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

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.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60670 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
ko1 2017-11-06 05:41:48 +00:00
parent 54e58c947b
commit e5e735549d
4 changed files with 34 additions and 39 deletions

48
cont.c
View file

@ -192,7 +192,7 @@ static void
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 *fib)
{
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
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)
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, VALUE contval)
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)
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
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 *
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_t *th)
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_thread_t *th)
/* 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*
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_thread_t *th)
{
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_thread_t *th)
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, const VALUE *argv, int is_resume)
/* 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, const VALUE *argv, int is_resume)
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, const VALUE *argv, int is_resume)
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 thval)
{
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;
}
}

View file

@ -696,7 +696,7 @@ thread_start_func_2(rb_thread_t *th, VALUE *stack_start, VALUE *register_stack_s
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.*/

2
vm.c
View file

@ -2393,7 +2393,7 @@ rb_thread_mark(void *ptr)
{
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);

View file

@ -745,8 +745,8 @@ typedef struct rb_execution_context_struct {
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_struct {
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;
/* trace information */
struct rb_trace_arg_struct *trace_arg;
/* for rb_iterate */
VALUE passed_block_handler;
/* for bmethod */
const rb_callable_method_entry_t *passed_bmethod_me;
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 {