erg@ommegang ~/factor/vm $ [master*] git diff diff --git a/vm/callstack.hpp b/vm/callstack.hpp index f4fbac2..ac514fb 100755 --- a/vm/callstack.hpp +++ b/vm/callstack.hpp @@ -47,6 +47,7 @@ inline void factor_vm::iterate_callstack(context *ctx, Iterator &iterator, Fixup char *frame_top = (char*)ctx->callstack_top; + printf("iterating\n"); while (frame_top < (char*)ctx->callstack_bottom) { void *addr = frame_return_address((void*)frame_top); @@ -54,13 +55,17 @@ inline void factor_vm::iterate_callstack(context *ctx, Iterator &iterator, Fixup void *fixed_addr = Fixup::translated_code_block_map ? (void*)fixup.translate_code((code_block*)addr) : addr; + printf("addr = %p\n", addr); + printf("fixed_addr = %p\n", fixed_addr); code_block *owner = code->code_block_for_address((cell)fixed_addr); code_block *fixed_owner = Fixup::translated_code_block_map ? owner : fixup.translate_code(owner); + // This fails cell frame_size = fixed_owner->stack_frame_size_for_address((cell)fixed_addr); + printf("frame_size = %ld\n", frame_size); void *fixed_addr_for_iter = Fixup::translated_code_block_map ? fixed_addr @@ -69,6 +74,7 @@ inline void factor_vm::iterate_callstack(context *ctx, Iterator &iterator, Fixup iterator(frame_top, frame_size, owner, fixed_addr_for_iter); frame_top += frame_size; } + printf("done iterating\n\n"); } template diff --git a/vm/code_blocks.hpp b/vm/code_blocks.hpp index 4f67a19..d0a602f 100644 --- a/vm/code_blocks.hpp +++ b/vm/code_blocks.hpp @@ -61,9 +61,13 @@ struct code_block return (header >> 20) & 0xFF0; } + // This fails! cell stack_frame_size_for_address(cell addr) const { cell natural_frame_size = stack_frame_size(); + printf("addr = %p\n", addr); + printf("natural_frame_size = %ld\n", natural_frame_size); + printf("entry_point() = %p\n", entry_point()); /* 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 diff --git a/vm/code_heap.cpp b/vm/code_heap.cpp index ad3680b..560d618 100755 --- a/vm/code_heap.cpp +++ b/vm/code_heap.cpp @@ -118,6 +118,11 @@ code_block *code_heap::code_block_for_address(cell address) { std::set::const_iterator blocki = all_blocks.upper_bound(address); + if(blocki == all_blocks.begin()) { + printf("failing at address = %p\n", address); + current_vm()->factorbug(); + //current_vm()->print_callstack(); + } FACTOR_ASSERT(blocki != all_blocks.begin()); --blocki; code_block* found_block = (code_block*)*blocki; diff --git a/vm/inline_cache.cpp b/vm/inline_cache.cpp index 30e568a..20edc5a 100755 --- a/vm/inline_cache.cpp +++ b/vm/inline_cache.cpp @@ -17,8 +17,10 @@ void factor_vm::deallocate_inline_cache(cell return_address) code_block *old_block = (code_block *)old_entry_point - 1; /* Free the old PIC since we know its unreachable */ - if(old_block->pic_p()) + if(old_block->pic_p()) { + printf("freeing old_block = %p\n", old_block); code->free(old_block); + } } /* Figure out what kind of type check the PIC needs based on the methods