ruby-changes:48703
From: ko1 <ko1@a...>
Date: Fri, 17 Nov 2017 15:59:28 +0900 (JST)
Subject: [ruby-changes:48703] ko1:r60819 (trunk): reuse gvar value.
ko1 2017-11-17 15:59:22 +0900 (Fri, 17 Nov 2017) New Revision: 60819 https://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=60819 Log: reuse gvar value. * vm_core.h (EXEC_EVENT_HOOK_VM_TRACE): added to pass vm_event_flags (== ruby_vm_event_flags) as a macro parameter. * vm_insnhelper.c (vm_trace): use an added macro. Modified files: trunk/vm_core.h trunk/vm_insnhelper.c Index: vm_core.h =================================================================== --- vm_core.h (revision 60818) +++ vm_core.h (revision 60819) @@ -1719,9 +1719,9 @@ struct rb_trace_arg_struct { https://github.com/ruby/ruby/blob/trunk/vm_core.h#L1719 void rb_exec_event_hooks(struct rb_trace_arg_struct *trace_arg, int pop_p); -#define EXEC_EVENT_HOOK_ORIG(ec_, flag_, self_, id_, called_id_, klass_, data_, pop_p_) do { \ +#define EXEC_EVENT_HOOK_ORIG(ec_, flag_, vm_flags_, self_, id_, called_id_, klass_, data_, pop_p_) do { \ const rb_event_flag_t flag_arg_ = (flag_); \ - if (UNLIKELY(ruby_vm_event_flags & (flag_arg_))) { \ + if (UNLIKELY(vm_flags_ & (flag_arg_))) { \ /* defer evaluating the other arguments */ \ rb_exec_event_hook_orig(ec_, flag_arg_, self_, id_, called_id_, klass_, data_, pop_p_); \ } \ @@ -1731,29 +1731,32 @@ static inline void https://github.com/ruby/ruby/blob/trunk/vm_core.h#L1731 rb_exec_event_hook_orig(rb_execution_context_t *ec, const rb_event_flag_t flag, VALUE self, ID id, ID called_id, VALUE klass, VALUE data, int pop_p) { - const rb_vm_t *vm = rb_ec_vm_ptr(ec); + struct rb_trace_arg_struct trace_arg; - if (vm->event_hooks.events & flag) { - struct rb_trace_arg_struct trace_arg; - trace_arg.event = flag; - trace_arg.ec = ec; - trace_arg.cfp = ec->cfp; - trace_arg.self = self; - trace_arg.id = id; - trace_arg.called_id = called_id; - trace_arg.klass = klass; - trace_arg.data = data; - trace_arg.path = Qundef; - trace_arg.klass_solved = 0; - rb_exec_event_hooks(&trace_arg, pop_p); - } + VM_ASSERT(rb_ec_vm_ptr(ec)->event_hooks.events == ruby_vm_event_flags); + VM_ASSERT(rb_ec_vm_ptr(ec)->event_hooks.events & flag); + + trace_arg.event = flag; + trace_arg.ec = ec; + trace_arg.cfp = ec->cfp; + trace_arg.self = self; + trace_arg.id = id; + trace_arg.called_id = called_id; + trace_arg.klass = klass; + trace_arg.data = data; + trace_arg.path = Qundef; + trace_arg.klass_solved = 0; + rb_exec_event_hooks(&trace_arg, pop_p); } #define EXEC_EVENT_HOOK(ec_, flag_, self_, id_, called_id_, klass_, data_) \ - EXEC_EVENT_HOOK_ORIG(ec_, flag_, self_, id_, called_id_, klass_, data_, 0) + EXEC_EVENT_HOOK_ORIG(ec_, flag_, ruby_vm_event_flags, self_, id_, called_id_, klass_, data_, 0) + +#define EXEC_EVENT_HOOK_VM_TRACE(ec_, flag_, vm_flag_, self_, id_, called_id_, klass_, data_) \ + EXEC_EVENT_HOOK_ORIG(ec_, flag_, vm_flag_, self_, id_, called_id_, klass_, data_, 0) #define EXEC_EVENT_HOOK_AND_POP_FRAME(ec_, flag_, self_, id_, called_id_, klass_, data_) \ - EXEC_EVENT_HOOK_ORIG(ec_, flag_, self_, id_, called_id_, klass_, data_, 1) + EXEC_EVENT_HOOK_ORIG(ec_, flag_, ruby_vm_event_flags, self_, id_, called_id_, klass_, data_, 1) RUBY_SYMBOL_EXPORT_BEGIN Index: vm_insnhelper.c =================================================================== --- vm_insnhelper.c (revision 60818) +++ vm_insnhelper.c (revision 60819) @@ -3729,13 +3729,13 @@ vm_trace(rb_execution_context_t *ec, rb_ https://github.com/ruby/ruby/blob/trunk/vm_insnhelper.c#L3729 { 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 vm_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) { + if ((events & vm_event_flags) == 0) { /* disable trace */ - rb_iseq_trace_set(iseq, cur_event_flags); + rb_iseq_trace_set(iseq, vm_event_flags); return; } @@ -3752,32 +3752,31 @@ vm_trace(rb_execution_context_t *ec, rb_ https://github.com/ruby/ruby/blob/trunk/vm_insnhelper.c#L3752 VM_ASSERT(reg_cfp->pc == pc); VM_ASSERT(events != 0); + VM_ASSERT(vm_event_flags & events); /* increment PC because source line is calculated with PC-1 */ - if (events & ruby_vm_event_flags) { - if (event = (events & (RUBY_EVENT_CLASS | RUBY_EVENT_CALL | RUBY_EVENT_B_CALL))) { - VM_ASSERT(event == RUBY_EVENT_CLASS || - event == RUBY_EVENT_CALL || - event == RUBY_EVENT_B_CALL); - reg_cfp->pc++; - vm_dtrace(event, ec); - EXEC_EVENT_HOOK(ec, event, GET_SELF(), 0, 0, 0, Qundef); - reg_cfp->pc--; - } - if (events & RUBY_EVENT_LINE) { - reg_cfp->pc++; - vm_dtrace(RUBY_EVENT_LINE, ec); - EXEC_EVENT_HOOK(ec, RUBY_EVENT_LINE, GET_SELF(), 0, 0, 0, Qundef); - reg_cfp->pc--; - } - if (event = (events & (RUBY_EVENT_END | RUBY_EVENT_RETURN | RUBY_EVENT_B_RETURN))) { - VM_ASSERT(event == RUBY_EVENT_END || - event == RUBY_EVENT_RETURN || - event == RUBY_EVENT_B_RETURN); - reg_cfp->pc++; - vm_dtrace(RUBY_EVENT_LINE, ec); - EXEC_EVENT_HOOK(ec, event, GET_SELF(), 0, 0, 0, TOPN(0)); - reg_cfp->pc--; - } + if (event = (events & (RUBY_EVENT_CLASS | RUBY_EVENT_CALL | RUBY_EVENT_B_CALL))) { + VM_ASSERT(event == RUBY_EVENT_CLASS || + event == RUBY_EVENT_CALL || + event == RUBY_EVENT_B_CALL); + reg_cfp->pc++; + vm_dtrace(event, ec); + EXEC_EVENT_HOOK_VM_TRACE(ec, event, vm_event_flags, GET_SELF(), 0, 0, 0, Qundef); + reg_cfp->pc--; + } + if (events & RUBY_EVENT_LINE) { + reg_cfp->pc++; + vm_dtrace(RUBY_EVENT_LINE, ec); + EXEC_EVENT_HOOK_VM_TRACE(ec, RUBY_EVENT_LINE, vm_event_flags, GET_SELF(), 0, 0, 0, Qundef); + reg_cfp->pc--; + } + if (event = (events & (RUBY_EVENT_END | RUBY_EVENT_RETURN | RUBY_EVENT_B_RETURN))) { + VM_ASSERT(event == RUBY_EVENT_END || + event == RUBY_EVENT_RETURN || + event == RUBY_EVENT_B_RETURN); + reg_cfp->pc++; + vm_dtrace(RUBY_EVENT_LINE, ec); + EXEC_EVENT_HOOK_VM_TRACE(ec, event, vm_event_flags, GET_SELF(), 0, 0, 0, TOPN(0)); + reg_cfp->pc--; } } -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/