void operator()(stack_frame *frame) { cell offset = (cell)FRAME_RETURN_ADDRESS(frame,myvm) - (cell)myvm->frame_code(frame); code_block *forwarded = myvm->forward_xt(myvm->frame_code(frame)); frame->xt = forwarded->xt(); FRAME_RETURN_ADDRESS(frame,myvm) = (void *)((cell)forwarded + offset); }
void forward_frame_xt(F_STACK_FRAME *frame) { CELL offset = (CELL)FRAME_RETURN_ADDRESS(frame) - (CELL)frame_code(frame); F_COMPILED *forwarded = forward_xt(frame_code(frame)); frame->xt = (XT)(forwarded + 1); FRAME_RETURN_ADDRESS(frame) = (XT)((CELL)forwarded + offset); }
void operator()(stack_frame *frame) { cell offset = (cell)FRAME_RETURN_ADDRESS(frame,parent) - (cell)frame->xt; code_block *forwarded = parent->code->forward_code_block(parent->frame_code(frame)); frame->xt = forwarded->xt(); FRAME_RETURN_ADDRESS(frame,parent) = (void *)((cell)frame->xt + offset); }
void operator()(stack_frame *frame) { cell offset = (cell)FRAME_RETURN_ADDRESS(frame,parent) - (cell)frame->entry_point; code_block *new_block = visitor(parent->frame_code(frame)); frame->entry_point = new_block->entry_point(); FRAME_RETURN_ADDRESS(frame,parent) = (void *)((cell)frame->entry_point + offset); }
void factor_vm::primitive_set_innermost_stack_frame_quot() { data_root<callstack> callstack(ctx->pop(),this); data_root<quotation> quot(ctx->pop(),this); callstack.untag_check(this); quot.untag_check(this); jit_compile_quot(quot.value(),true); stack_frame *inner = innermost_stack_frame(callstack.untagged()); cell offset = (char *)FRAME_RETURN_ADDRESS(inner,this) - (char *)inner->entry_point; inner->entry_point = quot->entry_point; FRAME_RETURN_ADDRESS(inner,this) = (char *)quot->entry_point + offset; }
inline void factorvm::vmprim_set_innermost_stack_frame_quot() { gc_root<callstack> callstack(dpop(),this); gc_root<quotation> quot(dpop(),this); callstack.untag_check(this); quot.untag_check(this); jit_compile(quot.value(),true); stack_frame *inner = innermost_stack_frame_quot(callstack.untagged()); cell offset = (char *)FRAME_RETURN_ADDRESS(inner) - (char *)inner->xt; inner->xt = quot->xt; FRAME_RETURN_ADDRESS(inner) = (char *)quot->xt + offset; }
/* Allocates memory */ cell frame_scan(stack_frame *frame) { switch(frame_type(frame)) { case QUOTATION_TYPE: { cell quot = frame_executing(frame); if(quot == F) return F; else { char *return_addr = (char *)FRAME_RETURN_ADDRESS(frame); char *quot_xt = (char *)(frame_code(frame) + 1); return tag_fixnum(quot_code_offset_to_scan( quot,(cell)(return_addr - quot_xt))); } } case WORD_TYPE: return F; default: critical_error("Bad frame type",frame_type(frame)); return F; } }
/* Allocates memory */ cell factor_vm::frame_scan(stack_frame *frame) { switch(frame_type(frame)) { case code_block_unoptimized: { tagged<object> obj(frame_executing(frame)); if(obj.type_p(WORD_TYPE)) obj = obj.as<word>()->def; if(obj.type_p(QUOTATION_TYPE)) { char *return_addr = (char *)FRAME_RETURN_ADDRESS(frame,this); char *quot_entry_point = (char *)(frame_code(frame) + 1); return tag_fixnum(quot_code_offset_to_scan( obj.value(),(cell)(return_addr - quot_entry_point))); } else return false_object; } case code_block_optimized: return false_object; default: critical_error("Bad frame type",frame_type(frame)); return false_object; } }
/* References to undefined symbols are patched up to call this function on image load. It finds the symbol and library, and throws an error. */ void factor_vm::undefined_symbol() { stack_frame *frame = innermost_stack_frame(ctx->callstack_bottom, ctx->callstack_top); code_block *compiled = frame_code(frame); cell return_address = (cell)FRAME_RETURN_ADDRESS(frame, this); find_symbol_at_address_visitor visitor(this, return_address); compiled->each_instruction_operand(visitor); if (!to_boolean(visitor.symbol)) critical_error("Can't find RT_DLSYM at return address", return_address); else general_error(ERROR_UNDEFINED_SYMBOL,visitor.symbol,visitor.library); }
static void fixup_stack_frame(stack_frame *frame) { code_fixup(&frame->xt); code_fixup(&FRAME_RETURN_ADDRESS(frame)); }
void fixup_stack_frame(F_STACK_FRAME *frame) { code_fixup((CELL)&frame->xt); code_fixup((CELL)&FRAME_RETURN_ADDRESS(frame)); }
void operator()(stack_frame *frame) { myvm->code_fixup(&frame->xt,code_relocation_base); myvm->code_fixup(&FRAME_RETURN_ADDRESS(frame,myvm),code_relocation_base); }