diff --git a/vm/callstack.cpp b/vm/callstack.cpp index 7044cddabd..1926170630 100644 --- a/vm/callstack.cpp +++ b/vm/callstack.cpp @@ -50,7 +50,7 @@ void factor_vm::primitive_callstack_for() { } void* factor_vm::frame_predecessor(void* frame_top) { - void* addr = frame_return_address((void*)frame_top); + void* addr = *(void**)frame_top; FACTOR_ASSERT(addr != 0); code_block* owner = code->code_block_for_address((cell)addr); cell frame_size = owner->stack_frame_size_for_address((cell)addr); @@ -106,14 +106,14 @@ Used by the single stepper. */ void factor_vm::primitive_innermost_stack_frame_executing() { callstack* stack = untag_check(ctx->peek()); void* frame = stack->top(); - void* addr = frame_return_address(frame); + void* addr = *(void**)frame; ctx->replace(code->code_block_for_address((cell)addr)->owner_quot()); } void factor_vm::primitive_innermost_stack_frame_scan() { callstack* stack = untag_check(ctx->peek()); void* frame = stack->top(); - void* addr = frame_return_address(frame); + void* addr = *(void**)frame; ctx->replace(code->code_block_for_address((cell)addr)->scan(this, addr)); } @@ -128,10 +128,10 @@ void factor_vm::primitive_set_innermost_stack_frame_quot() { jit_compile_quot(quot.value(), true); void* inner = stack->top(); - void* addr = frame_return_address(inner); + void* addr = *(void**)inner; code_block* block = code->code_block_for_address((cell)addr); cell offset = block->offset(addr); - set_frame_return_address(inner, (char*)quot->entry_point + offset); + *(void**)inner = (char*)quot->entry_point + offset; } /* Allocates memory (allot_alien) */ diff --git a/vm/callstack.hpp b/vm/callstack.hpp index 2e8b6b7c4c..85cd096296 100644 --- a/vm/callstack.hpp +++ b/vm/callstack.hpp @@ -17,7 +17,7 @@ inline void factor_vm::iterate_callstack_object(callstack* stack_, while (frame_offset < frame_length) { void* frame_top = stack->frame_top_at(frame_offset); - void* addr = frame_return_address(frame_top); + void* addr = *(void**)frame_top; void* fixed_addr = Fixup::translated_code_block_map ? (void*)fixup.translate_code((code_block*)addr) @@ -42,13 +42,11 @@ inline void factor_vm::iterate_callstack_object(callstack* stack, template inline void factor_vm::iterate_callstack(context* ctx, Iterator& iterator, Fixup& fixup) { - if (ctx->callstack_top == ctx->callstack_bottom) - return; char* frame_top = (char*)ctx->callstack_top; while (frame_top < (char*)ctx->callstack_bottom) { - void* addr = frame_return_address((void*)frame_top); + void* addr = *(void**)frame_top; FACTOR_ASSERT(addr != 0); void* fixed_addr = Fixup::translated_code_block_map ? (void*)fixup.translate_code((code_block*)addr) diff --git a/vm/code_block_visitor.hpp b/vm/code_block_visitor.hpp index 0a2184dea5..92e989511e 100644 --- a/vm/code_block_visitor.hpp +++ b/vm/code_block_visitor.hpp @@ -44,7 +44,8 @@ template struct call_frame_code_block_visitor { code_block* compiled = Fixup::translated_code_block_map ? owner : fixup.fixup_code(owner); void* fixed_addr = compiled->address_for_offset(owner->offset(addr)); - set_frame_return_address(frame_top, fixed_addr); + + *(void**)frame_top = fixed_addr; } }; diff --git a/vm/code_blocks.cpp b/vm/code_blocks.cpp index 19f8f4946b..f73e6d56c2 100644 --- a/vm/code_blocks.cpp +++ b/vm/code_blocks.cpp @@ -474,7 +474,7 @@ struct find_symbol_at_address_visitor { image load. It finds the symbol and library, and throws an error. */ void factor_vm::undefined_symbol() { void* frame = ctx->callstack_top; - void* return_address = frame_return_address(frame); + void* return_address = *(void**)frame; code_block* compiled = code->code_block_for_address((cell)return_address); find_symbol_at_address_visitor visitor(this, (cell)return_address); compiled->each_instruction_operand(visitor); diff --git a/vm/cpu-x86.hpp b/vm/cpu-x86.hpp index 1e3cbf6392..d6eea6f7ab 100644 --- a/vm/cpu-x86.hpp +++ b/vm/cpu-x86.hpp @@ -1,14 +1,5 @@ namespace factor { -inline static void* frame_return_address(void* frame_top) { - return *(void**)frame_top; -} - -inline static void set_frame_return_address(void* frame_top, - void* return_address) { - *(void**)frame_top = return_address; -} - #define CALLSTACK_BOTTOM(ctx) \ (void*)(ctx->callstack_seg->end - sizeof(cell) * 5)