From 40bc8459db1902c7d07a833906300ad389a23276 Mon Sep 17 00:00:00 2001 From: Joe Groff Date: Sat, 29 Oct 2011 15:47:36 -0700 Subject: [PATCH] vm: bottom_frame method for contexts ctx->callstack_bottom - 1 -- the fuck does that mean?! --- vm/callstack.cpp | 2 +- vm/contexts.hpp | 5 +++++ vm/cpu-x86.cpp | 2 +- vm/sampling_profiler.cpp | 4 ++-- 4 files changed, 9 insertions(+), 4 deletions(-) diff --git a/vm/callstack.cpp b/vm/callstack.cpp index 134a7c78b2..0be681d41c 100755 --- a/vm/callstack.cpp +++ b/vm/callstack.cpp @@ -28,7 +28,7 @@ called by continuation implementation, and user code shouldn't be calling it at all, so we leave it as it is for now. */ stack_frame *factor_vm::second_from_top_stack_frame(context *ctx) { - stack_frame *frame = ctx->callstack_bottom - 1; + stack_frame *frame = ctx->bottom_frame(); while(frame >= ctx->callstack_top && frame_successor(frame) >= ctx->callstack_top && frame_successor(frame_successor(frame)) >= ctx->callstack_top) diff --git a/vm/contexts.hpp b/vm/contexts.hpp index 59df3e68c9..30ed74ecd9 100644 --- a/vm/contexts.hpp +++ b/vm/contexts.hpp @@ -73,6 +73,11 @@ struct context { datastack += sizeof(cell); replace(tagged); } + + stack_frame *bottom_frame() + { + return callstack_bottom - 1; + } }; VM_C_API context *new_context(factor_vm *parent); diff --git a/vm/cpu-x86.cpp b/vm/cpu-x86.cpp index c27e563a7c..0fc6bbfc41 100644 --- a/vm/cpu-x86.cpp +++ b/vm/cpu-x86.cpp @@ -13,7 +13,7 @@ void factor_vm::dispatch_signal_handler(cell *sp, cell *pc, cell handler) the signal handler to do its thing, and launch the handler without going through the resumable subprimitive. */ signal_resumable = false; - stack_frame *frame = ctx->callstack_bottom - 1; + stack_frame *frame = ctx->bottom_frame(); while((cell)frame >= *sp && frame >= ctx->callstack_top diff --git a/vm/sampling_profiler.cpp b/vm/sampling_profiler.cpp index b7311d78f7..ed9358fe8d 100644 --- a/vm/sampling_profiler.cpp +++ b/vm/sampling_profiler.cpp @@ -40,10 +40,10 @@ void factor_vm::record_sample() void factor_vm::record_callstack_sample(cell *begin, cell *end) { *begin = sample_callstacks.size(); - stack_frame *frame = ctx->callstack_bottom - 1; + stack_frame *frame = ctx->bottom_frame(); while (frame >= ctx->callstack_top) { - sample_callstacks.push_back((code_block*)frame->entry_point - 1); + sample_callstacks.push_back(frame_code(frame)); frame = frame_successor(frame); }