changeset 3038:cebfa0b55183

Fix a bug where we would deopt to a non pendingException Framestate inside a exception handler + some FrameState methods cleanups
author Gilles Duboscq <gilles.duboscq@oracle.com>
date Mon, 20 Jun 2011 18:41:26 +0200
parents 5f417a4a944a
children 546dc7e1b184
files graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/gen/LIRGenerator.java graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/ir/ExceptionEdgeInstruction.java graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/ir/Invoke.java graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/phases/GraphBuilderPhase.java graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/phases/InliningPhase.java graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/value/FrameState.java graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/value/FrameStateAccess.java graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/value/FrameStateBuilder.java src/share/tools/IdealGraphVisualizer/nbproject/project.properties
diffstat 9 files changed, 35 insertions(+), 45 deletions(-) [+]
line wrap: on
line diff
--- a/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/gen/LIRGenerator.java	Mon Jun 20 12:19:47 2011 +0200
+++ b/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/gen/LIRGenerator.java	Mon Jun 20 18:41:26 2011 +0200
@@ -443,7 +443,14 @@
     @Override
     public void visitExceptionObject(ExceptionObject x) {
         XirSnippet snippet = xir.genExceptionObject(site(x));
-        emitXir(snippet, x, stateFor(x), null, true);
+        emitXir(snippet, x, null, null, true);
+        lastState = lastState.duplicateWithException(lastState.bci, x);
+        if (GraalOptions.TraceLIRGeneratorLevel >= 2) {
+            TTY.println("STATE CHANGE (visitExceptionObject)");
+            if (GraalOptions.TraceLIRGeneratorLevel >= 3) {
+                TTY.println(lastState.toString());
+            }
+        }
     }
 
     @Override
--- a/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/ir/ExceptionEdgeInstruction.java	Mon Jun 20 12:19:47 2011 +0200
+++ b/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/ir/ExceptionEdgeInstruction.java	Mon Jun 20 18:41:26 2011 +0200
@@ -24,5 +24,5 @@
 
 
 public interface ExceptionEdgeInstruction {
-    Instruction exceptionEdge();
+    FixedNode exceptionEdge();
 }
--- a/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/ir/Invoke.java	Mon Jun 20 12:19:47 2011 +0200
+++ b/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/ir/Invoke.java	Mon Jun 20 18:41:26 2011 +0200
@@ -72,12 +72,12 @@
      * The entry to the exception dispatch chain for this invoke.
      */
     @Override
-    public Instruction exceptionEdge() {
-        return (Instruction) successors().get(super.successorCount() + SUCCESSOR_EXCEPTION_EDGE);
+    public FixedNode exceptionEdge() {
+        return (FixedNode) successors().get(super.successorCount() + SUCCESSOR_EXCEPTION_EDGE);
     }
 
-    public Instruction setExceptionEdge(Instruction n) {
-        return (Instruction) successors().set(super.successorCount() + SUCCESSOR_EXCEPTION_EDGE, n);
+    public FixedNode setExceptionEdge(FixedNode n) {
+        return (FixedNode) successors().set(super.successorCount() + SUCCESSOR_EXCEPTION_EDGE, n);
     }
 
     public final int opcode;
--- a/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/phases/GraphBuilderPhase.java	Mon Jun 20 12:19:47 2011 +0200
+++ b/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/phases/GraphBuilderPhase.java	Mon Jun 20 18:41:26 2011 +0200
@@ -381,7 +381,7 @@
         return handler.catchTypeCPI() == 0;
     }
 
-    private Instruction handleException(Value exceptionObject, int bci) {
+    private FixedNode handleException(Value exceptionObject, int bci) {
         assert bci == Instruction.SYNCHRONIZATION_ENTRY_BCI || bci == bci() : "invalid bci";
 
         RiExceptionHandler firstHandler = null;
@@ -423,23 +423,22 @@
                     dispatchBlock = blockFromBci[handlerBCI];
                 }
             }
-            FrameState entryState = frameState.duplicateWithEmptyStack(bci);
 
-            StateSplit entry = new Placeholder(graph);
-            entry.setStateAfter(entryState);
-
-            Instruction currentNext = entry;
-            Value currentExceptionObject = exceptionObject;
-            if (currentExceptionObject == null) {
-                ExceptionObject exception = new ExceptionObject(graph);
-                entry.setNext(exception);
-                currentNext = exception;
-                currentExceptionObject = exception;
+            Value currentExceptionObject;
+            if (exceptionObject == null) {
+                currentExceptionObject = new ExceptionObject(graph);
+            } else {
+                currentExceptionObject = exceptionObject;
             }
-            FrameState stateWithException = entryState.duplicateWithException(bci, currentExceptionObject);
-
-            currentNext.setNext(createTarget(dispatchBlock, stateWithException));
-            return entry;
+            FrameState stateWithException = frameState.duplicateWithException(bci, currentExceptionObject);
+            FixedNode target = createTarget(dispatchBlock, stateWithException);
+            if (exceptionObject == null) {
+                ExceptionObject eObj = (ExceptionObject) currentExceptionObject;
+                eObj.setNext(target);
+                return eObj;
+            } else {
+                return target;
+            }
         }
         return null;
     }
