ruby-changes:47447
From: ko1 <ko1@a...>
Date: Thu, 10 Aug 2017 13:55:25 +0900 (JST)
Subject: [ruby-changes:47447] ko1:r59563 (trunk): rename rb_execution_context_t::stack(_size) to vm_stack(_size).
ko1 2017-08-10 13:55:12 +0900 (Thu, 10 Aug 2017) New Revision: 59563 https://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=59563 Log: rename rb_execution_context_t::stack(_size) to vm_stack(_size). * vm_core.h: Ruby processes run with two stacks, a machine stack and a VM stack. To make it clear, this fix renames rb_execution_context_t::stack(_size) to vm_stack(_size). Modified files: trunk/cont.c trunk/eval.c trunk/thread.c trunk/vm.c trunk/vm_core.h trunk/vm_dump.c trunk/vm_exec.h trunk/vm_insnhelper.c trunk/vm_insnhelper.h Index: thread.c =================================================================== --- thread.c (revision 59562) +++ thread.c (revision 59563) @@ -694,8 +694,8 @@ thread_start_func_2(rb_thread_t *th, VAL https://github.com/ruby/ruby/blob/trunk/thread.c#L694 rb_threadptr_unlock_all_locking_mutexes(th); rb_check_deadlock(th->vm); - rb_thread_recycle_stack_release(th->ec.stack); - th->ec.stack = NULL; + rb_thread_recycle_stack_release(th->ec.vm_stack); + th->ec.vm_stack = NULL; } native_mutex_lock(&th->vm->thread_destruct_lock); /* make sure vm->running_thread never point me after this point.*/ Index: vm_insnhelper.c =================================================================== --- vm_insnhelper.c (revision 59562) +++ vm_insnhelper.c (revision 59563) @@ -1516,8 +1516,8 @@ vm_base_ptr(const rb_control_frame_t *cf https://github.com/ruby/ruby/blob/trunk/vm_insnhelper.c#L1516 #if VM_DEBUG_BP_CHECK if (bp != cfp->bp_check) { fprintf(stderr, "bp_check: %ld, bp: %ld\n", - (long)(cfp->bp_check - GET_THREAD()->ec.stack), - (long)(bp - GET_THREAD()->ec.stack)); + (long)(cfp->bp_check - GET_THREAD()->ec.vm_stack), + (long)(bp - GET_THREAD()->ec.vm_stack)); rb_bug("vm_base_ptr: unreachable"); } #endif Index: vm_insnhelper.h =================================================================== --- vm_insnhelper.h (revision 59562) +++ vm_insnhelper.h (revision 59563) @@ -95,7 +95,7 @@ enum vm_regan_acttype { https://github.com/ruby/ruby/blob/trunk/vm_insnhelper.h#L95 #define SET_SV(x) (*GET_SP() = (x)) /* set current stack value as x */ -#define GET_SP_COUNT() (VM_REG_SP - th->ec.stack) +#define GET_SP_COUNT() (VM_REG_SP - th->ec.vm_stack) /* instruction sequence C struct */ #define GET_ISEQ() (GET_CFP()->iseq) Index: vm_core.h =================================================================== --- vm_core.h (revision 59562) +++ vm_core.h (revision 59563) @@ -737,8 +737,8 @@ typedef struct rb_fiber_struct rb_fiber_ https://github.com/ruby/ruby/blob/trunk/vm_core.h#L737 typedef struct rb_thread_context_struct { /* execution information */ - VALUE *stack; /* must free, must mark */ - size_t stack_size; /* size in word (byte size / sizeof(VALUE)) */ + VALUE *vm_stack; /* must free, must mark */ + size_t vm_stack_size; /* size in word (byte size / sizeof(VALUE)) */ rb_control_frame_t *cfp; struct rb_vm_tag *tag; @@ -1235,7 +1235,7 @@ VALUE rb_vm_frame_block_handler(const rb https://github.com/ruby/ruby/blob/trunk/vm_core.h#L1235 #define RUBY_VM_PREVIOUS_CONTROL_FRAME(cfp) ((cfp)+1) #define RUBY_VM_NEXT_CONTROL_FRAME(cfp) ((cfp)-1) #define RUBY_VM_END_CONTROL_FRAME(th) \ - ((rb_control_frame_t *)((th)->ec.stack + (th)->ec.stack_size)) + ((rb_control_frame_t *)((th)->ec.vm_stack + (th)->ec.vm_stack_size)) #define RUBY_VM_VALID_CONTROL_FRAME_P(cfp, ecfp) \ ((void *)(ecfp) > (void *)(cfp)) #define RUBY_VM_CONTROL_FRAME_STACK_OVERFLOW_P(th, cfp) \ Index: eval.c =================================================================== --- eval.c (revision 59562) +++ eval.c (revision 59563) @@ -1127,7 +1127,7 @@ previous_frame(rb_thread_t *th) https://github.com/ruby/ruby/blob/trunk/eval.c#L1127 { rb_control_frame_t *prev_cfp = RUBY_VM_PREVIOUS_CONTROL_FRAME(th->ec.cfp); /* check if prev_cfp can be accessible */ - if ((void *)(th->ec.stack + th->ec.stack_size) == (void *)(prev_cfp)) { + if ((void *)(th->ec.vm_stack + th->ec.vm_stack_size) == (void *)(prev_cfp)) { return 0; } return prev_cfp; Index: cont.c =================================================================== --- cont.c (revision 59562) +++ cont.c (revision 59563) @@ -87,8 +87,8 @@ typedef struct rb_context_struct { https://github.com/ruby/ruby/blob/trunk/cont.c#L87 VALUE value; VALUE *vm_stack; #ifdef CAPTURE_JUST_VALID_VM_STACK - size_t vm_stack_slen; /* length of stack (head of th->ec.stack) */ - size_t vm_stack_clen; /* length of control frames (tail of th->ec.stack) */ + size_t vm_stack_slen; /* length of stack (head of th->ec.svm_tack) */ + size_t vm_stack_clen; /* length of control frames (tail of th->ec.vm_stack) */ #endif struct { VALUE *stack; @@ -265,7 +265,7 @@ cont_free(void *ptr) https://github.com/ruby/ruby/blob/trunk/cont.c#L265 rb_context_t *cont = ptr; RUBY_FREE_ENTER("cont"); - RUBY_FREE_UNLESS_NULL(cont->saved_thread.ec.stack); + RUBY_FREE_UNLESS_NULL(cont->saved_thread.ec.vm_stack); #if FIBER_USE_NATIVE if (cont->type == CONTINUATION_CONTEXT) { /* cont */ @@ -324,7 +324,7 @@ cont_memsize(const void *ptr) https://github.com/ruby/ruby/blob/trunk/cont.c#L324 #ifdef CAPTURE_JUST_VALID_VM_STACK size_t n = (cont->vm_stack_slen + cont->vm_stack_clen); #else - size_t n = cont->saved_thread.ec.stack_size; + size_t n = cont->saved_thread.ec.vm_stack_size; #endif size += n * sizeof(*cont->vm_stack); } @@ -346,10 +346,10 @@ fiber_verify(const rb_fiber_t *fib) https://github.com/ruby/ruby/blob/trunk/cont.c#L346 #if VM_CHECK_MODE > 0 switch (fib->status) { case FIBER_RESUMED: - VM_ASSERT(fib->cont.saved_thread.ec.stack == NULL); + VM_ASSERT(fib->cont.saved_thread.ec.vm_stack == NULL); break; case FIBER_SUSPENDED: - VM_ASSERT(fib->cont.saved_thread.ec.stack != NULL); + VM_ASSERT(fib->cont.saved_thread.ec.vm_stack != NULL); break; case FIBER_CREATED: case FIBER_TERMINATED: @@ -531,17 +531,17 @@ cont_capture(volatile int *volatile stat https://github.com/ruby/ruby/blob/trunk/cont.c#L531 contval = cont->self; #ifdef CAPTURE_JUST_VALID_VM_STACK - cont->vm_stack_slen = ec->cfp->sp - ec->stack; - cont->vm_stack_clen = ec->stack + ec->stack_size - (VALUE*)ec->cfp; + cont->vm_stack_slen = ec->cfp->sp - ec->vm_stack; + cont->vm_stack_clen = ec->vm_stack + ec->vm_stack_size - (VALUE*)ec->cfp; cont->vm_stack = ALLOC_N(VALUE, cont->vm_stack_slen + cont->vm_stack_clen); - MEMCPY(cont->vm_stack, ec->stack, VALUE, cont->vm_stack_slen); + MEMCPY(cont->vm_stack, ec->vm_stack, VALUE, cont->vm_stack_slen); MEMCPY(cont->vm_stack + cont->vm_stack_slen, (VALUE*)ec->cfp, VALUE, cont->vm_stack_clen); #else - cont->vm_stack = ALLOC_N(VALUE, ec->stack_size); - MEMCPY(cont->vm_stack, ec->stack, VALUE, ec->stack_size); + cont->vm_stack = ALLOC_N(VALUE, ec->vm_stack_size); + MEMCPY(cont->vm_stack, ec->vm_stack, VALUE, ec->vm_stack_size); #endif - cont->saved_thread.ec.stack = NULL; + cont->saved_thread.ec.vm_stack = NULL; cont_save_machine_stack(th, cont); @@ -590,16 +590,16 @@ cont_restore_thread(rb_context_t *cont) https://github.com/ruby/ruby/blob/trunk/cont.c#L590 th->fiber = sth->fiber; fib = th->fiber ? th->fiber : th->root_fiber; - if (fib && fib->cont.saved_thread.ec.stack) { - th->ec.stack_size = fib->cont.saved_thread.ec.stack_size; - th->ec.stack = fib->cont.saved_thread.ec.stack; + if (fib && fib->cont.saved_thread.ec.vm_stack) { + th->ec.vm_stack_size = fib->cont.saved_thread.ec.vm_stack_size; + th->ec.vm_stack = fib->cont.saved_thread.ec.vm_stack; } #ifdef CAPTURE_JUST_VALID_VM_STACK - MEMCPY(th->ec.stack, cont->vm_stack, VALUE, cont->vm_stack_slen); - MEMCPY(th->ec.stack + sth->ec.stack_size - cont->vm_stack_clen, + MEMCPY(th->ec.vm_stack, cont->vm_stack, VALUE, cont->vm_stack_slen); + MEMCPY(th->ec.vm_stack + sth->ec.vm_stack_size - cont->vm_stack_clen, cont->vm_stack + cont->vm_stack_slen, VALUE, cont->vm_stack_clen); #else - MEMCPY(th->ec.stack, cont->vm_stack, VALUE, sth->ec.stack_size); + MEMCPY(th->ec.vm_stack, cont->vm_stack, VALUE, sth->ec.vm_stack_size); #endif /* other members of ec */ @@ -617,11 +617,11 @@ cont_restore_thread(rb_context_t *cont) https://github.com/ruby/ruby/blob/trunk/cont.c#L617 else { /* fiber */ th->ec = sth->ec; - sth->ec.stack = NULL; + sth->ec.vm_stack = NULL; th->fiber = (rb_fiber_t*)cont; } - VM_ASSERT(th->ec.stack != NULL); + VM_ASSERT(th->ec.vm_stack != NULL); VM_ASSERT(sth->status == THREAD_RUNNABLE); } @@ -1258,12 +1258,12 @@ fiber_init(VALUE fibval, VALUE proc) https://github.com/ruby/ruby/blob/trunk/cont.c#L1258 /* initialize cont */ cont->vm_stack = 0; - th->ec.stack = NULL; - th->ec.stack_size = 0; + th->ec.vm_stack = NULL; + th->ec.vm_stack_size = 0; - th->ec.stack_size = cth->vm->default_params.fiber_vm_stack_size / sizeof(VALUE); - th->ec.stack = ALLOC_N(VALUE, th->ec.stack_size); - th->ec.cfp = (void *)(th->ec.stack + th->ec.stack_size); + th->ec.vm_stack_size = cth->vm->default_params.fiber_vm_stack_size / sizeof(VALUE); + th->ec.vm_stack = ALLOC_N(VALUE, th->ec.vm_stack_size); + th->ec.cfp = (void *)(th->ec.vm_stack + th->ec.vm_stack_size); rb_vm_push_frame(th, NULL, @@ -1272,7 +1272,7 @@ fiber_init(VALUE fibval, VALUE proc) https://github.com/ruby/ruby/blob/trunk/cont.c#L1272 VM_BLOCK_HANDLER_NONE, 0, /* specval */ NULL, /* pc */ - th->ec.stack, /* sp */ + th->ec.vm_stack, /* sp */ 0, /* local_size */ 0); @@ -1374,7 +1374,7 @@ fiber_current(void) https://github.com/ruby/ruby/blob/trunk/cont.c#L1374 if (th->fiber == 0) { rb_fiber_t *fib = root_fiber_alloc(th); /* Running thread object has stack management responsibility */ - fib->cont.saved_thread.ec.stack = NULL; + fib->cont.saved_thread.ec.vm_stack = NULL; } return th->fiber; } Index: vm_exec.h =================================================================== --- vm_exec.h (revision 59562) +++ vm_exec.h (revision 59563) @@ -157,7 +157,7 @@ default: \ https://github.com/ruby/ruby/blob/trunk/vm_exec.h#L157 #endif -#define VM_SP_CNT(th, sp) ((sp) - (th)->ec.stack) +#define VM_SP_CNT(th, sp) ((sp) - (th)->ec.vm_stack) #if OPT_CALL_THREADED_CODE #define THROW_EXCEPTION(exc) do { \ Index: vm_dump.c =================================================================== --- vm_dump.c (revision 59562) +++ vm_dump.c (revision 59563) @@ -22,14 +22,14 @@ https://github.com/ruby/ruby/blob/trunk/vm_dump.c#L22 #define MAX_POSBUF 128 #define VM_CFP_CNT(th, cfp) \ - ((rb_control_frame_t *)((th)->ec.stack + (th)->ec.stack_size) - \ + ((rb_control_frame_t *)((th)->ec.vm_stack + (th)->ec.vm_stack_size) - \ (rb_control_frame_t *)(cfp)) static void control_frame_dump(rb_thread_t *th, rb_control_frame_t *cfp) { ptrdiff_t pc = -1; - ptrdiff_t ep = cfp->ep - th->ec.stack; + ptrdiff_t ep = cfp->ep - th->ec.vm_stack; char ep_in_heap = ' '; char posbuf[MAX_POSBUF+1]; int line = 0; @@ -39,7 +39,7 @@ control_frame_dump(rb_thread_t *th, rb_c https://github.com/ruby/ruby/blob/trunk/vm_dump.c#L39 const rb_callable_method_entry_t *me; - if (ep < 0 || (size_t)ep > th->ec.stack_size) { + if (ep < 0 || (size_t)ep > th->ec.vm_stack_size) { ep = (ptrdiff_t)cfp->ep; ep_in_heap = 'p'; } @@ -112,14 +112,14 @@ control_frame_dump(rb_thread_t *th, rb_c https://github.com/ruby/ruby/blob/trunk/vm_dump.c#L112 } fprintf(stderr, "c:%04"PRIdPTRDIFF" ", - ((rb_control_frame_t *)(th->ec.stack + th->ec.stack_size) - cfp)); + ((rb_control_frame_t *)(th->ec.vm_stack + th->ec.vm_stack_size) - cfp)); if (pc == -1) { fprintf(stderr, "p:---- "); } else { fprintf(stderr, "p:%04"PRIdPTRDIFF" ", pc); } - fprintf(stderr, "s:%04"PRIdPTRDIFF" ", cfp->sp - th->ec.stack); + fprintf(stderr, "s:%04"PRIdPTRDIFF" ", cfp->sp - th->ec.vm_stack); fprintf(stderr, ep_in_heap == ' ' ? "e:%06"PRIdPTRDIFF" " : "E:%06"PRIxPTRDIFF" ", ep % 10000); fprintf(stderr, "%-6s", magic); if (line) { @@ -145,12 +145,12 @@ rb_vmdebug_stack_dump_raw(rb_thread_t *t https://github.com/ruby/ruby/blob/trunk/vm_dump.c#L145 VALUE *p, *st, *t; fprintf(stderr, "-- stack frame ------------\n"); - for (p = st = th->ec.stack; p < sp; p++) { + for (p = st = th->ec.vm_stack; p < sp; p++) { fprintf(stderr, "%04ld (%p): %08"PRIxVALUE, (long)(p - st), p, *p); t = (VALUE *)*p; - if (th->ec.stack <= t && t < sp) { - fprintf(stderr, " (= %ld)", (long)((VALUE *)GC_GUARDED_PTR_REF(t) - th->ec.stack)); + if (th->ec.vm_stack <= t && t < sp) { + fprintf(stderr, " (= %ld)", (long)((VALUE *)GC_GUARDED_PTR_REF(t) - th->ec.vm_stack)); } if (p == ep) @@ -162,7 +162,7 @@ rb_vmdebug_stack_dump_raw(rb_thread_t *t https://github.com/ruby/ruby/blob/trunk/vm_dump.c#L162 fprintf(stderr, "-- Control frame information " "-----------------------------------------------\n"); - while ((void *)cfp < (void *)(th->ec.stack + th->ec.stack_size)) { + while ((void *)cfp < (void *)(th->ec.vm_stack + th->ec.vm_stack_size)) { control_frame_dump(th, cfp); cfp++; } @@ -285,7 +285,7 @@ vm_stack_dump_each(rb_thread_t *th, rb_c https://github.com/ruby/ruby/blob/trunk/vm_dump.c#L285 break; } fprintf(stderr, " stack %2d: %8s (%"PRIdPTRDIFF")\n", i, StringValueCStr(rstr), - (ptr - th->ec.stack)); + (ptr - th->ec.vm_stack)); } } else if (VM_FRAME_FINISHED_P(cfp)) { @@ -307,20 +307,20 @@ rb_vmdebug_debug_print_register(rb_threa https://github.com/ruby/ruby/blob/trunk/vm_dump.c#L307 { rb_control_frame_t *cfp = th->ec.cfp; ptrdiff_t pc = -1; - ptrdiff_t ep = cfp->ep - th->ec.stack; + ptrdiff_t ep = cfp->ep - th->ec.vm_stack; ptrdiff_t cfpi; if (VM_FRAME_RUBYFRAME_P(cfp)) { pc = cfp->pc - cfp->iseq->body->iseq_encoded; } - if (ep < 0 || (size_t)ep > th->ec.stack_size) { + if (ep < 0 || (size_t)ep > th->ec.vm_stack_size) { ep = -1; } - cfpi = ((rb_control_frame_t *)(th->ec.stack + th->ec.stack_size)) - cfp; + cfpi = ((rb_control_frame_t *)(th->ec.vm_stack + th->ec.vm_stack_size)) - cfp; fprintf(stderr, " [PC] %04"PRIdPTRDIFF", [SP] %04"PRIdPTRDIFF", [EP] %04"PRIdPTRDIFF", [CFP] %04"PRIdPTRDIFF"\n", - pc, (cfp->sp - th->ec.stack), ep, cfpi); + pc, (cfp->sp - th->ec.vm_stack), ep, cfpi); } void @@ -342,7 +342,7 @@ rb_vmdebug_debug_print_pre(rb_thread_t * https://github.com/ruby/ruby/blob/trunk/vm_dump.c#L342 printf(" "); } printf("| "); - if(0)printf("[%03ld] ", (long)(cfp->sp - th->ec.stack)); + if(0)printf("[%03ld] ", (long)(cfp->sp - th->ec.vm_stack)); /* printf("%3"PRIdPTRDIFF" ", VM_CFP_CNT(th, cfp)); */ if (pc >= 0) { Index: vm.c =================================================================== --- vm.c (revision 59562) +++ vm.c (revision 59563) @@ -88,8 +88,8 @@ rb_vm_frame_block_handler(const rb_contr https://github.com/ruby/ruby/blob/trunk/vm.c#L88 static int VM_CFP_IN_HEAP_P(const rb_thread_t *th, const rb_control_frame_t *cfp) { - const VALUE *start = th->ec.stack; - const VALUE *end = (VALUE *)th->ec.stack + th->ec.stack_size; + const VALUE *start = th->ec.vm_stack; + const VALUE *end = (VALUE *)th->ec.vm_stack + th->ec.vm_stack_size; VM_ASSERT(start != NULL); if (start <= (VALUE *)cfp && (VALUE *)cfp < end) { @@ -103,7 +103,7 @@ VM_CFP_IN_HEAP_P(const rb_thread_t *th, https://github.com/ruby/ruby/blob/trunk/vm.c#L103 static int VM_EP_IN_HEAP_P(const rb_thread_t *th, const VALUE *ep) { - const VALUE *start = th->ec.stack; + const VALUE *start = th->ec.vm_stack; const VALUE *end = (VALUE *)th->ec.cfp; VM_ASSERT(start != NULL); @@ -2370,11 +2370,11 @@ rb_thread_mark(void *ptr) https://github.com/ruby/ruby/blob/trunk/vm.c#L2370 RUBY_MARK_ENTER("thread"); /* mark VM stack */ - if (th->ec.stack) { - VALUE *p = th->ec.stack; + if (th->ec.vm_stack) { + VALUE *p = th->ec.vm_stack; VALUE *sp = th->ec.cfp->sp; rb_control_frame_t *cfp = th->ec.cfp; - rb_control_frame_t *limit_cfp = (void *)(th->ec.stack + th->ec.stack_size); + rb_control_frame_t *limit_cfp = (void *)(th->ec.vm_stack + th->ec.vm_stack_size); rb_gc_mark_values((long)(sp - p), p); @@ -2435,9 +2435,9 @@ thread_free(void *ptr) https://github.com/ruby/ruby/blob/trunk/vm.c#L2435 rb_thread_t *th = ptr; RUBY_FREE_ENTER("thread"); - if (th->ec.stack != NULL) { - rb_thread_recycle_stack_release(th->ec.stack); - th->ec.stack = NULL; + if (th->ec.vm_stack != NULL) { + rb_thread_recycle_stack_release(th->ec.vm_stack); + th->ec.vm_stack = NULL; } if (th->locking_mutex != Qfalse) { @@ -2475,7 +2475,7 @@ thread_memsize(const void *ptr) https://github.com/ruby/ruby/blob/trunk/vm.c#L2475 size_t size = sizeof(rb_thread_t); if (!th->root_fiber) { - size += th->ec.stack_size * sizeof(VALUE); + size += th->ec.vm_stack_size * sizeof(VALUE); } if (th->ec.local_storage) { size += st_memsize(th->ec.local_storage); @@ -2525,18 +2525,18 @@ th_init(rb_thread_t *th, VALUE self) https://github.com/ruby/ruby/blob/trunk/vm.c#L2525 /* altstack of main thread is reallocated in another place */ th->altstack = malloc(rb_sigaltstack_size()); #endif - /* th->ec.stack_size is word number. + /* th->ec.vm_stack_size is word number. * th->vm->default_params.thread_vm_stack_size is byte size. */ - th->ec.stack_size = th->vm->default_params.thread_vm_stack_size / sizeof(VALUE); - th->ec.stack = thread_recycle_stack(th->ec.stack_size); + th->ec.vm_stack_size = th->vm->default_params.thread_vm_stack_size / sizeof(VALUE); + th->ec.vm_stack = thread_recycle_stack(th->ec.vm_stack_size); - th->ec.cfp = (void *)(th->ec.stack + th->ec.stack_size); + th->ec.cfp = (void *)(th->ec.vm_stack + th->ec.vm_stack_size); vm_push_frame(th, 0 /* dummy iseq */, VM_FRAME_MAGIC_DUMMY | VM_ENV_FLAG_LOCAL | VM_FRAME_FLAG_FINISH | VM_FRAME_FLAG_CFRAME /* dummy frame */, Qnil /* dummy self */, VM_BLOCK_HANDLER_NONE /* dummy block ptr */, 0 /* dummy cref/me */, - 0 /* dummy pc */, th->ec.stack, 0, 0); + 0 /* dummy pc */, th->ec.vm_stack, 0, 0); th->status = THREAD_RUNNABLE; th->last_status = Qnil; @@ -3102,7 +3102,7 @@ void https://github.com/ruby/ruby/blob/trunk/vm.c#L3102 rb_vm_set_progname(VALUE filename) { rb_thread_t *th = GET_VM()->main_thread; - rb_control_frame_t *cfp = (void *)(th->ec.stack + th->ec.stack_size); + rb_control_frame_t *cfp = (void *)(th->ec.vm_stack + th->ec.vm_stack_size); --cfp; rb_iseq_pathobj_set(cfp->iseq, rb_str_dup(filename), rb_iseq_realpath(cfp->iseq)); -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/