ruby-changes:56388
From: Nobuyoshi <ko1@a...>
Date: Mon, 8 Jul 2019 16:00:28 +0900 (JST)
Subject: [ruby-changes:56388] Nobuyoshi Nakada: a8c54932ba (master): Renamed fib to fiber
https://git.ruby-lang.org/ruby.git/commit/?id=a8c54932ba From a8c54932ba4ba002e7046d36af85f940212df9d1 Mon Sep 17 00:00:00 2001 From: Nobuyoshi Nakada <nobu@r...> Date: Mon, 8 Jul 2019 14:59:28 +0900 Subject: Renamed fib to fiber diff --git a/cont.c b/cont.c index 9b28ed1..b04a0b4 100644 --- a/cont.c +++ b/cont.c @@ -147,11 +147,11 @@ enum fiber_status { https://github.com/ruby/ruby/blob/trunk/cont.c#L147 FIBER_TERMINATED }; -#define FIBER_CREATED_P(fib) ((fib)->status == FIBER_CREATED) -#define FIBER_RESUMED_P(fib) ((fib)->status == FIBER_RESUMED) -#define FIBER_SUSPENDED_P(fib) ((fib)->status == FIBER_SUSPENDED) -#define FIBER_TERMINATED_P(fib) ((fib)->status == FIBER_TERMINATED) -#define FIBER_RUNNABLE_P(fib) (FIBER_CREATED_P(fib) || FIBER_SUSPENDED_P(fib)) +#define FIBER_CREATED_P(fiber) ((fiber)->status == FIBER_CREATED) +#define FIBER_RESUMED_P(fiber) ((fiber)->status == FIBER_RESUMED) +#define FIBER_SUSPENDED_P(fiber) ((fiber)->status == FIBER_SUSPENDED) +#define FIBER_TERMINATED_P(fiber) ((fiber)->status == FIBER_TERMINATED) +#define FIBER_RUNNABLE_P(fiber) (FIBER_CREATED_P(fiber) || FIBER_SUSPENDED_P(fiber)) #if FIBER_USE_NATIVE && !defined(FIBER_USE_COROUTINE) && !defined(_WIN32) static inline int @@ -190,7 +190,7 @@ struct rb_fiber_struct { https://github.com/ruby/ruby/blob/trunk/cont.c#L190 void *ss_sp; size_t ss_size; #elif defined(_WIN32) - void *fib_handle; + void *fiber_handle; #else #define FIBER_ALLOCATE_STACK ucontext_t context; @@ -229,17 +229,17 @@ fiber_status_name(enum fiber_status s) https://github.com/ruby/ruby/blob/trunk/cont.c#L229 } static void -fiber_verify(const rb_fiber_t *fib) +fiber_verify(const rb_fiber_t *fiber) { #if VM_CHECK_MODE > 0 - VM_ASSERT(fib->cont.saved_ec.fiber_ptr == fib); + VM_ASSERT(fiber->cont.saved_ec.fiber_ptr == fiber); - switch (fib->status) { + switch (fiber->status) { case FIBER_RESUMED: - VM_ASSERT(fib->cont.saved_ec.vm_stack != NULL); + VM_ASSERT(fiber->cont.saved_ec.vm_stack != NULL); break; case FIBER_SUSPENDED: - VM_ASSERT(fib->cont.saved_ec.vm_stack != NULL); + VM_ASSERT(fiber->cont.saved_ec.vm_stack != NULL); break; case FIBER_CREATED: case FIBER_TERMINATED: @@ -260,19 +260,19 @@ rb_ec_verify(const rb_execution_context_t *ec) https://github.com/ruby/ruby/blob/trunk/cont.c#L260 #endif static void -fiber_status_set(rb_fiber_t *fib, enum fiber_status s) +fiber_status_set(rb_fiber_t *fiber, enum fiber_status s) { - if (0) fprintf(stderr, "fib: %p, status: %s -> %s\n", (void *)fib, fiber_status_name(fib->status), fiber_status_name(s)); - VM_ASSERT(!FIBER_TERMINATED_P(fib)); - VM_ASSERT(fib->status != s); - fiber_verify(fib); - fib->status = s; + if (0) fprintf(stderr, "fiber: %p, status: %s -> %s\n", (void *)fiber, fiber_status_name(fiber->status), fiber_status_name(s)); + VM_ASSERT(!FIBER_TERMINATED_P(fiber)); + VM_ASSERT(fiber->status != s); + fiber_verify(fiber); + fiber->status = s; } static inline void -ec_switch(rb_thread_t *th, rb_fiber_t *fib) +ec_switch(rb_thread_t *th, rb_fiber_t *fiber) { - rb_execution_context_t *ec = &fib->cont.saved_ec; + rb_execution_context_t *ec = &fiber->cont.saved_ec; ruby_current_execution_context_ptr = th->ec = ec; @@ -305,12 +305,12 @@ cont_ptr(VALUE obj) https://github.com/ruby/ruby/blob/trunk/cont.c#L305 static rb_fiber_t * fiber_ptr(VALUE obj) { - rb_fiber_t *fib; + rb_fiber_t *fiber; - TypedData_Get_Struct(obj, rb_fiber_t, &fiber_data_type, fib); - if (!fib) rb_raise(rb_eFiberError, "uninitialized fiber"); + TypedData_Get_Struct(obj, rb_fiber_t, &fiber_data_type, fiber); + if (!fiber) rb_raise(rb_eFiberError, "uninitialized fiber"); - return fib; + return fiber; } NOINLINE(static VALUE cont_capture(volatile int *volatile stat)); @@ -363,9 +363,9 @@ cont_mark(void *ptr) https://github.com/ruby/ruby/blob/trunk/cont.c#L363 } else { /* fiber */ - const rb_fiber_t *fib = (rb_fiber_t*)cont; + const rb_fiber_t *fiber = (rb_fiber_t*)cont; - if (!FIBER_TERMINATED_P(fib)) { + if (!FIBER_TERMINATED_P(fiber)) { rb_gc_mark_locations(cont->machine.stack, cont->machine.stack + cont->machine.stack_size); } @@ -376,9 +376,9 @@ cont_mark(void *ptr) https://github.com/ruby/ruby/blob/trunk/cont.c#L376 } static int -fiber_is_root_p(const rb_fiber_t *fib) +fiber_is_root_p(const rb_fiber_t *fiber) { - return fib == fib->cont.saved_ec.thread_ptr->root_fiber; + return fiber == fiber->cont.saved_ec.thread_ptr->root_fiber; } static void @@ -400,31 +400,31 @@ cont_free(void *ptr) https://github.com/ruby/ruby/blob/trunk/cont.c#L400 } else { /* fiber */ - rb_fiber_t *fib = (rb_fiber_t*)cont; + rb_fiber_t *fiber = (rb_fiber_t*)cont; #if defined(FIBER_USE_COROUTINE) - coroutine_destroy(&fib->context); - if (fib->ss_sp != NULL) { - if (fiber_is_root_p(fib)) { + coroutine_destroy(&fiber->context); + if (fiber->ss_sp != NULL) { + if (fiber_is_root_p(fiber)) { rb_bug("Illegal root fiber parameter"); } #ifdef _WIN32 - VirtualFree((void*)fib->ss_sp, 0, MEM_RELEASE); + VirtualFree((void*)fiber->ss_sp, 0, MEM_RELEASE); #else - munmap((void*)fib->ss_sp, fib->ss_size); + munmap((void*)fiber->ss_sp, fiber->ss_size); #endif - fib->ss_sp = NULL; + fiber->ss_sp = NULL; } #elif defined(_WIN32) - if (!fiber_is_root_p(fib)) { + if (!fiber_is_root_p(fiber)) { /* don't delete root fiber handle */ - if (fib->fib_handle) { - DeleteFiber(fib->fib_handle); + if (fiber->fiber_handle) { + DeleteFiber(fiber->fiber_handle); } } #else /* not WIN32 */ - /* fib->ss_sp == NULL is possible for root fiber */ - if (fib->ss_sp != NULL) { - munmap((void*)fib->ss_sp, fib->ss_size); + /* fiber->ss_sp == NULL is possible for root fiber */ + if (fiber->ss_sp != NULL) { + munmap((void*)fiber->ss_sp, fiber->ss_size); } #endif } @@ -466,90 +466,90 @@ cont_memsize(const void *ptr) https://github.com/ruby/ruby/blob/trunk/cont.c#L466 } void -rb_fiber_update_self(rb_fiber_t *fib) +rb_fiber_update_self(rb_fiber_t *fiber) { - if (fib->cont.self) { - fib->cont.self = rb_gc_location(fib->cont.self); + if (fiber->cont.self) { + fiber->cont.self = rb_gc_location(fiber->cont.self); } else { - rb_execution_context_update(&fib->cont.saved_ec); + rb_execution_context_update(&fiber->cont.saved_ec); } } void -rb_fiber_mark_self(const rb_fiber_t *fib) +rb_fiber_mark_self(const rb_fiber_t *fiber) { - if (fib->cont.self) { - rb_gc_mark_no_pin(fib->cont.self); + if (fiber->cont.self) { + rb_gc_mark_no_pin(fiber->cont.self); } else { - rb_execution_context_mark(&fib->cont.saved_ec); + rb_execution_context_mark(&fiber->cont.saved_ec); } } static void fiber_compact(void *ptr) { - rb_fiber_t *fib = ptr; - fib->first_proc = rb_gc_location(fib->first_proc); + rb_fiber_t *fiber = ptr; + fiber->first_proc = rb_gc_location(fiber->first_proc); - if (fib->prev) rb_fiber_update_self(fib->prev); + if (fiber->prev) rb_fiber_update_self(fiber->prev); - cont_compact(&fib->cont); - fiber_verify(fib); + cont_compact(&fiber->cont); + fiber_verify(fiber); } static void fiber_mark(void *ptr) { - rb_fiber_t *fib = ptr; + rb_fiber_t *fiber = ptr; RUBY_MARK_ENTER("cont"); - fiber_verify(fib); - rb_gc_mark_no_pin(fib->first_proc); - if (fib->prev) rb_fiber_mark_self(fib->prev); + fiber_verify(fiber); + rb_gc_mark_no_pin(fiber->first_proc); + if (fiber->prev) rb_fiber_mark_self(fiber->prev); #if !FIBER_USE_NATIVE - if (fib->status == FIBER_TERMINATED) { + if (fiber->status == FIBER_TERMINATED) { /* FIBER_TERMINATED fiber should not mark machine stack */ - if (fib->cont.saved_ec.machine.stack_end != NULL) { - fib->cont.saved_ec.machine.stack_end = NULL; + if (fiber->cont.saved_ec.machine.stack_end != NULL) { + fiber->cont.saved_ec.machine.stack_end = NULL; } } #endif - cont_mark(&fib->cont); + cont_mark(&fiber->cont); RUBY_MARK_LEAVE("cont"); } static void fiber_free(void *ptr) { - rb_fiber_t *fib = ptr; + rb_fiber_t *fiber = ptr; RUBY_FREE_ENTER("fiber"); - if (fib->cont.saved_ec.local_storage) { - st_free_table(fib->cont.saved_ec.local_storage); + if (fiber->cont.saved_ec.local_storage) { + st_free_table(fiber->cont.saved_ec.local_storage); } - cont_free(&fib->cont); + cont_free(&fiber->cont); RUBY_FREE_LEAVE("fiber"); } static size_t fiber_memsize(const void *ptr) { - const rb_fiber_t *fib = ptr; - size_t size = sizeof(*fib); - const rb_execution_context_t *saved_ec = &fib->cont.saved_ec; + const rb_fiber_t *fiber = ptr; + size_t size = sizeof(*fiber); + const rb_execution_context_t *saved_ec = &fiber->cont.saved_ec; const rb_thread_t *th = rb_ec_thread_ptr(saved_ec); /* * vm.c::thread_memsize already counts th->ec->local_storage */ - if (saved_ec->local_storage && fib != th->root_fiber) { + if (saved_ec->local_storage && fiber != th->root_fiber) { size += st_memsize(saved_ec->local_storage); } - size += cont_memsize(&fib->cont); + size += cont_memsize(&fiber->cont); return size; } @@ -736,10 +736,10 @@ cont_capture(volatile int *volatile stat) https://github.com/ruby/ruby/blob/trunk/cont.c#L736 COMPILER_WARNING_POP static inline void -fiber_restore_thread(rb_thread_t *th, rb_fiber_t *fib) +fiber_restore_thread(rb_thread_t *th, rb_fiber_t *fiber) { - ec_switch(th, fib); - VM_ASSERT(th->ec->fiber_ptr == fib); + ec_switch(th, fiber); + VM_ASSERT(th->ec->fiber_ptr == fiber); } static inline void @@ -751,17 +751,17 @@ cont_restore_thread(rb_context_t *cont) https://github.com/ruby/ruby/blob/trunk/co (... truncated) -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/