changeset 15220:ccf0c5a1edf1

Use a synthetic BCI instead of a random BCI (the first parsed bytecode that could throw an exception) for the exception unwind block
author Christian Wimmer <christian.wimmer@oracle.com>
date Thu, 17 Apr 2014 15:32:57 -0700
parents 3e6cbf843040
children b7dbf9403902
files graal/com.oracle.graal.java/src/com/oracle/graal/java/GraphBuilderPhase.java graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/FrameState.java
diffstat 2 files changed, 16 insertions(+), 10 deletions(-) [+]
line wrap: on
line diff
--- a/graal/com.oracle.graal.java/src/com/oracle/graal/java/GraphBuilderPhase.java	Thu Apr 17 23:41:00 2014 +0200
+++ b/graal/com.oracle.graal.java/src/com/oracle/graal/java/GraphBuilderPhase.java	Thu Apr 17 15:32:57 2014 -0700
@@ -284,12 +284,12 @@
             protected void finishPrepare(FixedWithNextNode startInstr) {
             }
 
-            private BciBlock unwindBlock(int bci) {
+            private BciBlock unwindBlock() {
                 if (unwindBlock == null) {
                     unwindBlock = new ExceptionDispatchBlock();
                     unwindBlock.startBci = -1;
                     unwindBlock.endBci = -1;
-                    unwindBlock.deoptBci = bci;
+                    unwindBlock.deoptBci = FrameState.UNWIND_BCI;
                     unwindBlock.setId(Integer.MAX_VALUE);
                 }
                 return unwindBlock;
@@ -419,7 +419,7 @@
                  * unwind immediately.
                  */
                 if (bci != currentBlock.endBci || dispatchBlock == null) {
-                    dispatchBlock = unwindBlock(bci);
+                    dispatchBlock = unwindBlock();
                 }
 
                 HIRFrameStateBuilder dispatchState = frameState.copy();
@@ -1188,7 +1188,7 @@
                     ResolvedJavaType resolvedCatchType = (ResolvedJavaType) catchType;
                     for (ResolvedJavaType skippedType : graphBuilderConfig.getSkippedExceptionTypes()) {
                         if (skippedType.isAssignableFrom(resolvedCatchType)) {
-                            BciBlock nextBlock = block.getSuccessorCount() == 1 ? unwindBlock(block.deoptBci) : block.getSuccessor(1);
+                            BciBlock nextBlock = block.getSuccessorCount() == 1 ? unwindBlock() : block.getSuccessor(1);
                             ValueNode exception = frameState.stackAt(0);
                             FixedNode trueSuccessor = currentGraph.add(new DeoptimizeNode(InvalidateReprofile, UnreachedCode));
                             FixedNode nextDispatch = createTarget(nextBlock, frameState);
@@ -1199,7 +1199,7 @@
                 }
 
                 if (initialized) {
-                    BciBlock nextBlock = block.getSuccessorCount() == 1 ? unwindBlock(block.deoptBci) : block.getSuccessor(1);
+                    BciBlock nextBlock = block.getSuccessorCount() == 1 ? unwindBlock() : block.getSuccessor(1);
                     ValueNode exception = frameState.stackAt(0);
                     CheckCastNode checkCast = currentGraph.add(new CheckCastNode((ResolvedJavaType) catchType, exception, null, false));
                     frameState.apop();
--- a/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/FrameState.java	Thu Apr 17 23:41:00 2014 +0200
+++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/FrameState.java	Thu Apr 17 15:32:57 2014 -0700
@@ -54,31 +54,37 @@
     /**
      * This BCI should be used for frame states that are built for code with no meaningful BCI.
      */
-    public static final int UNKNOWN_BCI = -4;
+    public static final int UNKNOWN_BCI = -5;
+
+    /**
+     * The BCI for the exception unwind block, i.e., the block containing the {@link UnwindNode}.
+     * This block and node is synthetic and has no representation in bytecode.
+     */
+    public static final int UNWIND_BCI = -1;
 
     /**
      * When a node whose frame state has this BCI value is inlined, its frame state will be replaced
      * with the frame state before the inlined invoke node.
      */
-    public static final int BEFORE_BCI = -1;
+    public static final int BEFORE_BCI = -2;
 
     /**
      * When a node whose frame state has this BCI value is inlined, its frame state will be replaced
      * with the frame state {@linkplain Invoke#stateAfter() after} the inlined invoke node.
      */
-    public static final int AFTER_BCI = -2;
+    public static final int AFTER_BCI = -3;
 
     /**
      * When a node whose frame state has this BCI value is inlined, its frame state will be replaced
      * with the frame state at the exception edge of the inlined invoke node.
      */
-    public static final int AFTER_EXCEPTION_BCI = -3;
+    public static final int AFTER_EXCEPTION_BCI = -4;
 
     /**
      * This BCI should be used for frame states that cannot be the target of a deoptimization, like
      * snippet frame states.
      */
-    public static final int INVALID_FRAMESTATE_BCI = -5;
+    public static final int INVALID_FRAMESTATE_BCI = -6;
 
     @Input(InputType.State) private FrameState outerFrameState;