summaryrefslogtreecommitdiff
path: root/vm.c
diff options
context:
space:
mode:
authorko1 <ko1@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2012-08-16 11:41:24 +0000
committerko1 <ko1@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2012-08-16 11:41:24 +0000
commit4a4a702e61d1c5585d522f1185a82a5685c554f6 (patch)
treebbbd9f9a92339aa20f6a113238965064a67487c7 /vm.c
parent9528358120511f0587be39c853f5916cf8d05a9d (diff)
* vm_trace.c, vm_core.h: simplify tracing mechanism.
(1) add rb_hook_list_t data structure which includes hooks, events (flag) and `need_clean' flag. If the last flag is true, then clean the hooks list. In other words, deleted hooks are contained by `hooks'. Cleanup process should run before traversing the list. (2) Change check mechanism See EXEC_EVENT_HOOK() in vm_core.h. (3) Add `raw' hooks APIs Normal hooks are guarded from exception by rb_protect(). However, this protection is overhead for too simple functions which never cause exceptions. `raw' hooks are executed without protection and faster. Now, we only provide registration APIs. All `raw' hooks are kicked under protection (same as normal hooks). * include/ruby/ruby.h: remove internal data definition and macros. * internal.h (ruby_suppress_tracing), vm_trace.c: rename ruby_suppress_tracing() to rb_suppress_tracing() and remove unused function parameter. * parse.y: fix to use renamed rb_suppress_tracing(). * thread.c (thread_create_core): no need to set RUBY_VM_VM. * vm.c (mark_event_hooks): move definition to vm_trace.c. * vm.c (ruby_vm_event_flags): add a global variable. This global variable represents all of Threads and VM's event masks (T1#events | T2#events | ... | VM#events). You can check the possibility kick trace func or not with ruby_vm_event_flags. ruby_vm_event_flags is maintained by vm_trace.c. * cont.c (fiber_switch, rb_cont_call): restore tracing status. [Feature #4347] * test/ruby/test_continuation.rb: ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@36715 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'vm.c')
-rw-r--r--vm.c14
1 files changed, 4 insertions, 10 deletions
diff --git a/vm.c b/vm.c
index 80dd512ae1..443260ea43 100644
--- a/vm.c
+++ b/vm.c
@@ -83,6 +83,7 @@ VALUE ruby_vm_const_missing_count = 0;
char ruby_vm_redefined_flag[BOP_LAST_];
rb_thread_t *ruby_current_thread = 0;
rb_vm_t *ruby_current_vm = 0;
+rb_event_flag_t ruby_vm_event_flags;
static void thread_free(void *ptr);
@@ -1462,14 +1463,7 @@ vm_mark_each_thread_func(st_data_t key, st_data_t value, st_data_t dummy)
return ST_CONTINUE;
}
-static void
-mark_event_hooks(rb_event_hook_t *hook)
-{
- while (hook) {
- rb_gc_mark(hook->data);
- hook = hook->next;
- }
-}
+void vm_trace_mark_event_hooks(rb_hook_list_t *hooks);
void
rb_vm_mark(void *ptr)
@@ -1495,7 +1489,7 @@ rb_vm_mark(void *ptr)
rb_mark_tbl(vm->loading_table);
}
- mark_event_hooks(vm->event_hooks);
+ vm_trace_mark_event_hooks(&vm->event_hooks);
for (i = 0; i < RUBY_NSIG; i++) {
if (vm->trap_list[i].cmd)
@@ -1671,7 +1665,7 @@ rb_thread_mark(void *ptr)
sizeof(th->machine_regs) / sizeof(VALUE));
}
- mark_event_hooks(th->event_hooks);
+ vm_trace_mark_event_hooks(&th->event_hooks);
}
RUBY_MARK_LEAVE("thread");