From 1a960576262223e6ea1a2ead214cfaf90fc304e6 Mon Sep 17 00:00:00 2001 From: ko1 Date: Fri, 17 Nov 2017 06:24:55 +0000 Subject: remove `trace_` prefix insns lazily. * vm_trace.c (update_global_event_hook): set only when tracing is added. If tracing was off (event flags are decreased), then ignore them. Next `trace_` prefix instruction will trace off itself (lazy tracing off). * vm_insnhelper.c (vm_trace): trace-off for when trace is not needed. * iseq.c (rb_iseq_trace_set): fix trace-off process (it was never off tracing). git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60817 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- vm_trace.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) (limited to 'vm_trace.c') diff --git a/vm_trace.c b/vm_trace.c index efa2ee1bfb..d01a966a70 100644 --- a/vm_trace.c +++ b/vm_trace.c @@ -72,10 +72,14 @@ rb_vm_trace_mark_event_hooks(rb_hook_list_t *hooks) static void update_global_event_hook(rb_event_flag_t vm_events) { - if ((vm_events & RUBY_EVENTS_TRACE_BY_ISEQ) != - (ruby_vm_event_flags & RUBY_EVENTS_TRACE_BY_ISEQ)) { - rb_iseq_trace_set_all(vm_events); + rb_event_flag_t new_iseq_events = vm_events & RUBY_EVENTS_TRACE_BY_ISEQ; + rb_event_flag_t cur_iseq_events = ruby_vm_event_flags & RUBY_EVENTS_TRACE_BY_ISEQ; + + if (new_iseq_events > cur_iseq_events) { + /* write all ISeqs iff new events are added */ + rb_iseq_trace_set_all(vm_events); } + ruby_vm_event_flags = vm_events; rb_objspace_set_event_hook(vm_events); } -- cgit v1.2.3