vm: context switching needs to scrub the return address

db4
Slava Pestov 2010-06-12 19:52:28 -04:00
parent 96ca7c1d92
commit 3f28c0e7f5
8 changed files with 21 additions and 5 deletions

View File

@ -252,6 +252,10 @@ IN: bootstrap.x86
! 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

View File

@ -228,6 +228,11 @@ IN: bootstrap.x86
! 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

View File

@ -138,6 +138,11 @@ cell factor_vm::frame_scan(stack_frame *frame)
}
}
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;

View File

@ -210,7 +210,8 @@ struct call_frame_scrubber {
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)

View File

@ -3,7 +3,7 @@
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();

View File

@ -45,7 +45,7 @@ struct gc_info {
+ index * gc_root_count;
}
int return_address_index(u32 return_address);
int return_address_index(cell return_address);
};
}

View File

@ -286,8 +286,8 @@ struct call_frame_slot_visitor {
{
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)

View File

@ -596,6 +596,7 @@ struct factor_vm
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();