changeset 2750:6048da340364

less references to BlockBegin in BlockEnd instructions
author Lukas Stadler <lukas.stadler@jku.at>
date Fri, 20 May 2011 14:22:19 +0200
parents 36440e516e44
children 0d268cf66e24
files graal/GraalCompiler/src/com/sun/c1x/graph/GraphBuilder.java graal/GraalCompiler/src/com/sun/c1x/ir/BlockBegin.java graal/GraalCompiler/src/com/sun/c1x/ir/BlockEnd.java graal/GraalCompiler/src/com/sun/c1x/ir/ExceptionDispatch.java graal/GraalCompiler/src/com/sun/c1x/ir/Goto.java graal/GraalCompiler/src/com/sun/c1x/ir/If.java graal/GraalCompiler/src/com/sun/c1x/ir/LookupSwitch.java graal/GraalCompiler/src/com/sun/c1x/ir/Switch.java graal/GraalCompiler/src/com/sun/c1x/ir/TableSwitch.java
diffstat 9 files changed, 36 insertions(+), 38 deletions(-) [+]
line wrap: on
line diff
--- a/graal/GraalCompiler/src/com/sun/c1x/graph/GraphBuilder.java	Fri May 20 14:09:28 2011 +0200
+++ b/graal/GraalCompiler/src/com/sun/c1x/graph/GraphBuilder.java	Fri May 20 14:22:19 2011 +0200
@@ -255,7 +255,7 @@
         assert bci() == 0;
         FrameState stateAfter = frameState.create(bci());
         Instruction target = createTargetAt(0, stateAfter);
-        Goto base = new Goto((BlockBegin) target, stateAfter, graph);
+        Goto base = new Goto(target, stateAfter, graph);
         appendWithBCI(base);
         ((BlockBegin) startBlock.firstInstruction).setEnd(base);
     }
@@ -400,14 +400,14 @@
 
                     if (handler.handler.catchType().isResolved()) {
                         Instruction entry = createTarget(handler.entryBlock(), null);
-                        ExceptionDispatch end = new ExceptionDispatch(null, (BlockBegin) handler.entryBlock().firstInstruction, null, handler, null, graph);
-                        end.setBlockSuccessor(0, (BlockBegin) successor);
+                        ExceptionDispatch end = new ExceptionDispatch(null, entry, null, handler, null, graph);
+                        end.setBlockSuccessor(0, successor);
                         dispatchEntry.appendNext(end);
                         dispatchEntry.setEnd(end);
                     } else {
                         Deoptimize deopt = new Deoptimize(graph);
                         dispatchEntry.appendNext(deopt);
-                        Goto end = new Goto((BlockBegin) successor, null, graph);
+                        Goto end = new Goto(successor, null, graph);
                         deopt.appendNext(end);
                         dispatchEntry.setEnd(end);
                     }
@@ -424,7 +424,7 @@
             ExceptionObject exception = new ExceptionObject(graph);
             entry.appendNext(exception);
             FrameState stateWithException = entryState.duplicateModified(bci, CiKind.Void, exception);
-            BlockEnd end = new Goto((BlockBegin) successor, stateWithException, graph);
+            BlockEnd end = new Goto(successor, stateWithException, graph);
             exception.appendNext(end);
             entry.setEnd(end);
 
@@ -666,13 +666,13 @@
     }
 
     private void genGoto(int fromBCI, int toBCI) {
-        append(new Goto((BlockBegin) createTargetAt(toBCI, frameState), null, graph));
+        append(new Goto(createTargetAt(toBCI, frameState), null, graph));
     }
 
     private void ifNode(Value x, Condition cond, Value y) {
         Instruction tsucc = createTargetAt(stream().readBranchDest(), frameState);
         Instruction fsucc = createTargetAt(stream().nextBCI(), frameState);
-        append(new If(x, cond, y, (BlockBegin) tsucc, (BlockBegin) fsucc, null, graph));
+        append(new If(x, cond, y, tsucc, fsucc, null, graph));
     }
 
     private void genIfZero(Condition cond) {
@@ -1052,23 +1052,7 @@
         list.add(createTargetAt(bci + offset, frameState));
         boolean isSafepoint = isBackwards && !noSafepoints();
         FrameState stateAfter = isSafepoint ? frameState.create(bci()) : null;
-        append(new TableSwitch(value, (List) list, ts.lowKey(), stateAfter, graph));
-    }
-
-    private Instruction createTargetAt(int bci, FrameStateAccess stateAfter) {
-        return createTarget(blockList[bci], stateAfter);
-    }
-
-    private Instruction createTarget(Block block, FrameStateAccess stateAfter) {
-        if (block.firstInstruction == null) {
-            BlockBegin blockBegin = new BlockBegin(block.startBci, block.blockID, graph);
-            block.firstInstruction = blockBegin;
-        }
-        if (stateAfter != null) {
-            mergeOrClone(block, stateAfter);
-        }
-        addToWorkList(block);
-        return block.firstInstruction;
+        append(new TableSwitch(value, list, ts.lowKey(), stateAfter, graph));
     }
 
     private void genLookupswitch() {
@@ -1091,7 +1075,7 @@
         list.add(createTargetAt(bci + offset, frameState));
         boolean isSafepoint = isBackwards && !noSafepoints();
         FrameState stateAfter = isSafepoint ? frameState.create(bci()) : null;
-        append(new LookupSwitch(value, (List) list, keys, stateAfter, graph));
+        append(new LookupSwitch(value, list, keys, stateAfter, graph));
     }
 
     private Value appendConstant(CiConstant constant) {
@@ -1130,6 +1114,22 @@
         return result;
     }
 
