summaryrefslogtreecommitdiff
path: root/vm_dump.c
diff options
context:
space:
mode:
authornormal <normal@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2017-05-09 05:06:41 +0000
committernormal <normal@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2017-05-09 05:06:41 +0000
commit9d09240d9e329bbe5a8168dd850f5bb3549fbaa9 (patch)
treee22cadfa88ec235f9630197c0c3a56ce6cbe4850 /vm_dump.c
parent62b885b0900fa8949d794fccce44787e5669f16e (diff)
rb_execution_context_t: move stack, stack_size and cfp from rb_thread_t
The goal is to reduce rb_context_t and rb_fiber_t size by removing the need to store the entire rb_thread_t in there. [ruby-core:81045] Work-in-progress: soon, we will move more fields here. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@58614 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'vm_dump.c')
-rw-r--r--vm_dump.c43
1 files changed, 22 insertions, 21 deletions
diff --git a/vm_dump.c b/vm_dump.c
index 9d1139ec92..d423f1a5a4 100644
--- a/vm_dump.c
+++ b/vm_dump.c
@@ -22,13 +22,14 @@
#define MAX_POSBUF 128
#define VM_CFP_CNT(th, cfp) \
- ((rb_control_frame_t *)((th)->stack + (th)->stack_size) - (rb_control_frame_t *)(cfp))
+ ((rb_control_frame_t *)((th)->ec.stack + (th)->ec.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->stack;
+ ptrdiff_t ep = cfp->ep - th->ec.stack;
char ep_in_heap = ' ';
char posbuf[MAX_POSBUF+1];
int line = 0;
@@ -38,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->stack_size) {
+ if (ep < 0 || (size_t)ep > th->ec.stack_size) {
ep = (ptrdiff_t)cfp->ep;
ep_in_heap = 'p';
}
@@ -117,14 +118,14 @@ control_frame_dump(rb_thread_t *th, rb_control_frame_t *cfp)
}
fprintf(stderr, "c:%04"PRIdPTRDIFF" ",
- ((rb_control_frame_t *)(th->stack + th->stack_size) - cfp));
+ ((rb_control_frame_t *)(th->ec.stack + th->ec.stack_size) - cfp));
if (pc == -1) {
fprintf(stderr, "p:---- ");
}
else {
fprintf(stderr, "p:%04"PRIdPTRDIFF" ", pc);
}
- fprintf(stderr, "s:%04"PRIdPTRDIFF" ", cfp->sp - th->stack);
+ fprintf(stderr, "s:%04"PRIdPTRDIFF" ", cfp->sp - th->ec.stack);
fprintf(stderr, ep_in_heap == ' ' ? "e:%06"PRIdPTRDIFF" " : "E:%06"PRIxPTRDIFF" ", ep % 10000);
fprintf(stderr, "%-6s", magic);
if (line) {
@@ -150,12 +151,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->stack; p < sp; p++) {
+ for (p = st = th->ec.stack; p < sp; p++) {
fprintf(stderr, "%04ld (%p): %08"PRIxVALUE, (long)(p - st), p, *p);
t = (VALUE *)*p;
- if (th->stack <= t && t < sp) {
- fprintf(stderr, " (= %ld)", (long)((VALUE *)GC_GUARDED_PTR_REF(t) - th->stack));
+ if (th->ec.stack <= t && t < sp) {
+ fprintf(stderr, " (= %ld)", (long)((VALUE *)GC_GUARDED_PTR_REF(t) - th->ec.stack));
}
if (p == ep)
@@ -167,7 +168,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->stack + th->stack_size)) {
+ while ((void *)cfp < (void *)(th->ec.stack + th->ec.stack_size)) {
control_frame_dump(th, cfp);
cfp++;
}
@@ -178,7 +179,7 @@ void
rb_vmdebug_stack_dump_raw_current(void)
{
rb_thread_t *th = GET_THREAD();
- rb_vmdebug_stack_dump_raw(th, th->cfp);
+ rb_vmdebug_stack_dump_raw(th, th->ec.cfp);
}
void
@@ -219,7 +220,7 @@ rb_vmdebug_stack_dump_th(VALUE thval)
{
rb_thread_t *th;
GetThreadPtr(thval, th);
- rb_vmdebug_stack_dump_raw(th, th->cfp);
+ rb_vmdebug_stack_dump_raw(th, th->ec.cfp);
}
#if VMDEBUG > 2
@@ -293,7 +294,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->stack));
+ (ptr - th->ec.stack));
}
}
else if (VM_FRAME_FINISHED_P(cfp)) {
@@ -313,22 +314,22 @@ vm_stack_dump_each(rb_thread_t *th, rb_control_frame_t *cfp)
void
rb_vmdebug_debug_print_register(rb_thread_t *th)
{
- rb_control_frame_t *cfp = th->cfp;
+ rb_control_frame_t *cfp = th->ec.cfp;
ptrdiff_t pc = -1;
- ptrdiff_t ep = cfp->ep - th->stack;
+ ptrdiff_t ep = cfp->ep - th->ec.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->stack_size) {
+ if (ep < 0 || (size_t)ep > th->ec.stack_size) {
ep = -1;
}
- cfpi = ((rb_control_frame_t *)(th->stack + th->stack_size)) - cfp;
+ cfpi = ((rb_control_frame_t *)(th->ec.stack + th->ec.stack_size)) - cfp;
fprintf(stderr, " [PC] %04"PRIdPTRDIFF", [SP] %04"PRIdPTRDIFF", [EP] %04"PRIdPTRDIFF", [CFP] %04"PRIdPTRDIFF"\n",
- pc, (cfp->sp - th->stack), ep, cfpi);
+ pc, (cfp->sp - th->ec.stack), ep, cfpi);
}
void
@@ -352,7 +353,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->stack));
+ if(0)printf("[%03ld] ", (long)(cfp->sp - th->ec.stack));
/* printf("%3"PRIdPTRDIFF" ", VM_CFP_CNT(th, cfp)); */
if (pc >= 0) {
@@ -387,7 +388,7 @@ rb_vmdebug_debug_print_post(rb_thread_t *th, rb_control_frame_t *cfp
#if VMDEBUG > 2
/* stack_dump_thobj(th); */
- vm_stack_dump_each(th, th->cfp);
+ vm_stack_dump_each(th, th->ec.cfp);
#if OPT_STACK_CACHING
{
@@ -409,7 +410,7 @@ rb_vmdebug_thread_dump_state(VALUE self)
rb_thread_t *th;
rb_control_frame_t *cfp;
GetThreadPtr(self, th);
- cfp = th->cfp;
+ cfp = th->ec.cfp;
fprintf(stderr, "Thread state dump:\n");
fprintf(stderr, "pc : %p, sp : %p\n", (void *)cfp->pc, (void *)cfp->sp);
@@ -1065,6 +1066,6 @@ rb_vmdebug_stack_dump_all_threads(void)
#else
fprintf(stderr, "th: %p, native_id: %p\n", th, (void *)th->thread_id);
#endif
- rb_vmdebug_stack_dump_raw(th, th->cfp);
+ rb_vmdebug_stack_dump_raw(th, th->ec.cfp);
}
}