mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
* ext/objspace/gc_hook.c: prohibit reentrant.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43253 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
542b31ca27
commit
33ab98f9e6
2 changed files with 32 additions and 5 deletions
|
@ -1,3 +1,7 @@
|
||||||
|
Fri Oct 11 18:12:47 2013 Koichi Sasada <ko1@atdot.net>
|
||||||
|
|
||||||
|
* ext/objspace/gc_hook.c: prohibit reentrant.
|
||||||
|
|
||||||
Fri Oct 11 18:11:34 2013 Koichi Sasada <ko1@atdot.net>
|
Fri Oct 11 18:11:34 2013 Koichi Sasada <ko1@atdot.net>
|
||||||
|
|
||||||
* vm_trace.c (rb_postponed_job_flush): fix bit operation.
|
* vm_trace.c (rb_postponed_job_flush): fix bit operation.
|
||||||
|
|
|
@ -16,19 +16,40 @@
|
||||||
#include "ruby/ruby.h"
|
#include "ruby/ruby.h"
|
||||||
#include "ruby/debug.h"
|
#include "ruby/debug.h"
|
||||||
|
|
||||||
|
static int invoking; /* TODO: should not be global variable */
|
||||||
|
|
||||||
|
static VALUE
|
||||||
|
invoke_proc_ensure(void *dmy)
|
||||||
|
{
|
||||||
|
invoking = 0;
|
||||||
|
return Qnil;
|
||||||
|
}
|
||||||
|
|
||||||
|
static VALUE
|
||||||
|
invoke_proc_begin(VALUE proc)
|
||||||
|
{
|
||||||
|
return rb_proc_call(proc, rb_ary_new());
|
||||||
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
invoke_proc(void *data)
|
invoke_proc(void *data)
|
||||||
{
|
{
|
||||||
VALUE proc = (VALUE)data;
|
VALUE proc = (VALUE)data;
|
||||||
rb_proc_call(proc, rb_ary_new());
|
invoking += 1;
|
||||||
|
rb_ensure(invoke_proc_begin, proc, invoke_proc_ensure, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
gc_start_end_i(VALUE tpval, void *data)
|
gc_start_end_i(VALUE tpval, void *data)
|
||||||
{
|
{
|
||||||
rb_trace_arg_t *tparg = rb_tracearg_from_tracepoint(tpval);
|
if (0) {
|
||||||
if (0) fprintf(stderr, "trace: %s\n", rb_tracearg_event_flag(tparg) == RUBY_INTERNAL_EVENT_GC_START ? "gc_start" : "gc_end");
|
rb_trace_arg_t *tparg = rb_tracearg_from_tracepoint(tpval);
|
||||||
rb_postponed_job_register(0, invoke_proc, data);
|
fprintf(stderr, "trace: %s\n", rb_tracearg_event_flag(tparg) == RUBY_INTERNAL_EVENT_GC_START ? "gc_start" : "gc_end");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (invoking == 0) {
|
||||||
|
rb_postponed_job_register(0, invoke_proc, data);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static VALUE
|
static VALUE
|
||||||
|
@ -38,7 +59,9 @@ set_gc_hook(VALUE rb_mObjSpace, VALUE proc, rb_event_flag_t event, const char *t
|
||||||
ID tp_key = rb_intern(tp_str);
|
ID tp_key = rb_intern(tp_str);
|
||||||
ID proc_key = rb_intern(proc_str);
|
ID proc_key = rb_intern(proc_str);
|
||||||
|
|
||||||
if (RTEST(tpval = rb_ivar_get(rb_mObjSpace, tp_key))) {
|
/* disable previous keys */
|
||||||
|
if (rb_ivar_defined(rb_mObjSpace, tp_key) != 0 &&
|
||||||
|
RTEST(tpval = rb_ivar_get(rb_mObjSpace, tp_key))) {
|
||||||
rb_tracepoint_disable(tpval);
|
rb_tracepoint_disable(tpval);
|
||||||
rb_ivar_set(rb_mObjSpace, tp_key, Qnil);
|
rb_ivar_set(rb_mObjSpace, tp_key, Qnil);
|
||||||
rb_ivar_set(rb_mObjSpace, proc_key, Qnil);
|
rb_ivar_set(rb_mObjSpace, proc_key, Qnil);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue