diff graal/com.oracle.graal.java/src/com/oracle/graal/java/GraphBuilderPhase.java @ 19521:9c4168877444

Create CompilerAsserts tests. Add graph builder context on bailout. Consolidate CompilerAsserts Truffle API class.
author Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
date Fri, 20 Feb 2015 13:58:56 +0100
parents 387d7192e18f
children a9aa368f9068
line wrap: on
line diff
--- a/graal/com.oracle.graal.java/src/com/oracle/graal/java/GraphBuilderPhase.java	Fri Feb 20 01:15:31 2015 +0100
+++ b/graal/com.oracle.graal.java/src/com/oracle/graal/java/GraphBuilderPhase.java	Fri Feb 20 13:58:56 2015 +0100
@@ -1038,7 +1038,7 @@
 
                 synchronizedEpilogue(BytecodeFrame.AFTER_BCI, x);
                 if (frameState.lockDepth() != 0) {
-                    throw new BailoutException("unbalanced monitors");
+                    throw bailout("unbalanced monitors");
                 }
             }
 
@@ -1055,7 +1055,7 @@
                 MonitorIdNode monitorId = frameState.peekMonitorId();
                 ValueNode lockedObject = frameState.popLock();
                 if (GraphUtil.originalValue(lockedObject) != GraphUtil.originalValue(x)) {
-                    throw new BailoutException("unbalanced monitors: mismatch at monitorexit, %s != %s", GraphUtil.originalValue(x), GraphUtil.originalValue(lockedObject));
+                    throw bailout(String.format("unbalanced monitors: mismatch at monitorexit, %s != %s", GraphUtil.originalValue(x), GraphUtil.originalValue(lockedObject)));
                 }
                 MonitorExitNode monitorExit = append(new MonitorExitNode(x, monitorId, escapedReturnValue));
                 return monitorExit;
@@ -1377,7 +1377,7 @@
 
                 // We already saw this block before, so we have to merge states.
                 if (!((HIRFrameStateBuilder) getEntryState(block, operatingDimension)).isCompatibleWith(state)) {
-                    throw new BailoutException("stacks do not match; bytecodes would not verify");
+                    throw bailout("stacks do not match; bytecodes would not verify");
                 }
 
                 if (getFirstInstruction(block, operatingDimension) instanceof LoopBeginNode) {
@@ -1461,7 +1461,7 @@
                                 if (FailedLoopExplosionIsFatal.getValue()) {
                                     throw new RuntimeException(message);
                                 } else {
-                                    throw new BailoutException(message);
+                                    throw bailout(message);
                                 }
                             }
                         }
@@ -1962,6 +1962,13 @@
             public String toString() {
                 return method.format("%H.%n(%p)@") + bci();
             }
+
+            public BailoutException bailout(String string) {
+                FrameState currentFrameState = this.frameState.create(bci());
+                StackTraceElement[] elements = GraphUtil.approxSourceStackTraceElement(currentFrameState);
+                BailoutException bailout = new BailoutException(string);
+                throw GraphUtil.createBailoutException(string, bailout, elements);
+            }
         }
     }