changeset 22878:f564fd10b118

Allow subclasses of BytecodeParser to intercept customize exception dispatch
author Christian Wimmer <christian.wimmer@oracle.com>
date Fri, 23 Oct 2015 10:25:31 -0700
parents b4f50acabc27
children f34dbef209fd
files graal/com.oracle.graal.java/src/com/oracle/graal/java/BytecodeParser.java
diffstat 1 files changed, 22 insertions(+), 12 deletions(-) [+]
line wrap: on
line diff
--- a/graal/com.oracle.graal.java/src/com/oracle/graal/java/BytecodeParser.java	Thu Oct 22 11:52:54 2015 -0700
+++ b/graal/com.oracle.graal.java/src/com/oracle/graal/java/BytecodeParser.java	Fri Oct 23 10:25:31 2015 -0700
@@ -637,6 +637,10 @@
         }
     }
 
+    protected GraphBuilderPhase.Instance getGraphBuilderInstance() {
+        return graphBuilderInstance;
+    }
+
     public ValueNode getReturnValue() {
         return returnValue;
     }
@@ -1220,16 +1224,6 @@
         assert bci == BytecodeFrame.BEFORE_BCI || bci == bci() : "invalid bci";
         Debug.log("Creating exception dispatch edges at %d, exception object=%s, exception seen=%s", bci, exceptionObject, (profilingInfo == null ? "" : profilingInfo.getExceptionSeen(bci)));
 
-        BciBlock dispatchBlock = currentBlock.exceptionDispatchBlock();
-        /*
-         * The exception dispatch block is always for the last bytecode of a block, so if we are not
-         * at the endBci yet, there is no exception handler for this bci and we can unwind
-         * immediately.
-         */
-        if (bci != currentBlock.endBci || dispatchBlock == null) {
-            dispatchBlock = blockMap.getUnwindBlock();
-        }
-
         FrameStateBuilder dispatchState = frameState.copy();
         dispatchState.clearStack();
 
@@ -1246,10 +1240,26 @@
             dispatchBegin.setStateAfter(dispatchState.create(bci, dispatchBegin));
         }
         this.controlFlowSplit = true;
+        FixedWithNextNode finishedDispatch = finishInstruction(dispatchBegin, dispatchState);
+
+        createHandleExceptionTarget(finishedDispatch, bci, dispatchState);
+
+        return dispatchBegin;
+    }
+
+    protected void createHandleExceptionTarget(FixedWithNextNode finishedDispatch, int bci, FrameStateBuilder dispatchState) {
+        BciBlock dispatchBlock = currentBlock.exceptionDispatchBlock();
+        /*
+         * The exception dispatch block is always for the last bytecode of a block, so if we are not
+         * at the endBci yet, there is no exception handler for this bci and we can unwind
+         * immediately.
+         */
+        if (bci != currentBlock.endBci || dispatchBlock == null) {
+            dispatchBlock = blockMap.getUnwindBlock();
+        }
+
         FixedNode target = createTarget(dispatchBlock, dispatchState);
-        FixedWithNextNode finishedDispatch = finishInstruction(dispatchBegin, dispatchState);
         finishedDispatch.setNext(target);
-        return dispatchBegin;
     }
 
     protected ValueNode genLoadIndexed(ValueNode array, ValueNode index, JavaKind kind) {