2007-06-09 23:06:15 -04:00
|
|
|
#include <ruby/ruby.h>
|
* blockinlining.c: remove "yarv" prefix.
* array.c, numeric.c: ditto.
* insnhelper.ci, insns.def, vm_evalbody.ci: ditto.
* yarvcore.c: removed.
* yarvcore.h: renamed to core.h.
* cont.c, debug.c, error.c, process.c, signal.c : ditto.
* ext/probeprofiler/probeprofiler.c: ditto.
* id.c, id.h: added.
* inits.c: ditto.
* compile.c: rename internal functions.
* compile.h: fix debug flag.
* eval.c, object.c, vm.c: remove ruby_top_self.
use rb_vm_top_self() instead.
* eval_intern.h, eval_load: ditto.
* gc.c: rename yarv_machine_stack_mark() to
rb_gc_mark_machine_stack().
* insnhelper.h: remove unused macros.
* iseq.c: add iseq_compile() to create iseq object
from source string.
* proc.c: rename a internal function.
* template/insns.inc.tmpl: remove YARV prefix.
* thread.c:
* vm.c (rb_iseq_eval): added.
* vm.c: move some functions from yarvcore.c.
* vm_dump.c: fix to remove compiler warning.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@12741 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-07-12 00:25:46 -04:00
|
|
|
#include <vm_core.h>
|
2007-04-25 00:10:55 -04:00
|
|
|
|
2007-06-10 05:35:42 -04:00
|
|
|
VALUE rb_thread_current_status(rb_thread_t *);
|
|
|
|
void rb_add_event_hook(rb_event_hook_func_t, rb_event_flag_t, VALUE);
|
|
|
|
int rb_remove_event_hook(rb_event_hook_func_t);
|
|
|
|
|
2007-04-25 00:10:55 -04:00
|
|
|
static void
|
|
|
|
hash_inc(VALUE data, VALUE key)
|
|
|
|
{
|
|
|
|
VALUE num = INT2FIX(0);
|
|
|
|
|
2007-06-10 05:35:42 -04:00
|
|
|
if (RTEST(num = rb_hash_aref(data, key))) {
|
2007-04-25 00:10:55 -04:00
|
|
|
num = INT2FIX(FIX2INT(num) + 1);
|
|
|
|
}
|
|
|
|
|
|
|
|
rb_hash_aset(data, key, num);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
pprof_hook(rb_event_flag_t flag, VALUE data,
|
2007-06-10 05:35:42 -04:00
|
|
|
VALUE self, ID dmyid, VALUE dmyklass)
|
2007-04-25 00:10:55 -04:00
|
|
|
{
|
|
|
|
rb_thread_t *th = GET_THREAD();
|
2007-04-25 01:14:33 -04:00
|
|
|
VALUE sig = rb_thread_current_status(th);
|
2007-04-25 00:10:55 -04:00
|
|
|
hash_inc(data, sig);
|
|
|
|
}
|
|
|
|
|
|
|
|
static VALUE
|
|
|
|
pprof_data(VALUE mod)
|
|
|
|
{
|
2007-04-25 01:14:33 -04:00
|
|
|
return rb_const_get_at(mod, rb_intern("#pprof_data"));
|
2007-04-25 00:10:55 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
static VALUE
|
|
|
|
pprof_start(VALUE self)
|
|
|
|
{
|
|
|
|
VALUE data = pprof_data(self);
|
|
|
|
rb_add_event_hook(pprof_hook, RUBY_EVENT_SWITCH, data);
|
|
|
|
return Qnil;
|
|
|
|
}
|
|
|
|
|
|
|
|
static VALUE
|
|
|
|
pprof_stop(VALUE self)
|
|
|
|
{
|
|
|
|
rb_remove_event_hook(pprof_hook);
|
|
|
|
return Qnil;
|
|
|
|
}
|
|
|
|
|
2007-06-10 05:35:42 -04:00
|
|
|
void
|
2007-04-25 00:10:55 -04:00
|
|
|
Init_probeprofiler(void)
|
|
|
|
{
|
|
|
|
VALUE mPProf;
|
|
|
|
|
|
|
|
mPProf = rb_define_module("ProbeProfiler");
|
|
|
|
rb_const_set(mPProf, rb_intern("#pprof_data"), rb_hash_new());
|
|
|
|
rb_define_module_function(mPProf, "start_profile", pprof_start, 0);
|
|
|
|
rb_define_module_function(mPProf, "stop_profile", pprof_stop, 0);
|
|
|
|
rb_define_module_function(mPProf, "profile_data", pprof_data, 0);
|
|
|
|
}
|
|
|
|
|