Permalink
Browse files

Introduce tooling API, convert profiler to it.

  • Loading branch information...
Evan Phoenix
Evan Phoenix committed Apr 1, 2011
1 parent 16f0478 commit 73fb4869e098cecd30d19822896aaedd1de7e012
Showing with 2,040 additions and 1,044 deletions.
  1. +2 −0 .gitignore
  2. +1 −1 Rakefile
  3. +32 −1 configure
  4. +22 −0 kernel/bootstrap/rubinius.rb
  5. +0 −1 kernel/delta/load_order.txt
  6. +8 −0 kernel/loader.rb
  7. +162 −0 lib/tooling/profiler/Makefile
  8. +3 −0 lib/tooling/profiler/extconf.rb
  9. +4 −8 {kernel/delta → lib/tooling/profiler}/profiler.rb
  10. +826 −0 lib/tooling/profiler/profiler_vm.cpp
  11. +27 −6 projects/daedalus/daedalus.rb
  12. +4 −1 rakelib/extensions.rake
  13. +3 −5 vm/builtin/block_environment.cpp
  14. +3 −3 vm/builtin/nativefunction.cpp
  15. +3 −3 vm/builtin/nativemethod.cpp
  16. +12 −10 vm/builtin/system.cpp
  17. +12 −12 vm/builtin/system.hpp
  18. +117 −0 vm/capi/include/rbxti.hpp
  19. +4 −6 vm/codegen/field_extract.rb
  20. +13 −0 vm/config_parser.cpp
  21. +1 −0 vm/config_parser.hpp
  22. +6 −1 vm/configuration.hpp
  23. +41 −0 vm/environment.cpp
  24. +1 −0 vm/environment.hpp
  25. +0 −1 vm/instructions.cpp
  26. +0 −484 vm/instruments/profiler.cpp
  27. +0 −295 vm/instruments/profiler.hpp
  28. +86 −0 vm/instruments/rbxti-internal.hpp
  29. +317 −0 vm/instruments/rbxti.cpp
  30. +139 −0 vm/instruments/tooling.cpp
  31. +131 −0 vm/instruments/tooling.hpp
  32. +0 −2 vm/llvm/jit.cpp
  33. +2 −2 vm/llvm/jit_block.cpp
  34. +0 −1 vm/llvm/jit_compiler.cpp
  35. +2 −2 vm/llvm/jit_method.cpp
  36. +4 −4 vm/llvm/jit_util.cpp
  37. +1 −1 vm/primitives.cpp
  38. +2 −31 vm/shared_state.cpp
  39. +7 −9 vm/shared_state.hpp
  40. +0 −116 vm/test/test_profiler.hpp
  41. +4 −1 vm/util/configuration.hpp
  42. +12 −25 vm/vm.cpp
  43. +23 −9 vm/vm.hpp
  44. +3 −3 vm/vmmethod.cpp
