VM: the frame_return_address and set_frame_return_address functions aren't needed (clearer to read/write the pointers directly)

db4
Björn Lindqvist 2015-01-04 15:33:51 +01:00
parent 11e906139b
commit a6e191a490
5 changed files with 10 additions and 20 deletions

View File

@ -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<callstack>(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<callstack>(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) */

View File

@ -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 <typename Iterator, typename Fixup>
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)

View File

@ -44,7 +44,8 @@ template <typename Fixup> 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;
}
};

View File

@ -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);

View File

@ -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)