diff options
author | ko1 <ko1@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2012-08-16 11:41:24 +0000 |
---|---|---|
committer | ko1 <ko1@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2012-08-16 11:41:24 +0000 |
commit | 4a4a702e61d1c5585d522f1185a82a5685c554f6 (patch) | |
tree | bbbd9f9a92339aa20f6a113238965064a67487c7 /vm_core.h | |
parent | 9528358120511f0587be39c853f5916cf8d05a9d (diff) | |
download | ruby-4a4a702e61d1c5585d522f1185a82a5685c554f6.tar.gz |
* 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_core.h')
-rw-r--r-- | vm_core.h | 19 |
1 files changed, 12 insertions, 7 deletions
@@ -290,6 +290,12 @@ struct rb_objspace; void rb_objspace_free(struct rb_objspace *); #endif +typedef struct rb_hook_list_struct { + struct rb_event_hook_struct *hooks; + rb_event_flag_t events; + int need_clean; +} rb_hook_list_t; + typedef struct rb_vm_struct { VALUE self; @@ -325,7 +331,7 @@ typedef struct rb_vm_struct { } trap_list[RUBY_NSIG]; /* hook */ - rb_event_hook_t *event_hooks; + rb_hook_list_t event_hooks; int src_encoding_index; @@ -513,9 +519,8 @@ typedef struct rb_thread_struct { VALUE stat_insn_usage; /* tracer */ - rb_event_hook_t *event_hooks; - rb_event_flag_t event_flags; - int tracing; + rb_hook_list_t event_hooks; + int trace_running; /* fiber */ VALUE fiber; @@ -764,6 +769,7 @@ int rb_autoloading_value(VALUE mod, ID id, VALUE* value); #if RUBY_VM_THREAD_MODEL == 2 extern rb_thread_t *ruby_current_thread; extern rb_vm_t *ruby_current_vm; +extern rb_event_flag_t ruby_vm_event_flags; #define GET_VM() ruby_current_vm #define GET_THREAD() ruby_current_thread @@ -817,9 +823,8 @@ void rb_threadptr_exec_event_hooks(rb_thread_t *th, rb_event_flag_t flag, VALUE self, ID id, VALUE klass); #define EXEC_EVENT_HOOK(th, flag, self, id, klass) do { \ - rb_event_flag_t wait_event__ = (th)->event_flags; \ - if (UNLIKELY(wait_event__)) { \ - if (wait_event__ & ((flag) | RUBY_EVENT_VM)) { \ + if (UNLIKELY(ruby_vm_event_flags & (flag))) { \ + if (((th)->event_hooks.events | (th)->vm->event_hooks.events) & (flag)) { \ rb_threadptr_exec_event_hooks((th), (flag), (self), (id), (klass)); \ } \ } \ |