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_insnhelper.c | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'vm_insnhelper.c') diff --git a/vm_insnhelper.c b/vm_insnhelper.c index 357a85d589..b172c2d20f 100644 --- a/vm_insnhelper.c +++ b/vm_insnhelper.c @@ -3729,9 +3729,16 @@ vm_trace(rb_execution_context_t *ec, rb_control_frame_t *reg_cfp, const VALUE *p { const rb_iseq_t *iseq = reg_cfp->iseq; size_t pos = pc - iseq->body->iseq_encoded; + rb_event_flag_t cur_event_flags = ruby_vm_event_flags; rb_event_flag_t events = rb_iseq_event_flags(iseq, pos); rb_event_flag_t event; + if ((events & cur_event_flags) == 0) { + /* disable trace */ + rb_iseq_trace_set(iseq, cur_event_flags); + return; + } + if (ec->trace_arg != NULL) return; if (0) { -- cgit v1.2.3