From 46bfcbf3a2145d26eea05afdf01901769c346338 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B6rn=20Lindqvist?= Date: Sat, 12 Dec 2015 04:02:53 +0100 Subject: [PATCH] VM: the rel_type() and rel_offset() accessors in instruction_operand can be removed --- vm/code_blocks.cpp | 10 +++++----- vm/instruction_operands.cpp | 10 +++++----- vm/instruction_operands.hpp | 14 +++++--------- vm/jit.cpp | 4 ++-- vm/slot_visitor.hpp | 8 ++++---- 5 files changed, 21 insertions(+), 25 deletions(-) diff --git a/vm/code_blocks.cpp b/vm/code_blocks.cpp index f65af3d9ed..7625ce9c11 100644 --- a/vm/code_blocks.cpp +++ b/vm/code_blocks.cpp @@ -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(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(compiled->parameters); cell index = op.index; symbol = array_nth(parameters, index); diff --git a/vm/instruction_operands.cpp b/vm/instruction_operands.cpp index 460d1f0c37..d0e6d255b6 100644 --- a/vm/instruction_operands.cpp +++ b/vm/instruction_operands.cpp @@ -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; } } diff --git a/vm/instruction_operands.hpp b/vm/instruction_operands.hpp index 9e12fc1918..a8e0994fa7 100644 --- a/vm/instruction_operands.hpp +++ b/vm/instruction_operands.hpp @@ -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); diff --git a/vm/jit.cpp b/vm/jit.cpp index ad13d08747..77340f2fd3 100644 --- a/vm/jit.cpp +++ b/vm/jit.cpp @@ -38,8 +38,8 @@ void jit::emit_relocation(cell relocation_template_) { relocation_entry* relocations = relocation_template->data(); 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)); } } diff --git a/vm/slot_visitor.hpp b/vm/slot_visitor.hpp index 2e49d5db50..b8af8314bf 100644 --- a/vm/slot_visitor.hpp +++ b/vm/slot_visitor.hpp @@ -370,7 +370,7 @@ void slot_visitor::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::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 void slot_visitor::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;