diff --git a/basis/compiler/codegen/fixup/fixup.factor b/basis/compiler/codegen/fixup/fixup.factor index af2b1ef1a3..edac283ee0 100644 --- a/basis/compiler/codegen/fixup/fixup.factor +++ b/basis/compiler/codegen/fixup/fixup.factor @@ -80,7 +80,7 @@ SYMBOL: relocation-table rt-this rel-fixup ; : rel-here ( offset class -- ) - [ add-parameter ] dip rt-here rel-fixup ; + [ add-literal ] dip rt-here rel-fixup ; : rel-vm ( offset class -- ) [ add-parameter ] dip rt-vm rel-fixup ; @@ -96,7 +96,7 @@ SYMBOL: relocation-table label>> offset>> [ "Unresolved label" throw ] unless* ; : resolve-absolute-label ( label-fixup -- ) - dup resolve-offset neg add-parameter + dup resolve-offset neg add-literal [ rt-here ] dip [ class>> ] [ offset>> ] bi add-relocation-entry ; : resolve-relative-label ( label-fixup -- label ) diff --git a/vm/code_blocks.cpp b/vm/code_blocks.cpp index d50cbf5160..acbf1ccad8 100755 --- a/vm/code_blocks.cpp +++ b/vm/code_blocks.cpp @@ -194,11 +194,6 @@ cell factor_vm::compute_dlsym_address(array *literals, cell index) return (cell)factor::undefined_symbol; } } -cell factor_vm::compute_here_address(cell arg, cell offset, code_block *compiled) -{ - fixnum n = untag_fixnum(arg); - return n >= 0 ? ((cell)compiled->xt() + offset + n) : ((cell)compiled->xt() - n); -} cell factor_vm::compute_context_address() { @@ -224,9 +219,6 @@ void factor_vm::store_external_address(instruction_operand op) case RT_DLSYM: op.store_value(compute_dlsym_address(parameters,index)); break; - case RT_HERE: - op.store_value(compute_here_address(array_nth(parameters,index),op.rel_offset(),compiled)); - break; case RT_THIS: op.store_value((cell)compiled->xt()); break; @@ -251,6 +243,12 @@ void factor_vm::store_external_address(instruction_operand op) } } +cell factor_vm::compute_here_address(cell arg, cell offset, code_block *compiled) +{ + fixnum n = untag_fixnum(arg); + return n >= 0 ? ((cell)compiled->xt() + offset + n) : ((cell)compiled->xt() - n); +} + struct initial_code_block_visitor { factor_vm *parent; cell literals; @@ -280,6 +278,9 @@ struct initial_code_block_visitor { case RT_XT_PIC_TAIL: op.store_value(parent->compute_xt_pic_tail_address(next_literal())); break; + case RT_HERE: + op.store_value(parent->compute_here_address(next_literal(),op.rel_offset(),op.parent_code_block())); + break; case RT_UNTAGGED: op.store_value(untag_fixnum(next_literal())); break; diff --git a/vm/compaction.cpp b/vm/compaction.cpp index 3b6beb3de9..41ae20232d 100644 --- a/vm/compaction.cpp +++ b/vm/compaction.cpp @@ -117,6 +117,8 @@ struct code_block_compaction_relocation_visitor { op.store_code_block(code_forwarder.visit_code_block(op.load_code_block(old_offset))); break; case RT_HERE: + op.store_value(op.load_value(old_offset) - (cell)old_address + (cell)op.parent_code_block()); + break; case RT_THIS: case RT_CARDS_OFFSET: case RT_DECKS_OFFSET: diff --git a/vm/image.cpp b/vm/image.cpp index 7ec3d615ce..4131365adc 100755 --- a/vm/image.cpp +++ b/vm/image.cpp @@ -190,6 +190,9 @@ struct code_block_fixup_relocation_visitor { case RT_XT_PIC_TAIL: op.store_code_block(code_visitor(op.load_code_block(old_offset))); break; + case RT_HERE: + op.store_value(op.load_value(old_offset) + code_offset); + break; case RT_UNTAGGED: break; default: diff --git a/vm/instruction_operands.hpp b/vm/instruction_operands.hpp index a7d6e4813e..12ac39bb7d 100644 --- a/vm/instruction_operands.hpp +++ b/vm/instruction_operands.hpp @@ -96,7 +96,6 @@ struct relocation_entry { switch(rel_type()) { case RT_PRIMITIVE: - case RT_HERE: case RT_VM: return 1; case RT_DLSYM: @@ -105,6 +104,7 @@ struct relocation_entry { case RT_XT_PIC: case RT_XT_PIC_TAIL: case RT_IMMEDIATE: + case RT_HERE: case RT_UNTAGGED: case RT_THIS: case RT_CONTEXT: diff --git a/vm/jit.hpp b/vm/jit.hpp index 27800b3081..8bc21296e7 100644 --- a/vm/jit.hpp +++ b/vm/jit.hpp @@ -33,8 +33,9 @@ struct jit { void word_jump(cell word_) { data_root word(word_,parent); - parameter(tag_fixnum(xt_tail_pic_offset)); - emit_with_literal(parent->special_objects[JIT_WORD_JUMP],word.value()); + literal(tag_fixnum(xt_tail_pic_offset)); + literal(word.value()); + emit(parent->special_objects[JIT_WORD_JUMP]); } void word_call(cell word) diff --git a/vm/vm.hpp b/vm/vm.hpp index e863597077..d19aa63c19 100755 --- a/vm/vm.hpp +++ b/vm/vm.hpp @@ -512,10 +512,10 @@ struct factor_vm cell compute_primitive_address(cell arg); void undefined_symbol(); cell compute_dlsym_address(array *literals, cell index); - cell compute_here_address(cell arg, cell offset, code_block *compiled); cell compute_context_address(); cell compute_vm_address(cell arg); void store_external_address(instruction_operand op); + cell compute_here_address(cell arg, cell offset, code_block *compiled); void initialize_code_block(code_block *compiled); void fixup_labels(array *labels, code_block *compiled); code_block *allot_code_block(cell size, code_block_type type);