+    private Instruction createTargetAt(int bci, FrameStateAccess stateAfter) {
+        return createTarget(blockList[bci], stateAfter);
+    }
+
+    private Instruction createTarget(Block block, FrameStateAccess stateAfter) {
+        if (block.firstInstruction == null) {
+            BlockBegin blockBegin = new BlockBegin(block.startBci, block.blockID, graph);
+            block.firstInstruction = blockBegin;
+        }
+        if (stateAfter != null) {
+            mergeOrClone(block, stateAfter);
+        }
+        addToWorkList(block);
+        return block.firstInstruction;
+    }
+
     private Value synchronizedObject(FrameStateAccess state, RiMethod target) {
         if (isStatic(target.accessFlags())) {
             Constant classConstant = new Constant(target.holder().getEncoding(Representation.JavaClass), graph);
@@ -1210,7 +1210,7 @@
             if (nextBlock != null && nextBlock != block) {
                 // we fell through to the next block, add a goto and break
                 Instruction next = createTarget(nextBlock, frameState);
-                end = new Goto((BlockBegin) next, null, graph);
+                end = new Goto(next, null, graph);
                 lastInstr = lastInstr.appendNext(end);
                 break;
             }
--- a/graal/GraalCompiler/src/com/sun/c1x/ir/BlockBegin.java	Fri May 20 14:09:28 2011 +0200
+++ b/graal/GraalCompiler/src/com/sun/c1x/ir/BlockBegin.java	Fri May 20 14:22:19 2011 +0200
@@ -25,13 +25,11 @@
 import java.util.*;
 
 import com.oracle.graal.graph.*;
-import com.sun.c1x.*;
 import com.sun.c1x.debug.*;
 import com.sun.c1x.lir.*;
 import com.sun.c1x.util.*;
 import com.sun.c1x.value.*;
 import com.sun.cri.ci.*;
-import com.sun.cri.ri.*;
 
 /**
  * Denotes the beginning of a basic block, and holds information
--- a/graal/GraalCompiler/src/com/sun/c1x/ir/BlockEnd.java	Fri May 20 14:09:28 2011 +0200
+++ b/graal/GraalCompiler/src/com/sun/c1x/ir/BlockEnd.java	Fri May 20 14:22:19 2011 +0200
@@ -77,8 +77,9 @@
         return (BlockBegin) successors().get(super.successorCount() + SUCCESSOR_COUNT + index);
     }
 
-    public BlockBegin setBlockSuccessor(int index, BlockBegin n) {
+    public Instruction setBlockSuccessor(int index, Instruction n) {
         assert index >= 0 && index < blockSuccessorCount;
+        assert n instanceof BlockBegin : "only BlockBegins, for now...";
         return (BlockBegin) successors().set(super.successorCount() + SUCCESSOR_COUNT + index, n);
     }
 
@@ -93,7 +94,7 @@
      * @param isSafepoint {@code true} if this instruction is a safepoint instruction
      * @param successors the list of successor blocks. If {@code null}, a new one will be created.
      */
-    public BlockEnd(CiKind kind, FrameState stateAfter, List<BlockBegin> blockSuccessors, int inputCount, int successorCount, Graph graph) {
+    public BlockEnd(CiKind kind, FrameState stateAfter, List<? extends Instruction> blockSuccessors, int inputCount, int successorCount, Graph graph) {
         this(kind, stateAfter, blockSuccessors.size(), inputCount, successorCount, graph);
         for (int i = 0; i < blockSuccessors.size(); i++) {
             setBlockSuccessor(i, blockSuccessors.get(i));
@@ -166,7 +167,7 @@
      */
     public void reorderSuccessor(int i, int backEdgeIndex) {
         assert i >= 0 && i < blockSuccessorCount;
-        BlockBegin successor = blockSuccessor(i);
+        Instruction successor = blockSuccessor(i);
         if (successor != null) {
             successors().set(super.successorCount() + SUCCESSOR_COUNT + i, Node.Null);
             successors().set(super.successorCount() + SUCCESSOR_COUNT + i, successor, backEdgeIndex);
--- a/graal/GraalCompiler/src/com/sun/c1x/ir/ExceptionDispatch.java	Fri May 20 14:09:28 2011 +0200
+++ b/graal/GraalCompiler/src/com/sun/c1x/ir/ExceptionDispatch.java	Fri May 20 14:22:19 2011 +0200
@@ -64,7 +64,7 @@
     /**
      * Constructs a new ExceptionDispatch instruction.
      */
-    public ExceptionDispatch(Value exception, BlockBegin catchSuccessor, BlockBegin otherSuccessor, ExceptionHandler handler, FrameState stateAfter, Graph graph) {
+    public ExceptionDispatch(Value exception, Instruction catchSuccessor, Instruction otherSuccessor, ExceptionHandler handler, FrameState stateAfter, Graph graph) {
         super(CiKind.Int, stateAfter, 2, INPUT_COUNT, SUCCESSOR_COUNT, graph);
         setException(exception);
         setBlockSuccessor(0, otherSuccessor);
--- a/graal/GraalCompiler/src/com/sun/c1x/ir/Goto.java	Fri May 20 14:09:28 2011 +0200
+++ b/graal/GraalCompiler/src/com/sun/c1x/ir/Goto.java	Fri May 20 14:22:19 2011 +0200
@@ -42,7 +42,7 @@
      * @param isSafepoint {@code true} if the goto should be considered a safepoint (e.g. backward branch)
      * @param graph
      */
-    public Goto(BlockBegin succ, FrameState stateAfter, Graph graph) {
+    public Goto(Instruction succ, FrameState stateAfter, Graph graph) {
         super(CiKind.Illegal, stateAfter, 1, INPUT_COUNT, SUCCESSOR_COUNT, graph);
         setBlockSuccessor(0, succ);
     }
--- a/graal/GraalCompiler/src/com/sun/c1x/ir/If.java	Fri May 20 14:09:28 2011 +0200
+++ b/graal/GraalCompiler/src/com/sun/c1x/ir/If.java	Fri May 20 14:22:19 2011 +0200
@@ -86,8 +86,7 @@
      * @param isSafepoint {@code true} if this branch should be considered a safepoint
      * @param graph
      */
-    public If(Value x, Condition cond, Value y,
-              BlockBegin trueSucc, BlockBegin falseSucc, FrameState stateAfter, Graph graph) {
+    public If(Value x, Condition cond, Value y, Instruction trueSucc, Instruction falseSucc, FrameState stateAfter, Graph graph) {
         super(CiKind.Illegal, stateAfter, 2, INPUT_COUNT, SUCCESSOR_COUNT, graph);
         assert Util.archKindsEqual(x, y);
         condition = cond;
--- a/graal/GraalCompiler/src/com/sun/c1x/ir/LookupSwitch.java	Fri May 20 14:09:28 2011 +0200
+++ b/graal/GraalCompiler/src/com/sun/c1x/ir/LookupSwitch.java	Fri May 20 14:22:19 2011 +0200
@@ -50,7 +50,7 @@
      * @param isSafepoint {@code true} if this instruction is a safepoint
      * @param graph
      */
-    public LookupSwitch(Value value, List<BlockBegin> successors, int[] keys, FrameState stateAfter, Graph graph) {
+    public LookupSwitch(Value value, List<? extends Instruction> successors, int[] keys, FrameState stateAfter, Graph graph) {
         super(value, successors, stateAfter, INPUT_COUNT, SUCCESSOR_COUNT, graph);
         this.keys = keys;
     }
--- a/graal/GraalCompiler/src/com/sun/c1x/ir/Switch.java	Fri May 20 14:09:28 2011 +0200
+++ b/graal/GraalCompiler/src/com/sun/c1x/ir/Switch.java	Fri May 20 14:22:19 2011 +0200
@@ -67,7 +67,7 @@
      * @param isSafepoint {@code true} if this switch is a safepoint
      * @param graph
      */
-    public Switch(Value value, List<BlockBegin> successors, FrameState stateAfter, int inputCount, int successorCount, Graph graph) {
+    public Switch(Value value, List<? extends Instruction> successors, FrameState stateAfter, int inputCount, int successorCount, Graph graph) {
         super(CiKind.Illegal, stateAfter, successors, inputCount + INPUT_COUNT, successorCount + SUCCESSOR_COUNT, graph);
         setValue(value);
     }
--- a/graal/GraalCompiler/src/com/sun/c1x/ir/TableSwitch.java	Fri May 20 14:09:28 2011 +0200
+++ b/graal/GraalCompiler/src/com/sun/c1x/ir/TableSwitch.java	Fri May 20 14:22:19 2011 +0200
@@ -49,7 +49,7 @@
      * @param isSafepoint {@code true} if this instruction is a safepoint
      * @param graph
      */
-    public TableSwitch(Value value, List<BlockBegin> successors, int lowKey, FrameState stateAfter, Graph graph) {
+    public TableSwitch(Value value, List<? extends Instruction> successors, int lowKey, FrameState stateAfter, Graph graph) {
         super(value, successors, stateAfter, INPUT_COUNT, SUCCESSOR_COUNT, graph);
         this.lowKey = lowKey;
     }