@@ -713,7 +712,7 @@
         node.setNode(new IsNonNull(exception, graph));
         append(node);
 
-        Instruction entry = handleException(exception, bci);
+        FixedNode entry = handleException(exception, bci);
         if (entry != null) {
             append(entry);
         } else {
--- a/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/phases/InliningPhase.java	Mon Jun 20 12:19:47 2011 +0200
+++ b/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/phases/InliningPhase.java	Mon Jun 20 18:41:26 2011 +0200
@@ -278,7 +278,7 @@
 
     private void inlineMethod(Invoke invoke, RiMethod method) {
         FrameState stateAfter = invoke.stateAfter();
-        Instruction exceptionEdge = invoke.exceptionEdge();
+        FixedNode exceptionEdge = invoke.exceptionEdge();
 
         CompilerGraph graph;
         Object stored = GraphBuilderPhase.cachedGraphs.get(method);
--- a/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/value/FrameState.java	Mon Jun 20 12:19:47 2011 +0200
+++ b/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/value/FrameState.java	Mon Jun 20 18:41:26 2011 +0200
@@ -130,22 +130,7 @@
         return other;
     }
 
-    /**
-     * Gets a copy of this frame state without the stack.
-     */
     @Override
-    public FrameState duplicateWithEmptyStack(int bci) {
-        FrameState other = new FrameState(method, bci, localsSize, 0, locksSize(), rethrowException, graph());
-        for (int i = 0; i < localsSize; i++) {
-            other.setValueAt(i, localAt(i));
-        }
-        for (int i = 0; i < locksSize; i++) {
-            other.setValueAt(localsSize + i, lockAt(i));
-        }
-        other.setOuterFrameState(outerFrameState());
-        return other;
-    }
-
     public FrameState duplicateWithException(int bci, Value exceptionObject) {
         return duplicateModified(bci, true, CiKind.Void, exceptionObject);
     }
--- a/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/value/FrameStateAccess.java	Mon Jun 20 12:19:47 2011 +0200
+++ b/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/value/FrameStateAccess.java	Mon Jun 20 18:41:26 2011 +0200
@@ -42,10 +42,10 @@
 
     Value stackAt(int i);
 
-    FrameState duplicateWithEmptyStack(int bci);
-
     void setValueAt(int j, Value v);
 
     Value outerFrameState();
 
+    FrameState duplicateWithException(int bci, Value exceptionObject);
+
 }
--- a/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/value/FrameStateBuilder.java	Mon Jun 20 12:19:47 2011 +0200
+++ b/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/value/FrameStateBuilder.java	Mon Jun 20 18:41:26 2011 +0200
@@ -107,9 +107,8 @@
         return new FrameState(method, bci, locals, stack, stackIndex, locks, false, graph);
     }
 
-    @Override
-    public FrameState duplicateWithEmptyStack(int bci) {
-        FrameState frameState = new FrameState(method, bci, locals, new Value[0], 0, locks, false, graph);
+    public FrameState duplicateWithException(int bci, Value exceptionObject) {
+        FrameState frameState = new FrameState(method, bci, locals, new Value[]{exceptionObject}, 1, locks, true, graph);
         frameState.setOuterFrameState(outerFrameState());
         return frameState;
     }
--- a/src/share/tools/IdealGraphVisualizer/nbproject/project.properties	Mon Jun 20 12:19:47 2011 +0200
+++ b/src/share/tools/IdealGraphVisualizer/nbproject/project.properties	Mon Jun 20 18:41:26 2011 +0200
@@ -54,4 +54,4 @@
 project.com.sun.hotspot.igv.view=View
 project.com.sun.hotspot.igv.util=Util
 project.test=module1
-run.args = -J-client -J-Xms128m -J-Xmx512m -J-ea
+run.args = -J-client -J-Xms128m -J-Xmx1g -J-ea