RT_HERE now takes its argument from the literal table rather than the parameter table, reducing image size further
							parent
							
								
									68c09f0e93
								
							
						
					
					
						commit
						eb840dcf41
					
				| 
						 | 
				
			
			@ -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 )
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -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;
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -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:
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -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:
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -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:
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -33,8 +33,9 @@ struct jit {
 | 
			
		|||
	void word_jump(cell word_)
 | 
			
		||||
	{
 | 
			
		||||
		data_root<word> 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)
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -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);
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
		Reference in New Issue