changeset 21190:c927a05097ae

PhiResolver: use LIRInsertionBuffer instead of LIRGeneratorTool.append().
author Josef Eisl <josef.eisl@jku.at>
date Mon, 20 Apr 2015 15:44:04 +0200
parents a74a22532c17
children 12a5d2c12e2e
files graal/com.oracle.graal.lir/src/com/oracle/graal/lir/gen/PhiResolver.java
diffstat 1 files changed, 14 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/graal/com.oracle.graal.lir/src/com/oracle/graal/lir/gen/PhiResolver.java	Mon Apr 20 15:34:41 2015 +0200
+++ b/graal/com.oracle.graal.lir/src/com/oracle/graal/lir/gen/PhiResolver.java	Mon Apr 20 15:44:04 2015 +0200
@@ -30,6 +30,7 @@
 
 import com.oracle.graal.api.meta.*;
 import com.oracle.graal.compiler.common.*;
+import com.oracle.graal.compiler.common.cfg.*;
 import com.oracle.graal.lir.*;
 import com.oracle.graal.lir.gen.LIRGeneratorTool.*;
 
@@ -107,6 +108,8 @@
 
     private final LIRGeneratorTool gen;
     private final SpillMoveFactory moveFactory;
+    private final LIRInsertionBuffer buffer;
+    private final int insertBefore;
 
     /**
      * The operand loop header phi for the operand currently being process in {@link #dispose()}.
@@ -127,6 +130,15 @@
         this.gen = gen;
         moveFactory = gen.getSpillMoveFactory();
         temp = ILLEGAL;
+
+        AbstractBlockBase<?> block = gen.getCurrentBlock();
+        assert block != null;
+        List<LIRInstruction> instructions = gen.getResult().getLIR().getLIRforBlock(block);
+
+        buffer = new LIRInsertionBuffer();
+        buffer.init(instructions);
+        insertBefore = instructions.size();
+
     }
 
     public void dispose() {
@@ -148,6 +160,7 @@
                 emitMove(node.destinations.get(j).operand, node.operand);
             }
         }
+        buffer.finish();
     }
 
     public void move(Value dest, Value src) {
@@ -192,7 +205,7 @@
         assert isLegal(src);
         assert isLegal(dest);
         LIRInstruction move = moveFactory.createMove((AllocatableValue) dest, src);
-        gen.append(move);
+        buffer.append(insertBefore, move);
     }
 
     // Traverse assignment graph in depth first order and generate moves in post order