ruby-changes:48555
From: ko1 <ko1@a...>
Date: Mon, 6 Nov 2017 14:41:52 +0900 (JST)
Subject: [ruby-changes:48555] ko1:r60670 (trunk): renmae ec::fiber to ec::fiber_ptr.
ko1 2017-11-06 14:41:48 +0900 (Mon, 06 Nov 2017) New Revision: 60670 https://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=60670 Log: renmae ec::fiber to ec::fiber_ptr. * vm_core.h (rb_execution_context_t): renmae ec::fiber to ec::fiber_ptr make consistent with ec::thread_ptr. Modified files: trunk/cont.c trunk/thread.c trunk/vm.c trunk/vm_core.h Index: thread.c =================================================================== --- thread.c (revision 60669) +++ thread.c (revision 60670) @@ -696,7 +696,7 @@ thread_start_func_2(rb_thread_t *th, VAL https://github.com/ruby/ruby/blob/trunk/thread.c#L696 rb_threadptr_unlock_all_locking_mutexes(th); rb_check_deadlock(th->vm); - rb_fiber_close(th->ec->fiber); + rb_fiber_close(th->ec->fiber_ptr); } native_mutex_lock(&th->vm->thread_destruct_lock); /* make sure vm->running_thread never point me after this point.*/ Index: vm.c =================================================================== --- vm.c (revision 60669) +++ vm.c (revision 60670) @@ -2393,7 +2393,7 @@ rb_thread_mark(void *ptr) https://github.com/ruby/ruby/blob/trunk/vm.c#L2393 { rb_thread_t *th = ptr; RUBY_MARK_ENTER("thread"); - rb_fiber_mark_self(th->ec->fiber); + rb_fiber_mark_self(th->ec->fiber_ptr); /* mark ruby objects */ RUBY_MARK_UNLESS_NULL(th->first_proc); Index: vm_core.h =================================================================== --- vm_core.h (revision 60669) +++ vm_core.h (revision 60670) @@ -745,8 +745,8 @@ typedef struct rb_execution_context_stru https://github.com/ruby/ruby/blob/trunk/vm_core.h#L745 int safe_level; int raised_flag; - /* temporary place of errinfo */ - VALUE errinfo; + rb_fiber_t *fiber_ptr; + struct rb_thread_struct *thread_ptr; /* storage (ec (fiber) local) */ st_table *local_storage; @@ -757,21 +757,16 @@ typedef struct rb_execution_context_stru https://github.com/ruby/ruby/blob/trunk/vm_core.h#L757 const VALUE *root_lep; VALUE root_svar; - /* trace information */ - struct rb_trace_arg_struct *trace_arg; - /* ensure & callcc */ rb_ensure_list_t *ensure_list; - rb_fiber_t *fiber; - - /* for rb_iterate */ - VALUE passed_block_handler; - - /* for bmethod */ - const rb_callable_method_entry_t *passed_bmethod_me; + /* trace information */ + struct rb_trace_arg_struct *trace_arg; - struct rb_thread_struct *thread_ptr; + /* temporary places */ + VALUE errinfo; + VALUE passed_block_handler; /* for rb_iterate */ + const rb_callable_method_entry_t *passed_bmethod_me; /* for bmethod */ /* for GC */ struct { Index: cont.c =================================================================== --- cont.c (revision 60669) +++ cont.c (revision 60670) @@ -192,7 +192,7 @@ static void https://github.com/ruby/ruby/blob/trunk/cont.c#L192 fiber_verify(const rb_fiber_t *fib) { #if VM_CHECK_MODE > 0 - VM_ASSERT(fib->cont.saved_ec.fiber == fib); + VM_ASSERT(fib->cont.saved_ec.fiber_ptr == fib); switch (fib->status) { case FIBER_RESUMED: @@ -241,7 +241,7 @@ ec_switch(rb_thread_t *th, rb_fiber_t *f https://github.com/ruby/ruby/blob/trunk/cont.c#L241 { rb_execution_context_t *ec = &fib->cont.saved_ec; ruby_current_execution_context_ptr = th->ec = ec; - VM_ASSERT(ec->fiber->cont.self == 0 || ec->vm_stack != NULL); + VM_ASSERT(ec->fiber_ptr->cont.self == 0 || ec->vm_stack != NULL); } static const rb_data_type_t cont_data_type, fiber_data_type; @@ -657,7 +657,7 @@ static inline void https://github.com/ruby/ruby/blob/trunk/cont.c#L657 fiber_restore_thread(rb_thread_t *th, rb_fiber_t *fib) { ec_switch(th, fib); - VM_ASSERT(th->ec->fiber == fib); + VM_ASSERT(th->ec->fiber_ptr == fib); } static inline void @@ -671,8 +671,8 @@ cont_restore_thread(rb_context_t *cont) https://github.com/ruby/ruby/blob/trunk/cont.c#L671 rb_execution_context_t *sec = &cont->saved_ec; rb_fiber_t *fib = NULL; - if (sec->fiber != NULL) { - fib = sec->fiber; + if (sec->fiber_ptr != NULL) { + fib = sec->fiber_ptr; } else if (th->root_fiber) { fib = th->root_fiber; @@ -1203,8 +1203,8 @@ rb_cont_call(int argc, VALUE *argv, VALU https://github.com/ruby/ruby/blob/trunk/cont.c#L1203 if (cont->saved_ec.protect_tag != th->ec->protect_tag) { rb_raise(rb_eRuntimeError, "continuation called across stack rewinding barrier"); } - if (cont->saved_ec.fiber) { - if (th->ec->fiber != cont->saved_ec.fiber) { + if (cont->saved_ec.fiber_ptr) { + if (th->ec->fiber_ptr != cont->saved_ec.fiber_ptr) { rb_raise(rb_eRuntimeError, "continuation called across fiber"); } } @@ -1311,7 +1311,7 @@ fiber_t_alloc(VALUE fibval) https://github.com/ruby/ruby/blob/trunk/cont.c#L1311 fib->cont.self = fibval; fib->cont.type = FIBER_CONTEXT; cont_init(&fib->cont, th); - fib->cont.saved_ec.fiber = fib; + fib->cont.saved_ec.fiber_ptr = fib; fib->prev = NULL; /* fib->status == 0 == CREATED @@ -1395,7 +1395,7 @@ void https://github.com/ruby/ruby/blob/trunk/cont.c#L1395 rb_fiber_start(void) { rb_thread_t * volatile th = GET_THREAD(); - rb_fiber_t *fib = th->ec->fiber; + rb_fiber_t *fib = th->ec->fiber_ptr; rb_proc_t *proc; enum ruby_tag_type state; @@ -1441,7 +1441,7 @@ static rb_fiber_t * https://github.com/ruby/ruby/blob/trunk/cont.c#L1441 root_fiber_alloc(rb_thread_t *th) { VALUE fibval = fiber_alloc(rb_cFiber); - rb_fiber_t *fib = th->ec->fiber; + rb_fiber_t *fib = th->ec->fiber_ptr; VM_ASSERT(DATA_PTR(fibval) == NULL); VM_ASSERT(fib->cont.type == ROOT_FIBER_CONTEXT); @@ -1466,7 +1466,7 @@ rb_threadptr_root_fiber_setup(rb_thread_ https://github.com/ruby/ruby/blob/trunk/cont.c#L1466 rb_fiber_t *fib = ruby_mimmalloc(sizeof(rb_fiber_t)); MEMZERO(fib, rb_fiber_t, 1); fib->cont.type = ROOT_FIBER_CONTEXT; - fib->cont.saved_ec.fiber = fib; + fib->cont.saved_ec.fiber_ptr = fib; fib->cont.saved_ec.thread_ptr = th; fiber_status_set(fib, FIBER_RESUMED); /* skip CREATED */ th->ec = &fib->cont.saved_ec; @@ -1486,9 +1486,9 @@ rb_threadptr_root_fiber_release(rb_threa https://github.com/ruby/ruby/blob/trunk/cont.c#L1486 /* ignore. A root fiber object will free th->ec */ } else { - VM_ASSERT(th->ec->fiber->cont.type == ROOT_FIBER_CONTEXT); - VM_ASSERT(th->ec->fiber->cont.self == 0); - fiber_free(th->ec->fiber); + VM_ASSERT(th->ec->fiber_ptr->cont.type == ROOT_FIBER_CONTEXT); + VM_ASSERT(th->ec->fiber_ptr->cont.self == 0); + fiber_free(th->ec->fiber_ptr); if (th->ec == ruby_current_execution_context_ptr) { ruby_current_execution_context_ptr = NULL; @@ -1501,10 +1501,10 @@ static inline rb_fiber_t* https://github.com/ruby/ruby/blob/trunk/cont.c#L1501 fiber_current(void) { rb_thread_t *th = GET_THREAD(); - if (th->ec->fiber->cont.self == 0) { + if (th->ec->fiber_ptr->cont.self == 0) { root_fiber_alloc(th); } - return th->ec->fiber; + return th->ec->fiber_ptr; } static inline rb_fiber_t* @@ -1541,8 +1541,8 @@ fiber_store(rb_fiber_t *next_fib, rb_thr https://github.com/ruby/ruby/blob/trunk/cont.c#L1541 { rb_fiber_t *fib; - if (th->ec->fiber != NULL) { - fib = th->ec->fiber; + if (th->ec->fiber_ptr != NULL) { + fib = th->ec->fiber_ptr; } else { /* create root fiber */ @@ -1589,14 +1589,14 @@ fiber_store(rb_fiber_t *next_fib, rb_thr https://github.com/ruby/ruby/blob/trunk/cont.c#L1589 terminated_machine_stack.size = 0; } #endif /* not _WIN32 */ - fib = th->ec->fiber; + fib = th->ec->fiber_ptr; if (fib->cont.argc == -1) rb_exc_raise(fib->cont.value); return fib->cont.value; #else /* FIBER_USE_NATIVE */ if (ruby_setjmp(fib->cont.jmpbuf)) { /* restored */ - fib = th->ec->fiber; + fib = th->ec->fiber_ptr; if (fib->cont.argc == -1) rb_exc_raise(fib->cont.value); if (next_fib->cont.value == Qundef) { cont_restore_0(&next_fib->cont, &next_fib->cont.value); @@ -1622,7 +1622,7 @@ fiber_switch(rb_fiber_t *fib, int argc, https://github.com/ruby/ruby/blob/trunk/cont.c#L1622 /* make sure the root_fiber object is available */ if (th->root_fiber == NULL) root_fiber_alloc(th); - if (th->ec->fiber == fib) { + if (th->ec->fiber_ptr == fib) { /* ignore fiber context switch * because destination fiber is same as current fiber */ @@ -1638,7 +1638,7 @@ fiber_switch(rb_fiber_t *fib, int argc, https://github.com/ruby/ruby/blob/trunk/cont.c#L1638 else if (FIBER_TERMINATED_P(fib)) { value = rb_exc_new2(rb_eFiberError, "dead fiber called"); - if (!FIBER_TERMINATED_P(th->ec->fiber)) { + if (!FIBER_TERMINATED_P(th->ec->fiber_ptr)) { rb_exc_raise(value); VM_UNREACHABLE(fiber_switch); } @@ -1652,7 +1652,7 @@ fiber_switch(rb_fiber_t *fib, int argc, https://github.com/ruby/ruby/blob/trunk/cont.c#L1652 cont->argc = -1; cont->value = value; #if FIBER_USE_NATIVE - fiber_setcontext(th->root_fiber, th->ec->fiber); + fiber_setcontext(th->root_fiber, th->ec->fiber_ptr); #else cont_restore_0(cont, &value); #endif @@ -1751,7 +1751,7 @@ rb_fiber_reset_root_local_storage(VALUE https://github.com/ruby/ruby/blob/trunk/cont.c#L1751 { rb_thread_t *th = rb_thread_ptr(thval); - if (th->root_fiber && th->root_fiber != th->ec->fiber) { + if (th->root_fiber && th->root_fiber != th->ec->fiber_ptr) { th->ec->local_storage = th->root_fiber->cont.saved_ec.local_storage; } } -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/