aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorko1 <ko1@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2017-08-10 04:55:12 +0000
committerko1 <ko1@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2017-08-10 04:55:12 +0000
commitb4933f2a66baecf8abe4ecd4020ee7d042c1eea4 (patch)
tree2f9f2f81a57cb986b724d87959260d27de12da54
parent6432c915543db226c276533e21a5c7ef591cbb9a (diff)
downloadruby-b4933f2a66baecf8abe4ecd4020ee7d042c1eea4.tar.gz
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). git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@59563 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r--cont.c54
-rw-r--r--eval.c2
-rw-r--r--thread.c4
-rw-r--r--vm.c32
-rw-r--r--vm_core.h6
-rw-r--r--vm_dump.c30
-rw-r--r--vm_exec.h2
-rw-r--r--vm_insnhelper.c4
-rw-r--r--vm_insnhelper.h2
9 files changed, 68 insertions, 68 deletions
diff --git a/cont.c b/cont.c
index 68ad545966..19b15852ad 100644
--- a/cont.c
+++ b/cont.c
@@ -87,8 +87,8 @@ typedef struct rb_context_struct {
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)
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)
#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)
#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)
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)
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)
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)
/* 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)
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)
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;
}
diff --git a/eval.c b/eval.c
index 6b31bab995..2b6f7849fd 100644
--- a/eval.c
+++ b/eval.c
@@ -1127,7 +1127,7 @@ previous_frame(rb_thread_t *th)
{
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;
diff --git a/thread.c b/thread.c
index c994710920..ea5172129a 100644
--- a/thread.c
+++ b/thread.c
@@ -694,8 +694,8 @@ 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_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.*/
diff --git a/vm.c b/vm.c
index bc944e5085..0d942a9bfb 100644
--- a/vm.c
+++ b/vm.c
@@ -88,8 +88,8 @@ rb_vm_frame_block_handler(const rb_control_frame_t *cfp)
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, const rb_control_frame_t *cfp)
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)
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)
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)
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)
/* 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
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));
diff --git a/vm_core.h b/vm_core.h
index 809f7eef58..f7bd4d6b1e 100644
--- a/vm_core.h
+++ b/vm_core.h
@@ -737,8 +737,8 @@ typedef struct rb_fiber_struct rb_fiber_t;
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_control_frame_t *cfp);
#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) \
diff --git a/vm_dump.c b/vm_dump.c
index dbd9c6bb89..37028a292d 100644
--- a/vm_dump.c
+++ b/vm_dump.c
@@ -22,14 +22,14 @@
#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_control_frame_t *cfp)
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_control_frame_t *cfp)
}
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 *th, rb_control_frame_t *cfp)
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 *th, rb_control_frame_t *cfp)
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_control_frame_t *cfp)
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_thread_t *th)
{
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 *th, rb_control_frame_t *cfp, const VALUE
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) {
diff --git a/vm_exec.h b/vm_exec.h
index 2b5f7a9473..12dd277330 100644
--- a/vm_exec.h
+++ b/vm_exec.h
@@ -157,7 +157,7 @@ default: \
#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 { \
diff --git a/vm_insnhelper.c b/vm_insnhelper.c
index c2cc34c4f1..69faf67fa6 100644
--- a/vm_insnhelper.c
+++ b/vm_insnhelper.c
@@ -1516,8 +1516,8 @@ vm_base_ptr(const rb_control_frame_t *cfp)
#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
diff --git a/vm_insnhelper.h b/vm_insnhelper.h
index 8edeb28014..33720cfb21 100644
--- a/vm_insnhelper.h
+++ b/vm_insnhelper.h
@@ -95,7 +95,7 @@ enum vm_regan_acttype {
#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)