! Contexts
: jit-switch-context ( reg -- )
+ ! Dummy return address -- it never gets returned to but it
+ ! must point to inside the current code block
+ ESP -4 [+] HEX: ffffffff MOV rc-absolute-cell rt-this jit-rel
+
! Save ds, rs registers
jit-load-vm
jit-save-context
! Contexts
: jit-switch-context ( reg -- )
+ ! Dummy return address -- it never gets returned to but it
+ ! must point to inside the current code block
+ R11 0 [RIP+] LEA
+ RSP -8 [+] R11 MOV
+
! Save ds, rs registers
jit-save-context
}
}
+cell factor_vm::frame_offset(stack_frame *frame)
+{
+ return (cell)FRAME_RETURN_ADDRESS(frame,this) - (cell)frame_code(frame)->entry_point();
+}
+
struct stack_frame_accumulator {
factor_vm *parent;
growable_array frames;
const code_block *compiled = parent->frame_code(frame);
gc_info *info = compiled->block_gc_info();
- u32 return_address = (cell)FRAME_RETURN_ADDRESS(frame,parent) - (cell)compiled->entry_point();
+ cell return_address = parent->frame_offset(frame);
+ assert(return_address < compiled->size());
int index = info->return_address_index(return_address);
if(index != -1)
namespace factor
{
-int gc_info::return_address_index(u32 return_address)
+int gc_info::return_address_index(cell return_address)
{
u32 *return_address_array = return_addresses();
+ index * gc_root_count;
}
- int return_address_index(u32 return_address);
+ int return_address_index(cell return_address);
};
}
{
const code_block *compiled = visitor->fixup.translate_code(parent->frame_code(frame));
gc_info *info = compiled->block_gc_info();
-
- u32 return_address = (cell)FRAME_RETURN_ADDRESS(frame,parent) - (cell)compiled->entry_point();
+ cell return_address = parent->frame_offset(frame);
+ assert(return_address < compiled->size());
int index = info->return_address_index(return_address);
if(index != -1)
cell frame_executing_quot(stack_frame *frame);
stack_frame *frame_successor(stack_frame *frame);
cell frame_scan(stack_frame *frame);
+ cell frame_offset(stack_frame *frame);
void primitive_callstack_to_array();
stack_frame *innermost_stack_frame(callstack *stack);
void primitive_innermost_stack_frame_executing();