View
@@ -72,6 +72,8 @@ tmtags
/lib/compiler/opcodes.rb
/lib/compiler/generator_methods.rb
+vm/capi/include/rbx_config.h
+
/lib/etc.rb
/lib/kernel.rb
/lib/zlib.rb
View
@@ -33,7 +33,7 @@ end
require config_rb
BUILD_CONFIG = Rubinius::BUILD_CONFIG
-unless BUILD_CONFIG[:config_version] == 35
+unless BUILD_CONFIG[:config_version] == 36
STDERR.puts "Your configuration is outdated, please run ./configure first"
exit 1
end
View
@@ -89,7 +89,7 @@ class Configure
@libversion = "1.2"
@version = "#{@libversion}.4dev"
@release_date = "yyyy-mm-dd"
- @config_version = 35
+ @config_version = 36
# TODO: add conditionals for platforms
if RbConfig::CONFIG["build_os"] =~ /darwin/
@@ -877,6 +877,37 @@ end
end
end
+ File.open "vm/capi/include/rbx_config.h", "w" do |f|
+ f.puts <<-EOC
+#define RBX_HOST "#{@host}"
+#define RBX_CPU "#{@cpu}"
+#define RBX_VENDOR "#{@vendor}"
+#define RBX_OS "#{@os}"
+#define RBX_BIN_PATH "#{@bindir}"
+#define RBX_GEMS_PATH "#{@gemsdir}"
+#define RBX_RUNTIME "#{@runtime}"
+#define RBX_LIB_PATH "#{@lib_path}"
+#define RBX_EXT_PATH "#{@ext_path}"
+#define RBX_HDR_PATH "#{@includedir}"
+#define RBX_SITE_PATH "#{@sitedir}"
+#define RBX_VENDOR_PATH "#{@vendordir}"
+#define RBX_VERSION "#{@version}"
+#define RBX_LIB_VERSION "#{@libversion}"
+#define RBX_LDSHARED "#{@ldshared}"
+#define RBX_RELEASE_DATE "#{@release_date}"
+#define RBX_SIZEOF_LONG #{@sizeof_long}
+#define RBX_LLVM_API_VER #{@llvm_api_version}
+ EOC
+
+ if @little_endian
+ f.puts "#define RBX_LITTLE_ENDIAN 1"
+ end
+
+ if @tr1_hash
+ f.puts "#define RBX_HAVE_TR1_HASH 1"
+ end
+ end
+
# Write a require file depending on which Readline library we use.
File.open "lib/readline.rb", "w" do |f|
if @rb_readline
@@ -118,4 +118,26 @@ def self.run_script(cm)
Ruby.primitive :vm_run_script
raise PrimitiveFailure, "Rubinius.run_script failed"
end
+
+ module Tooling
+ def self.available?
+ Ruby.primitive :vm_tooling_available_p
+ raise PrimitiveFailure, "Tooling.available? failed"
+ end
+
+ def self.active?
+ Ruby.primitive :vm_tooling_active_p
+ raise PrimitiveFailure, "Tooling.active? failed"
+ end
+
+ def self.enable
+ Ruby.primitive :vm_tooling_enable
+ raise PrimitiveFailure, "Tooling.enable failed"
+ end
+
+ def self.disable
+ Ruby.primitive :vm_tooling_disable
+ raise PrimitiveFailure, "Tooling.disable failed"
+ end
+ end
end
@@ -11,7 +11,6 @@ kernel.rbc
math.rbc
options.rbc
stats.rbc
-profiler.rbc
signal.rbc
struct.rbc
thread.rbc
View
@@ -429,6 +429,14 @@ def options(argv=ARGV)
handle_rubyopt(options)
+ if str = Rubinius::Config['tool.require']
+ begin
+ require str
+ rescue LoadError
+ STDERR.puts "Unable to require file for tool: '#{str}'"
+ end
+ end
+
if @profile
require 'profile'
end
@@ -0,0 +1,162 @@
+
+SHELL = /bin/sh
+
+#### Start of system configuration section. ####
+
+srcdir = .
+topdir = /Users/evan/git/rbx-release/vm/capi/include
+hdrdir = $(topdir)
+VPATH = $(srcdir):$(topdir):$(hdrdir)
+prefix = $(DESTDIR)/Users/evan/git/rbx-release
+exec_prefix = $(prefix)
+install_prefix = $(DESTDIR)
+includedir = $(prefix)/include
+bindir = $(DESTDIR)/Users/evan/git/rbx-release/bin
+sysconfdir = $(prefix)/etc
+localedir = $(datarootdir)/locale
+rubylibdir = $(DESTDIR)/Users/evan/git/rbx-release/lib/site
+sitedir = $(DESTDIR)/Users/evan/git/rbx-release/lib/site
+oldincludedir = $(DESTDIR)/usr/include
+libexecdir = $(exec_prefix)/libexec
+rubyhdrdir = $(DESTDIR)/Users/evan/git/rbx-release/vm/capi/include
+libdir = $(exec_prefix)/lib
+dvidir = $(docdir)
+docdir = $(datarootdir)/doc/$(PACKAGE)
+psdir = $(docdir)
+infodir = $(datarootdir)/info
+datadir = $(datarootdir)
+archdir = $(DESTDIR)/Users/evan/git/rbx-release/lib/site/x86_64-darwin10.7.0
+sharedstatedir = $(prefix)/com
+localstatedir = $(prefix)/var
+pdfdir = $(docdir)
+htmldir = $(docdir)
+datarootdir = $(prefix)/share
+sbindir = $(exec_prefix)/sbin
+sitelibdir = $(DESTDIR)/Users/evan/git/rbx-release/lib/site
+mandir = $(datarootdir)/man
+sitearchdir = $(DESTDIR)/Users/evan/git/rbx-release/lib/site/x86_64-darwin10.7.0
+
+CC = gcc
+LIBRUBY = $(LIBRUBY_SO)
+LIBRUBY_A =
+LIBRUBYARG_SHARED =
+LIBRUBYARG_STATIC =
+
+RUBY_EXTCONF_H =
+cflags =
+optflags =
+debugflags =
+warnflags =
+CFLAGS = -fPIC -ggdb3 -O2 -fPIC
+INCFLAGS = -I. -I$(topdir) -I$(hdrdir) -I$(srcdir)
+DEFS =
+CPPFLAGS =
+CXXFLAGS = $(CFLAGS)
+ldflags =
+dldflags =
+archflag =
+DLDFLAGS = $(ldflags) $(dldflags) $(archflag)
+LDSHARED = gcc -dynamic -bundle -undefined suppress -flat_namespace
+AR = ar
+EXEEXT =
+
+RUBY_INSTALL_NAME = rbx
+RUBY_SO_NAME = rubinius-1.2.4dev
+arch = x86_64-darwin10.7.0
+sitearch = x86_64-darwin10.7.0
+ruby_version = 1.8
+ruby = /Users/evan/git/rbx-release/bin/rbx
+RUBY = $(ruby)
+RM = rm -f
+MAKEDIRS = mkdir -p
+INSTALL = install -c
+INSTALL_PROG = $(INSTALL) -m 0755
+INSTALL_DATA = $(INSTALL) -m 644
+COPY = cp
+
+#### End of system configuration section. ####
+
+preload =
+
+libpath = . $(libdir)
+LIBPATH = -L. -L$(libdir)
+DEFFILE =
+
+CLEANFILES = mkmf.log
+DISTCLEANFILES =
+
+extout =
+extout_prefix =
+target_prefix =
+LOCAL_LIBS =
+LIBS = $(LIBRUBYARG_STATIC)
+SRCS = profiler_vm.cpp
+OBJS = profiler_vm.o
+TARGET = profiler_vm
+DLLIB = $(TARGET).bundle
+EXTSTATIC =
+STATIC_LIB =
+
+BINDIR = $(bindir)
+RUBYCOMMONDIR = $(sitedir)$(target_prefix)
+RUBYLIBDIR = $(sitelibdir)$(target_prefix)
+RUBYARCHDIR = $(sitearchdir)$(target_prefix)
+
+TARGET_SO = $(DLLIB)
+CLEANLIBS = $(TARGET).bundle
+CLEANOBJS = *.o *.bak
+
+all: $(DLLIB)
+static: $(STATIC_LIB)
+.PHONY: all install static install-so install-rb
+.PHONY: clean clean-so clean-rb
+
+clean:
+ @-$(RM) $(CLEANLIBS) $(CLEANOBJS) $(CLEANFILES)
+
+distclean: clean
+ @-$(RM) Makefile $(RUBY_EXTCONF_H) conftest.* mkmf.log
+ @-$(RM) core ruby$(EXEEXT) *~ $(DISTCLEANFILES)
+
+realclean: distclean
+install: install-so install-rb
+
+install-so: $(RUBYARCHDIR)
+install-so: $(RUBYARCHDIR)/$(DLLIB)
+$(RUBYARCHDIR)/$(DLLIB): $(DLLIB)
+ $(INSTALL_PROG) $(DLLIB) $(RUBYARCHDIR)
+install-rb: pre-install-rb install-rb-default
+install-rb-default: pre-install-rb-default
+pre-install-rb: Makefile
+pre-install-rb-default: Makefile
+$(RUBYARCHDIR):
+ $(MAKEDIRS) $@
+
+site-install: site-install-so site-install-rb
+site-install-so: install-so
+site-install-rb: install-rb
+
+.SUFFIXES: .c .m .cc .cxx .cpp .C .o
+
+.cc.o:
+ $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) -c $<
+
+.cxx.o:
+ $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) -c $<
+
+.cpp.o:
+ $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) -c $<
+
+.C.o:
+ $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) -c $<
+
+.c.o:
+ $(CC) $(INCFLAGS) $(CPPFLAGS) $(CFLAGS) -c $<
+
+$(DLLIB): $(OBJS) Makefile
+ @-$(RM) $@
+ $(LDSHARED) -o $@ $(OBJS) $(LIBPATH) $(DLDFLAGS) $(LOCAL_LIBS) $(LIBS)
+
+
+
+$(OBJS): ruby.h defines.h
@@ -0,0 +1,3 @@
+require 'mkmf'
+
+create_makefile 'profiler_vm'
@@ -10,13 +10,11 @@ class Instrumenter
attr_reader :info, :options
def self.available?
- Ruby.primitive :vm_profiler_instrumenter_available_p
- raise PrimitiveFailure, "Profiler::Instrumenter.available? failed"
+ Rubinius::Tooling.available?
end
def self.active?
- Ruby.primitive :vm_profiler_instrumenter_active_p
- raise PrimitiveFailure, "Profiler::Instrumenter.active? failed"
+ Rubinius::Tooling.active?
end
def initialize(options = {})
@@ -57,13 +55,11 @@ def set_options(options)
end
def start
- Ruby.primitive :vm_profiler_instrumenter_start
- raise PrimitiveFailure, "Profiler::Instrumenter#start failed"
+ Rubinius::Tooling.enable
end
def __stop__
- Ruby.primitive :vm_profiler_instrumenter_stop
- raise PrimitiveFailure, "Profiler::Instrumenter#stop failed"
+ Rubinius::Tooling.disable
end
def stop
Oops, something went wrong.

0 comments on commit 73fb486

Please sign in to comment.