diff graal/GraalCompiler/src/com/sun/c1x/ir/BlockBegin.java @ 2616:3558ca7088c0

FrameState and Graphviz changes: * removed popx, pushx methods from GraphBuilder * FrameState subclass of Value * added String shortName() to Node * added GraphvizPrinter option to use short names * small hack in GraphvizPrinter: omit FrameState->Local connections * added GraalGraphviz to implicit classpatch (read from GRAAL env var)
author Lukas Stadler <lukas.stadler@jku.at>
date Mon, 09 May 2011 17:00:25 +0200
parents bd235cb4375a
children dd115f80acf8
line wrap: on
line diff
--- a/graal/GraalCompiler/src/com/sun/c1x/ir/BlockBegin.java	Mon May 09 14:11:13 2011 +0200
+++ b/graal/GraalCompiler/src/com/sun/c1x/ir/BlockBegin.java	Mon May 09 17:00:25 2011 +0200
@@ -41,9 +41,34 @@
  */
 public final class BlockBegin extends Instruction {
 
-    private static final int INPUT_COUNT = 0;
+    private static final int INPUT_COUNT = 1;
+    private static final int INPUT_STATE_BEFORE = 0;
+
     private static final int SUCCESSOR_COUNT = 0;
 
+    @Override
+    protected int inputCount() {
+        return super.inputCount() + INPUT_COUNT;
+    }
+
+    @Override
+    protected int successorCount() {
+        return super.successorCount() + SUCCESSOR_COUNT;
+    }
+
+    /**
+     * The frame state before execution of the first instruction in this block.
+     */
+     @Override
+    public FrameState stateBefore() {
+        return (FrameState) inputs().get(super.inputCount() + INPUT_STATE_BEFORE);
+    }
+
+    public FrameState setStateBefore(FrameState n) {
+        assert stateBefore() == null;
+        return (FrameState) inputs().set(super.inputCount() + INPUT_STATE_BEFORE, n);
+    }
+
     private static final List<BlockBegin> NO_HANDLERS = Collections.emptyList();
 
     /**
@@ -76,11 +101,6 @@
     private int blockFlags;
 
     /**
-     * The frame state before execution of the first instruction in this block.
-     */
-    private FrameState stateBefore;
-
-    /**
      * A link to the last node in the block (which contains the successors).
      */
     private BlockEnd end;
@@ -183,24 +203,6 @@
     }
 
     /**
-     * Gets the state at the start of this block.
-     * @return the state at the start of this block
-     */
-    @Override
-    public FrameState stateBefore() {
-        return stateBefore;
-    }
-
-    /**
-     * Sets the initial state for this block.
-     * @param stateBefore the state for this block
-     */
-    public void setStateBefore(FrameState stateBefore) {
-        assert this.stateBefore == null;
-        this.stateBefore = stateBefore;
-    }
-
-    /**
      * Gets the exception handlers that cover one or more instructions of this basic block.
      *
      * @return the exception handlers
@@ -399,8 +401,8 @@
         v.visitBlockBegin(this);
     }
 
-    public void mergeOrClone(FrameState newState, RiMethod method) {
-        FrameState existingState = stateBefore;
+    public void mergeOrClone(FrameStateAccess newState, RiMethod method) {
+        FrameState existingState = stateBefore();
 
         if (existingState == null) {
             // this is the first state for the block
@@ -410,7 +412,7 @@
             }
 
             // copy state because it is modified
-            newState = newState.copy();
+            FrameState duplicate = newState.duplicate();
 
             if (C1XOptions.UseStackMapTableLiveness) {
                 // if a liveness map is available, use it to invalidate dead locals
@@ -419,17 +421,17 @@
                     assert bci() < livenessMap.length;
                     CiBitMap liveness = livenessMap[bci()];
                     if (liveness != null) {
-                        invalidateDeadLocals(newState, liveness);
+                        invalidateDeadLocals(duplicate, liveness);
                     }
                 }
             }
 
             // if the block is a loop header, insert all necessary phis
             if (isParserLoopHeader()) {
-                insertLoopPhis(newState);
+                insertLoopPhis(duplicate);
             }
 
-            stateBefore = newState;
+            setStateBefore(duplicate);
         } else {
             if (!C1XOptions.AssumeVerifiedBytecode && !existingState.isCompatibleWith(newState)) {
                 // stacks or locks do not match--bytecodes would not verify
@@ -443,7 +445,7 @@
                 throw new CiBailout("jsr/ret too complicated");
             }
 
-            existingState.merge(this, newState, graph());
+            existingState.merge(this, newState);
         }
     }
 
@@ -465,13 +467,13 @@
         int stackSize = newState.stackSize();
         for (int i = 0; i < stackSize; i++) {
             // always insert phis for the stack
-            newState.setupPhiForStack(this, i, graph());
+            newState.setupPhiForStack(this, i);
         }
         int localsSize = newState.localsSize();
         for (int i = 0; i < localsSize; i++) {
             Value x = newState.localAt(i);
             if (x != null) {
-                newState.setupPhiForLocal(this, i, graph());
+                newState.setupPhiForLocal(this, i);
             }
         }
     }