1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

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.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60819 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
ko1 2017-11-17 06:59:22 +00:00
parent 1fcdec57da
commit c7ae8af92f
2 changed files with 49 additions and 47 deletions

View file

@ -1719,9 +1719,9 @@ struct rb_trace_arg_struct {
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
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

View file

@ -3729,13 +3729,13 @@ 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 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_control_frame_t *reg_cfp, const VALUE *p
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--;
}
}