ruby-changes:47080
From: ko1 <ko1@a...>
Date: Wed, 28 Jun 2017 15:09:12 +0900 (JST)
Subject: [ruby-changes:47080] ko1:r59195 (trunk): move fields to ec.
ko1 2017-06-28 15:09:06 +0900 (Wed, 28 Jun 2017) New Revision: 59195 https://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=59195 Log: move fields to ec. * vm_core.h (rb_thread_t): move root_lep, root_svar and ensure_list to rb_execution_context_t. Modified files: trunk/cont.c trunk/eval.c trunk/thread.c trunk/vm.c trunk/vm_core.h trunk/vm_insnhelper.c Index: eval.c =================================================================== --- eval.c (revision 59194) +++ eval.c (revision 59195) @@ -895,8 +895,8 @@ rb_ensure(VALUE (*b_proc)(ANYARGS), VALU https://github.com/ruby/ruby/blob/trunk/eval.c#L895 ensure_list.entry.marker = 0; ensure_list.entry.e_proc = e_proc; ensure_list.entry.data2 = data2; - ensure_list.next = th->ensure_list; - th->ensure_list = &ensure_list; + ensure_list.next = th->ec.ensure_list; + th->ec.ensure_list = &ensure_list; TH_PUSH_TAG(th); if ((state = EXEC_TAG()) == TAG_NONE) { result = (*b_proc) (data1); @@ -906,7 +906,7 @@ rb_ensure(VALUE (*b_proc)(ANYARGS), VALU https://github.com/ruby/ruby/blob/trunk/eval.c#L906 if (!NIL_P(errinfo) && !RB_TYPE_P(errinfo, T_OBJECT)) { th->errinfo = Qnil; } - th->ensure_list=ensure_list.next; + th->ec.ensure_list=ensure_list.next; (*ensure_list.entry.e_proc)(ensure_list.entry.data2); th->errinfo = errinfo; if (state) Index: cont.c =================================================================== --- cont.c (revision 59194) +++ cont.c (revision 59195) @@ -414,9 +414,6 @@ cont_save_thread(rb_context_t *cont, rb_ https://github.com/ruby/ruby/blob/trunk/cont.c#L414 VM_ASSERT(th->status == THREAD_RUNNABLE); sth->errinfo = th->errinfo; sth->first_proc = th->first_proc; - sth->root_lep = th->root_lep; - sth->root_svar = th->root_svar; - sth->ensure_list = th->ensure_list; sth->trace_arg = th->trace_arg; @@ -490,10 +487,10 @@ cont_capture(volatile int *volatile stat https://github.com/ruby/ruby/blob/trunk/cont.c#L487 rb_ensure_list_t *p; int size = 0; rb_ensure_entry_t *entry; - for (p=th->ensure_list; p; p=p->next) + for (p=th->ec.ensure_list; p; p=p->next) size++; entry = cont->ensure_array = ALLOC_N(rb_ensure_entry_t,size+1); - for (p=th->ensure_list; p; p=p->next) { + for (p=th->ec.ensure_list; p; p=p->next) { if (!p->entry.marker) p->entry.marker = rb_ary_tmp_new(0); /* dummy object */ *entry++ = p->entry; @@ -548,6 +545,9 @@ cont_restore_thread(rb_context_t *cont) https://github.com/ruby/ruby/blob/trunk/cont.c#L545 th->ec.raised_flag = sth->ec.raised_flag; th->ec.tag = sth->ec.tag; th->ec.protect_tag = sth->ec.protect_tag; + th->ec.root_lep = sth->ec.root_lep; + th->ec.root_svar = sth->ec.root_svar; + th->ec.ensure_list = sth->ec.ensure_list; } else { /* fiber */ @@ -558,9 +558,6 @@ cont_restore_thread(rb_context_t *cont) https://github.com/ruby/ruby/blob/trunk/cont.c#L558 th->errinfo = sth->errinfo; th->first_proc = sth->first_proc; - th->root_lep = sth->root_lep; - th->root_svar = sth->root_svar; - th->ensure_list = sth->ensure_list; VM_ASSERT(sth->status == THREAD_RUNNABLE); } @@ -1065,7 +1062,7 @@ rb_cont_call(int argc, VALUE *argv, VALU https://github.com/ruby/ruby/blob/trunk/cont.c#L1062 rb_raise(rb_eRuntimeError, "continuation called across fiber"); } } - rollback_ensure_stack(contval, th->ensure_list, cont->ensure_array); + rollback_ensure_stack(contval, th->ec.ensure_list, cont->ensure_array); cont->argc = argc; cont->value = make_passing_arg(argc, argv); @@ -1265,8 +1262,8 @@ rb_fiber_start(void) https://github.com/ruby/ruby/blob/trunk/cont.c#L1262 argv = (argc = cont->argc) > 1 ? RARRAY_CONST_PTR(args) : &args; cont->value = Qnil; th->errinfo = Qnil; - th->root_lep = rb_vm_proc_local_ep(cont->saved_thread.first_proc); - th->root_svar = Qfalse; + th->ec.root_lep = rb_vm_proc_local_ep(cont->saved_thread.first_proc); + th->ec.root_svar = Qfalse; fib->status = FIBER_RUNNING; EXEC_EVENT_HOOK(th, RUBY_EVENT_FIBER_SWITCH, th->self, 0, 0, 0, Qnil); Index: thread.c =================================================================== --- thread.c (revision 59194) +++ thread.c (revision 59195) @@ -581,8 +581,8 @@ thread_do_start(rb_thread_t *th, VALUE a https://github.com/ruby/ruby/blob/trunk/thread.c#L581 rb_proc_t *proc; GetProcPtr(th->first_proc, proc); th->errinfo = Qnil; - th->root_lep = rb_vm_proc_local_ep(th->first_proc); - th->root_svar = Qfalse; + th->ec.root_lep = rb_vm_proc_local_ep(th->first_proc); + th->ec.root_svar = Qfalse; EXEC_EVENT_HOOK(th, RUBY_EVENT_THREAD_BEGIN, th->self, 0, 0, 0, Qundef); th->value = rb_vm_invoke_proc(th, proc, (int)RARRAY_LEN(args), RARRAY_CONST_PTR(args), Index: vm_core.h =================================================================== --- vm_core.h (revision 59194) +++ vm_core.h (revision 59195) @@ -751,6 +751,13 @@ typedef struct rb_thread_context_struct https://github.com/ruby/ruby/blob/trunk/vm_core.h#L751 st_table *local_storage; VALUE local_storage_recursive_hash; VALUE local_storage_recursive_hash_for_trace; + + /* eval env */ + const VALUE *root_lep; + VALUE root_svar; + + /* ensure & callcc */ + rb_ensure_list_t *ensure_list; } rb_execution_context_t; typedef struct rb_thread_struct { @@ -775,10 +782,6 @@ typedef struct rb_thread_struct { https://github.com/ruby/ruby/blob/trunk/vm_core.h#L782 VALUE top_self; VALUE top_wrapper; - /* eval env */ - const VALUE *root_lep; - VALUE root_svar; - /* thread control */ rb_nativethread_id_t thread_id; #ifdef NON_SCALAR_THREAD_ID @@ -845,9 +848,6 @@ typedef struct rb_thread_struct { https://github.com/ruby/ruby/blob/trunk/vm_core.h#L848 rb_fiber_t *root_fiber; rb_jmpbuf_t root_jmpbuf; - /* ensure & callcc */ - rb_ensure_list_t *ensure_list; - /* misc */ enum method_missing_reason method_missing_reason: 8; unsigned int abort_on_exception: 1; Index: vm_insnhelper.c =================================================================== --- vm_insnhelper.c (revision 59194) +++ vm_insnhelper.c (revision 59195) @@ -369,11 +369,11 @@ lep_svar(rb_thread_t *th, const VALUE *l https://github.com/ruby/ruby/blob/trunk/vm_insnhelper.c#L369 { VALUE svar; - if (lep && (th == NULL || th->root_lep != lep)) { + if (lep && (th == NULL || th->ec.root_lep != lep)) { svar = lep[VM_ENV_DATA_INDEX_ME_CREF]; } else { - svar = th->root_svar; + svar = th->ec.root_svar; } VM_ASSERT(svar == Qfalse || vm_svar_valid_p(svar)); @@ -386,11 +386,11 @@ lep_svar_write(rb_thread_t *th, const VA https://github.com/ruby/ruby/blob/trunk/vm_insnhelper.c#L386 { VM_ASSERT(vm_svar_valid_p((VALUE)svar)); - if (lep && (th == NULL || th->root_lep != lep)) { + if (lep && (th == NULL || th->ec.root_lep != lep)) { vm_env_write(lep, VM_ENV_DATA_INDEX_ME_CREF, (VALUE)svar); } else { - RB_OBJ_WRITE(th->self, &th->root_svar, svar); + RB_OBJ_WRITE(th->self, &th->ec.root_svar, svar); } } Index: vm.c =================================================================== --- vm.c (revision 59194) +++ vm.c (revision 59195) @@ -2407,7 +2407,7 @@ rb_thread_mark(void *ptr) https://github.com/ruby/ruby/blob/trunk/vm.c#L2407 RUBY_MARK_UNLESS_NULL(th->errinfo); RUBY_MARK_UNLESS_NULL(th->pending_interrupt_queue); RUBY_MARK_UNLESS_NULL(th->pending_interrupt_mask_stack); - RUBY_MARK_UNLESS_NULL(th->root_svar); + RUBY_MARK_UNLESS_NULL(th->ec.root_svar); RUBY_MARK_UNLESS_NULL(th->top_self); RUBY_MARK_UNLESS_NULL(th->top_wrapper); rb_fiber_mark_self(th->fiber); @@ -2539,7 +2539,7 @@ th_init(rb_thread_t *th, VALUE self) https://github.com/ruby/ruby/blob/trunk/vm.c#L2539 th->status = THREAD_RUNNABLE; th->errinfo = Qnil; th->last_status = Qnil; - th->root_svar = Qfalse; + th->ec.root_svar = Qfalse; th->ec.local_storage_recursive_hash = Qnil; th->ec.local_storage_recursive_hash_for_trace = Qnil; #ifdef NON_SCALAR_THREAD_ID @@ -2564,7 +2564,7 @@ ruby_thread_init(VALUE self) https://github.com/ruby/ruby/blob/trunk/vm.c#L2564 th->top_wrapper = 0; th->top_self = rb_vm_top_self(); - th->root_svar = Qfalse; + th->ec.root_svar = Qfalse; return self; } -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/