VM: the rel_type() and rel_offset() accessors in instruction_operand can be removed

db4
Björn Lindqvist 2015-12-12 04:02:53 +01:00
parent 3affad7681
commit 46bfcbf3a2
5 changed files with 21 additions and 25 deletions

View File

@ -83,7 +83,7 @@ struct update_word_references_relocation_visitor {
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))
@ -198,7 +198,7 @@ cell factor_vm::compute_external_address(instruction_operand op) {
? 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) {
@ -239,7 +239,7 @@ struct initial_code_block_visitor {
}
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:
@ -250,7 +250,7 @@ struct initial_code_block_visitor {
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:
@ -395,7 +395,7 @@ void factor_vm::undefined_symbol() {
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);

View File

@ -7,7 +7,7 @@ instruction_operand::instruction_operand(relocation_entry rel,
: 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() {
@ -37,7 +37,7 @@ fixnum instruction_operand::load_value_masked(cell mask, cell bits,
}
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:
@ -68,7 +68,7 @@ fixnum instruction_operand::load_value(cell relative_to) {
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;
}
}
@ -110,7 +110,7 @@ void instruction_operand::store_value_masked(fixnum value, cell mask,
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;
@ -153,7 +153,7 @@ void instruction_operand::store_value(fixnum absolute_value) {
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;
}
}

View File

@ -81,18 +81,18 @@ struct relocation_entry {
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:
@ -112,7 +112,7 @@ struct relocation_entry {
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 */
}
}
@ -127,10 +127,6 @@ struct instruction_operand {
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);

View File

@ -38,8 +38,8 @@ void jit::emit_relocation(cell relocation_template_) {
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));
}
}

View File

@ -370,7 +370,7 @@ void slot_visitor<Fixup>::visit_embedded_literals(code_block* compiled) {
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);
@ -438,7 +438,7 @@ void slot_visitor<Fixup>::visit_embedded_code_pointers(code_block* compiled) {
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)
@ -485,9 +485,9 @@ template <typename Fixup>
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;