void operator()(instruction_operand op) {
code_block* compiled = op.load_code_block();
- switch (op.rel_type()) {
+ switch (op.rel.type()) {
case RT_ENTRY_POINT: {
cell owner = compiled->owner;
if (to_boolean(owner))
? untag<array>(compiled->parameters)
: NULL;
cell idx = op.index;
- relocation_type rel_type = op.rel_type();
+ relocation_type rel_type = op.rel.type();
cell ext_addr = lookup_external_address(rel_type, compiled, parameters, idx);
if (ext_addr == (cell)-1) {
}
fixnum compute_operand_value(instruction_operand op) {
- switch (op.rel_type()) {
+ switch (op.rel.type()) {
case RT_LITERAL:
return next_literal();
case RT_ENTRY_POINT:
return parent->compute_entry_point_pic_tail_address(next_literal());
case RT_HERE:
return parent->compute_here_address(
- next_literal(), op.rel_offset(), op.compiled);
+ next_literal(), op.rel.offset(), op.compiled);
case RT_UNTAGGED:
return untag_fixnum(next_literal());
default:
cell library = false_object;
auto find_symbol_at_address_visitor = [&](instruction_operand op) {
- if (op.rel_type() == RT_DLSYM && op.pointer <= return_address) {
+ if (op.rel.type() == RT_DLSYM && op.pointer <= return_address) {
array* parameters = untag<array>(compiled->parameters);
cell index = op.index;
symbol = array_nth(parameters, index);
: rel(rel),
compiled(compiled),
index(index),
- pointer(compiled->entry_point() + rel.rel_offset()) {}
+ pointer(compiled->entry_point() + rel.offset()) {}
/* Load a 32-bit value from a PowerPC LIS/ORI sequence */
fixnum instruction_operand::load_value_2_2() {
}
fixnum instruction_operand::load_value(cell relative_to) {
- switch (rel.rel_class()) {
+ switch (rel.klass()) {
case RC_ABSOLUTE_CELL:
return *(cell*)(pointer - sizeof(cell));
case RC_ABSOLUTE:
case RC_ABSOLUTE_PPC_2_2_2_2:
return load_value_2_2_2_2();
default:
- critical_error("Bad rel class", rel.rel_class());
+ critical_error("Bad rel class", rel.klass());
return 0;
}
}
void instruction_operand::store_value(fixnum absolute_value) {
fixnum relative_value = absolute_value - pointer;
- switch (rel.rel_class()) {
+ switch (rel.klass()) {
case RC_ABSOLUTE_CELL:
*(cell*)(pointer - sizeof(cell)) = absolute_value;
break;
store_value_2_2_2_2(absolute_value);
break;
default:
- critical_error("Bad rel class", rel.rel_class());
+ critical_error("Bad rel class", rel.klass());
break;
}
}
value = (uint32_t)((rel_type << 28) | (rel_class << 24) | offset);
}
- relocation_type rel_type() {
+ relocation_type type() {
return (relocation_type)((value & 0xf0000000) >> 28);
}
- relocation_class rel_class() {
+ relocation_class klass() {
return (relocation_class)((value & 0x0f000000) >> 24);
}
- cell rel_offset() { return (value & 0x00ffffff); }
+ cell offset() { return (value & 0x00ffffff); }
int number_of_parameters() {
- switch (rel_type()) {
+ switch (type()) {
case RT_VM:
return 1;
case RT_DLSYM:
case RT_SAFEPOINT:
return 0;
default:
- critical_error("Bad rel type in number_of_parameters()", rel_type());
+ critical_error("Bad rel type in number_of_parameters()", type());
return -1; /* Can't happen */
}
}
instruction_operand(relocation_entry rel, code_block* compiled,
cell index);
- relocation_type rel_type() { return rel.rel_type(); }
-
- cell rel_offset() { return rel.rel_offset(); }
-
fixnum load_value_2_2();
fixnum load_value_2_2_2_2();
fixnum load_value_masked(cell mask, cell bits, cell shift);
relocation_entry* relocations = relocation_template->data<relocation_entry>();
for (cell i = 0; i < capacity; i++) {
relocation_entry entry = relocations[i];
- relocation_entry new_entry(entry.rel_type(), entry.rel_class(),
- entry.rel_offset() + code.count);
+ relocation_entry new_entry(entry.type(), entry.klass(),
+ entry.offset() + code.count);
relocation.append_bytes(&new_entry, sizeof(relocation_entry));
}
}
return;
auto update_literal_refs = [&](instruction_operand op) {
- if (op.rel_type() == RT_LITERAL)
+ if (op.rel.type() == RT_LITERAL)
op.store_value(visit_pointer(op.load_value()));
};
compiled->each_instruction_operand(update_literal_refs);
if (parent->code->uninitialized_p(compiled))
return;
auto update_code_block_refs = [&](instruction_operand op){
- relocation_type type = op.rel_type();
+ relocation_type type = op.rel.type();
if (type == RT_ENTRY_POINT ||
type == RT_ENTRY_POINT_PIC ||
type == RT_ENTRY_POINT_PIC_TAIL)
void slot_visitor<Fixup>::visit_instruction_operands(code_block* block,
cell rel_base) {
auto visit_func = [&](instruction_operand op){
- cell old_offset = rel_base + op.rel_offset();
+ cell old_offset = rel_base + op.rel.offset();
cell value = op.load_value(old_offset);
- switch (op.rel_type()) {
+ switch (op.rel.type()) {
case RT_LITERAL: {
value = visit_pointer(value);
break;