]> gitweb.factorcode.org Git - factor.git/commitdiff
VM: the rel_type() and rel_offset() accessors in instruction_operand can be removed
authorBjörn Lindqvist <bjourne@gmail.com>
Sat, 12 Dec 2015 03:02:53 +0000 (04:02 +0100)
committerBjörn Lindqvist <bjourne@gmail.com>
Sun, 13 Dec 2015 12:56:36 +0000 (13:56 +0100)
vm/code_blocks.cpp
vm/instruction_operands.cpp
vm/instruction_operands.hpp
vm/jit.cpp
vm/slot_visitor.hpp

index f65af3d9ede08ea079e842a8e9eceb577c34c59f..7625ce9c116b13da503c5d7d7ef732feaf680fb9 100644 (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);
index 460d1f0c3709a71b6d9ef6f52a2e146a8e23fb58..d0e6d255b6b386d538c748508389d947960cbdc4 100644 (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;
   }
 }
index 9e12fc1918c3bf94d70a28208f2a03e315489b6c..a8e0994fa7783179e070f43f67364da70d28d5eb 100644 (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);
index ad13d08747c7497d94901fc806ac7d2fd495d1b4..77340f2fd3050525fe7ecd7966be49383ceef047 100644 (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));
   }
 }
index 2e49d5db50f497e3a947ab76125a6771b5e1ebee..b8af8314bf53be3bfe9d614c840f7b7c65e093c5 100644 (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;