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

rb_trace_arg_t::ec

* vm_core.h (rb_trace_arg_t): introduce `ec` field instead of `th`.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60538 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
ko1 2017-10-29 13:17:37 +00:00
parent 382aa678d0
commit 3fd1b00528
2 changed files with 33 additions and 33 deletions

View file

@ -1694,8 +1694,8 @@ ruby_vm_check_ints(rb_thread_t *th)
/* tracer */ /* tracer */
struct rb_trace_arg_struct { struct rb_trace_arg_struct {
rb_event_flag_t event; rb_event_flag_t event;
rb_thread_t *th; rb_execution_context_t *ec;
rb_control_frame_t *cfp; const rb_control_frame_t *cfp;
VALUE self; VALUE self;
ID id; ID id;
ID called_id; ID called_id;
@ -1727,7 +1727,7 @@ ruby_exec_event_hook_orig(rb_thread_t *const th, const rb_event_flag_t flag,
if ((th->event_hooks.events | th->vm->event_hooks.events) & flag) { if ((th->event_hooks.events | th->vm->event_hooks.events) & flag) {
struct rb_trace_arg_struct trace_arg; struct rb_trace_arg_struct trace_arg;
trace_arg.event = flag; trace_arg.event = flag;
trace_arg.th = th; trace_arg.ec = th->ec;
trace_arg.cfp = th->ec->cfp; trace_arg.cfp = th->ec->cfp;
trace_arg.self = self; trace_arg.self = self;
trace_arg.id = id; trace_arg.id = id;

View file

@ -301,60 +301,60 @@ exec_hooks_protected(rb_thread_t *th, rb_hook_list_t *list, const rb_trace_arg_t
static void static void
rb_threadptr_exec_event_hooks_orig(rb_trace_arg_t *trace_arg, int pop_p) rb_threadptr_exec_event_hooks_orig(rb_trace_arg_t *trace_arg, int pop_p)
{ {
rb_thread_t *th = trace_arg->th; rb_execution_context_t *ec = trace_arg->ec;
if (trace_arg->event & RUBY_INTERNAL_EVENT_MASK) { if (trace_arg->event & RUBY_INTERNAL_EVENT_MASK) {
if (th->ec->trace_arg && (th->ec->trace_arg->event & RUBY_INTERNAL_EVENT_MASK)) { if (ec->trace_arg && (ec->trace_arg->event & RUBY_INTERNAL_EVENT_MASK)) {
/* skip hooks because this thread doing INTERNAL_EVENT */ /* skip hooks because this thread doing INTERNAL_EVENT */
} }
else { else {
rb_trace_arg_t *prev_trace_arg = th->ec->trace_arg; rb_trace_arg_t *prev_trace_arg = ec->trace_arg;
th->vm->trace_running++; rb_ec_vm_ptr(ec)->trace_running++;
th->ec->trace_arg = trace_arg; ec->trace_arg = trace_arg;
exec_hooks_unprotected(th, &th->event_hooks, trace_arg); exec_hooks_unprotected(rb_ec_thread_ptr(ec), &rb_ec_thread_ptr(ec)->event_hooks, trace_arg);
exec_hooks_unprotected(th, &th->vm->event_hooks, trace_arg); exec_hooks_unprotected(rb_ec_thread_ptr(ec), &rb_ec_thread_ptr(ec)->vm->event_hooks, trace_arg);
th->ec->trace_arg = prev_trace_arg; ec->trace_arg = prev_trace_arg;
th->vm->trace_running--; rb_ec_vm_ptr(ec)->trace_running--;
} }
} }
else { else {
if (th->ec->trace_arg == NULL && /* check reentrant */ if (ec->trace_arg == NULL && /* check reentrant */
trace_arg->self != rb_mRubyVMFrozenCore /* skip special methods. TODO: remove it. */) { trace_arg->self != rb_mRubyVMFrozenCore /* skip special methods. TODO: remove it. */) {
const VALUE errinfo = th->ec->errinfo; const VALUE errinfo = ec->errinfo;
const VALUE old_recursive = th->ec->local_storage_recursive_hash; const VALUE old_recursive = ec->local_storage_recursive_hash;
int state = 0; int state = 0;
th->ec->local_storage_recursive_hash = th->ec->local_storage_recursive_hash_for_trace; ec->local_storage_recursive_hash = ec->local_storage_recursive_hash_for_trace;
th->ec->errinfo = Qnil; ec->errinfo = Qnil;
th->vm->trace_running++; rb_ec_vm_ptr(ec)->trace_running++;
th->ec->trace_arg = trace_arg; ec->trace_arg = trace_arg;
{ {
/* thread local traces */ /* thread local traces */
state = exec_hooks_protected(th, &th->event_hooks, trace_arg); state = exec_hooks_protected(rb_ec_thread_ptr(ec), &rb_ec_thread_ptr(ec)->event_hooks, trace_arg);
if (state) goto terminate; if (state) goto terminate;
/* vm global traces */ /* vm global traces */
state = exec_hooks_protected(th, &th->vm->event_hooks, trace_arg); state = exec_hooks_protected(rb_ec_thread_ptr(ec), &rb_ec_thread_ptr(ec)->vm->event_hooks, trace_arg);
if (state) goto terminate; if (state) goto terminate;
th->ec->errinfo = errinfo; ec->errinfo = errinfo;
} }
terminate: terminate:
th->ec->trace_arg = NULL; ec->trace_arg = NULL;
th->vm->trace_running--; rb_ec_vm_ptr(ec)->trace_running--;
th->ec->local_storage_recursive_hash_for_trace = th->ec->local_storage_recursive_hash; ec->local_storage_recursive_hash_for_trace = ec->local_storage_recursive_hash;
th->ec->local_storage_recursive_hash = old_recursive; ec->local_storage_recursive_hash = old_recursive;
if (state) { if (state) {
if (pop_p) { if (pop_p) {
if (VM_FRAME_FINISHED_P(th->ec->cfp)) { if (VM_FRAME_FINISHED_P(ec->cfp)) {
th->ec->tag = th->ec->tag->prev; ec->tag = ec->tag->prev;
} }
rb_vm_pop_frame(th->ec); rb_vm_pop_frame(ec);
} }
EC_JUMP_TAG(th->ec, state); EC_JUMP_TAG(ec, state);
} }
} }
} }
@ -735,7 +735,7 @@ static void
fill_path_and_lineno(rb_trace_arg_t *trace_arg) fill_path_and_lineno(rb_trace_arg_t *trace_arg)
{ {
if (trace_arg->path == Qundef) { if (trace_arg->path == Qundef) {
rb_control_frame_t *cfp = rb_vm_get_ruby_level_next_cfp(trace_arg->th->ec, trace_arg->cfp); rb_control_frame_t *cfp = rb_vm_get_ruby_level_next_cfp(trace_arg->ec, trace_arg->cfp);
if (cfp) { if (cfp) {
trace_arg->path = rb_iseq_path(cfp->iseq); trace_arg->path = rb_iseq_path(cfp->iseq);
@ -807,10 +807,10 @@ VALUE
rb_tracearg_binding(rb_trace_arg_t *trace_arg) rb_tracearg_binding(rb_trace_arg_t *trace_arg)
{ {
rb_control_frame_t *cfp; rb_control_frame_t *cfp;
cfp = rb_vm_get_binding_creatable_next_cfp(trace_arg->th->ec, trace_arg->cfp); cfp = rb_vm_get_binding_creatable_next_cfp(trace_arg->ec, trace_arg->cfp);
if (cfp) { if (cfp) {
return rb_vm_make_binding(trace_arg->th->ec, cfp); return rb_vm_make_binding(trace_arg->ec, cfp);
} }
else { else {
return Qnil; return Qnil;