From ef38688e87a7f0eccf40d5dfbfb80188a5a5285b Mon Sep 17 00:00:00 2001 From: Joe Groff Date: Wed, 30 Nov 2011 12:57:35 -0800 Subject: [PATCH] vm: method to calculate frame size for address If we're before the prolog or or in a leaf procedure, the stack frame is really a leaf frame created by the signal handler, with a known fixed size, instead of the real stack frame (if any) with a different size. --- vm/code_blocks.hpp | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/vm/code_blocks.hpp b/vm/code_blocks.hpp index d14a55c479..34aeed787d 100644 --- a/vm/code_blocks.hpp +++ b/vm/code_blocks.hpp @@ -61,6 +61,19 @@ struct code_block return (header >> 20) & 0xFF0; } + cell stack_frame_size_for_address(cell addr) const + { + cell natural_frame_size = stack_frame_size(); + /* The first instruction in a code block is the prolog safepoint, + and a leaf procedure code block will record a frame size of zero. + If we're seeing a stack frame in either of these cases, it's a + fake "leaf frame" set up by the signal handler. */ + if (natural_frame_size == 0 || (void*)addr == entry_point()) + return LEAF_FRAME_SIZE; + else + return natural_frame_size; + } + void set_stack_frame_size(cell frame_size) { FACTOR_ASSERT(size() < 0xFFFFFF);