changeset 21328:de17f6676a43

LinearScan: encapsulate opIdToBlockMap and opIdToInstructionMap.
author Josef Eisl <josef.eisl@jku.at>
date Tue, 12 May 2015 12:19:39 +0200
parents b8dcf353b822
children 6a32034ace1b
files graal/com.oracle.graal.lir/src/com/oracle/graal/lir/alloc/lsra/LifetimeAnalysis.java graal/com.oracle.graal.lir/src/com/oracle/graal/lir/alloc/lsra/LinearScan.java
diffstat 2 files changed, 15 insertions(+), 7 deletions(-) [+]
line wrap: on
line diff
--- a/graal/com.oracle.graal.lir/src/com/oracle/graal/lir/alloc/lsra/LifetimeAnalysis.java	Tue May 12 12:03:55 2015 +0200
+++ b/graal/com.oracle.graal.lir/src/com/oracle/graal/lir/alloc/lsra/LifetimeAnalysis.java	Tue May 12 12:19:39 2015 +0200
@@ -96,8 +96,7 @@
         }
 
         // initialize with correct length
-        allocator.opIdToInstructionMap = new LIRInstruction[numInstructions];
-        allocator.opIdToBlockMap = new AbstractBlockBase<?>[numInstructions];
+        allocator.initOpIdMaps(numInstructions);
 
         int opId = 0;
         int index = 0;
@@ -111,8 +110,7 @@
                 LIRInstruction op = instructions.get(j);
                 op.setId(opId);
 
-                allocator.opIdToInstructionMap[index] = op;
-                allocator.opIdToBlockMap[index] = block;
+                allocator.putOpIdMaps(index, op, block);
                 assert allocator.instructionForId(opId) == op : "must match";
 
                 op.visitEachTemp(setVariableConsumer);
@@ -310,7 +308,7 @@
                             /*
                              * liveIn(block) is the union of liveGen(block) with (liveOut(block) &
                              * !liveKill(block)).
-                             *
+                             * 
                              * Note: liveIn has to be computed only in first iteration or if liveOut
                              * has changed!
                              */
--- a/graal/com.oracle.graal.lir/src/com/oracle/graal/lir/alloc/lsra/LinearScan.java	Tue May 12 12:03:55 2015 +0200
+++ b/graal/com.oracle.graal.lir/src/com/oracle/graal/lir/alloc/lsra/LinearScan.java	Tue May 12 12:19:39 2015 +0200
@@ -141,14 +141,14 @@
      * be retrieved with {@link #instructionForId(int)} as the id is not simply an index into this
      * array.
      */
-    LIRInstruction[] opIdToInstructionMap;
+    private LIRInstruction[] opIdToInstructionMap;
 
     /**
      * Map from an instruction {@linkplain LIRInstruction#id id} to the
      * {@linkplain AbstractBlockBase block} containing the instruction. Entries should be retrieved
      * with {@link #blockForId(int)} as the id is not simply an index into this array.
      */
-    AbstractBlockBase<?>[] opIdToBlockMap;
+    private AbstractBlockBase<?>[] opIdToBlockMap;
 
     /**
      * The {@linkplain #operandNumber(Value) number} of the first variable operand allocated.
@@ -377,6 +377,16 @@
         }
     }
 
+    void initOpIdMaps(int numInstructions) {
+        opIdToInstructionMap = new LIRInstruction[numInstructions];
+        opIdToBlockMap = new AbstractBlockBase<?>[numInstructions];
+    }
+
+    void putOpIdMaps(int index, LIRInstruction op, AbstractBlockBase<?> block) {
+        opIdToInstructionMap[index] = op;
+        opIdToBlockMap[index] = block;
+    }
+
     /**
      * Gets the highest instruction id allocated by this object.
      */