changeset 8448:71a9f3a5d8c5

Merge.
author Doug Simon <doug.simon@oracle.com>
date Fri, 22 Mar 2013 18:18:55 +0100
parents b6b9ab1fde62 3e85441907de
children 7485b8a7cd24
files graal/com.oracle.graal.java/src/com/oracle/graal/java/GraphBuilderPhase.java
diffstat 10 files changed, 69 insertions(+), 48 deletions(-) [+]
line wrap: on
line diff
--- a/graal/com.oracle.graal.java/src/com/oracle/graal/java/GraphBuilderPhase.java	Fri Mar 22 15:20:16 2013 +0100
+++ b/graal/com.oracle.graal.java/src/com/oracle/graal/java/GraphBuilderPhase.java	Fri Mar 22 18:18:55 2013 +0100
@@ -385,25 +385,20 @@
         FrameStateBuilder dispatchState = frameState.copy();
         dispatchState.clearStack();
 
-        DispatchBeginNode dispatchBegin = currentGraph.add(new DispatchBeginNode());
-        dispatchBegin.setStateAfter(dispatchState.create(bci));
-
+        DispatchBeginNode dispatchBegin;
         if (exceptionObject == null) {
-            ExceptionObjectNode newExceptionObject = currentGraph.add(new ExceptionObjectNode(runtime));
-            dispatchState.apush(newExceptionObject);
+            dispatchBegin = currentGraph.add(new ExceptionObjectNode(runtime));
+            dispatchState.apush(dispatchBegin);
             dispatchState.setRethrowException(true);
-            newExceptionObject.setStateAfter(dispatchState.create(bci));
-
-            FixedNode target = createTarget(dispatchBlock, dispatchState);
-            dispatchBegin.setNext(newExceptionObject);
-            newExceptionObject.setNext(target);
+            dispatchBegin.setStateAfter(dispatchState.create(bci));
         } else {
+            dispatchBegin = currentGraph.add(new DispatchBeginNode());
+            dispatchBegin.setStateAfter(dispatchState.create(bci));
             dispatchState.apush(exceptionObject);
             dispatchState.setRethrowException(true);
-
-            FixedNode target = createTarget(dispatchBlock, dispatchState);
-            dispatchBegin.setNext(target);
         }
+        FixedNode target = createTarget(dispatchBlock, dispatchState);
+        dispatchBegin.setNext(target);
         return dispatchBegin;
     }
 
@@ -1121,14 +1116,19 @@
             returnType = returnType.resolve(targetMethod.getDeclaringClass());
         }
         MethodCallTargetNode callTarget = currentGraph.add(new MethodCallTargetNode(invokeKind, targetMethod, args, returnType));
+        createInvokeNode(callTarget, resultType);
+    }
+
+    protected Invoke createInvokeNode(MethodCallTargetNode callTarget, Kind resultType) {
         // be conservative if information was not recorded (could result in endless recompiles
         // otherwise)
         if (graphBuilderConfig.omitAllExceptionEdges() || (optimisticOpts.useExceptionProbability() && profilingInfo.getExceptionSeen(bci()) == ExceptionSeen.FALSE)) {
-            ValueNode result = appendWithBCI(currentGraph.add(new InvokeNode(callTarget, bci())));
+            InvokeNode invoke = new InvokeNode(callTarget, bci());
+            ValueNode result = appendWithBCI(currentGraph.add(invoke));
             frameState.pushReturn(resultType, result);
-
+            return invoke;
         } else {
-            DispatchBeginNode exceptionEdge = handleException(null, bci());
+            ExceptionObjectNode exceptionEdge = (ExceptionObjectNode) handleException(null, bci());
             InvokeWithExceptionNode invoke = currentGraph.add(new InvokeWithExceptionNode(callTarget, exceptionEdge, bci()));
             ValueNode result = append(invoke);
             frameState.pushReturn(resultType, result);
@@ -1139,6 +1139,7 @@
 
             invoke.setNext(createTarget(nextBlock, frameState));
             invoke.setStateAfter(frameState.create(nextBlock.startBci));
+            return invoke;
         }
     }
 
--- a/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/BeginNode.java	Fri Mar 22 15:20:16 2013 +0100
+++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/BeginNode.java	Fri Mar 22 18:18:55 2013 +0100
@@ -53,6 +53,10 @@
         super(StampFactory.dependency());
     }
 
+    protected BeginNode(Stamp stamp) {
+        super(stamp);
+    }
+
     public static BeginNode begin(FixedNode with) {
         if (with instanceof BeginNode) {
             return (BeginNode) with;
--- a/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/BeginStateSplitNode.java	Fri Mar 22 15:20:16 2013 +0100
+++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/BeginStateSplitNode.java	Fri Mar 22 18:18:55 2013 +0100
@@ -22,6 +22,8 @@
  */
 package com.oracle.graal.nodes;
 
+import com.oracle.graal.nodes.type.*;
+
 /**
  * Base class for {@link BeginNode}s that are associated with a frame state. TODO (dnsimon) this not
  * needed until {@link BeginNode} no longer implements {@link StateSplit} which is not possible
@@ -29,6 +31,13 @@
  */
 public abstract class BeginStateSplitNode extends BeginNode implements StateSplit {
 
+    public BeginStateSplitNode() {
+    }
+
+    protected BeginStateSplitNode(Stamp stamp) {
+        super(stamp);
+    }
+
     /**
      * A begin node has no side effect.
      */
--- a/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/DispatchBeginNode.java	Fri Mar 22 15:20:16 2013 +0100
+++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/DispatchBeginNode.java	Fri Mar 22 18:18:55 2013 +0100
@@ -22,9 +22,17 @@
  */
 package com.oracle.graal.nodes;
 
+import com.oracle.graal.nodes.type.*;
+
 /**
  * The entry node of an exception dispatcher block.
  */
 public class DispatchBeginNode extends BeginStateSplitNode {
 
+    public DispatchBeginNode() {
+    }
+
+    protected DispatchBeginNode(Stamp stamp) {
+        super(stamp);
+    }
 }
--- a/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/InvokeWithExceptionNode.java	Fri Mar 22 15:20:16 2013 +0100
+++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/InvokeWithExceptionNode.java	Fri Mar 22 18:18:55 2013 +0100
@@ -35,7 +35,7 @@
 public class InvokeWithExceptionNode extends ControlSplitNode implements Node.IterableNodeType, Invoke, MemoryCheckpoint, LIRLowerable {
 
     @Successor private BeginNode next;
-    @Successor private DispatchBeginNode exceptionEdge;
+    @Successor private ExceptionObjectNode exceptionEdge;
     @Input private final CallTargetNode callTarget;
     @Input private FrameState stateAfter;
     private final int bci;
@@ -43,7 +43,7 @@
     private boolean useForInlining;
     private double inliningRelevance;
 
-    public InvokeWithExceptionNode(CallTargetNode callTarget, DispatchBeginNode exceptionEdge, int bci) {
+    public InvokeWithExceptionNode(CallTargetNode callTarget, ExceptionObjectNode exceptionEdge, int bci) {
         super(callTarget.returnStamp());
         this.exceptionEdge = exceptionEdge;
         this.bci = bci;
@@ -53,11 +53,11 @@
         this.inliningRelevance = Double.NaN;
     }
 
-    public DispatchBeginNode exceptionEdge() {
+    public ExceptionObjectNode exceptionEdge() {
         return exceptionEdge;
     }
 
-    public void setExceptionEdge(DispatchBeginNode x) {
+    public void setExceptionEdge(ExceptionObjectNode x) {
         updatePredecessor(exceptionEdge, x);
         exceptionEdge = x;
     }
--- a/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/cfg/Block.java	Fri Mar 22 15:20:16 2013 +0100
+++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/cfg/Block.java	Fri Mar 22 18:18:55 2013 +0100
@@ -79,7 +79,7 @@
     }
 
     public boolean isExceptionEntry() {
-        return getBeginNode().next() instanceof ExceptionObjectNode;
+        return getBeginNode() instanceof ExceptionObjectNode;
     }
 
     public Block getFirstPredecessor() {
--- a/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/java/ExceptionObjectNode.java	Fri Mar 22 15:20:16 2013 +0100
+++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/java/ExceptionObjectNode.java	Fri Mar 22 18:18:55 2013 +0100
@@ -32,7 +32,7 @@
  * The {@code ExceptionObject} instruction represents the incoming exception object to an exception
  * handler.
  */
-public class ExceptionObjectNode extends AbstractStateSplit implements StateSplit, Lowerable, LIRLowerable, MemoryCheckpoint {
+public class ExceptionObjectNode extends DispatchBeginNode implements Lowerable, LIRLowerable, MemoryCheckpoint {
 
     /**
      * Constructs a new ExceptionObject instruction.
@@ -57,6 +57,11 @@
     }
 
     @Override
+    public void simplify(SimplifierTool tool) {
+        //
+    }
+
+    @Override
     public boolean verify() {
         assertTrue(stateAfter() != null, "an exception handler needs a frame state");
         return super.verify();
--- a/graal/com.oracle.graal.phases.common/src/com/oracle/graal/phases/common/ConvertDeoptimizeToGuardPhase.java	Fri Mar 22 15:20:16 2013 +0100
+++ b/graal/com.oracle.graal.phases.common/src/com/oracle/graal/phases/common/ConvertDeoptimizeToGuardPhase.java	Fri Mar 22 18:18:55 2013 +0100
@@ -99,10 +99,6 @@
         // We could not convert the control split - at least cut off control flow after the split.
         FixedWithNextNode deoptPred = deoptBegin;
         FixedNode next = deoptPred.next();
-        if (next instanceof ExceptionObjectNode) {
-            deoptPred = (FixedWithNextNode) next;
-            next = deoptPred.next();
-        }
 
         if (next != deopt) {
             DeoptimizeNode newDeoptNode = (DeoptimizeNode) deopt.clone(graph);
--- a/graal/com.oracle.graal.phases.common/src/com/oracle/graal/phases/common/InliningUtil.java	Fri Mar 22 15:20:16 2013 +0100
+++ b/graal/com.oracle.graal.phases.common/src/com/oracle/graal/phases/common/InliningUtil.java	Fri Mar 22 18:18:55 2013 +0100
@@ -448,13 +448,12 @@
             PhiNode exceptionObjectPhi = null;
             if (invoke instanceof InvokeWithExceptionNode) {
                 InvokeWithExceptionNode invokeWithException = (InvokeWithExceptionNode) invoke;
-                DispatchBeginNode exceptionEdge = invokeWithException.exceptionEdge();
-                ExceptionObjectNode exceptionObject = (ExceptionObjectNode) exceptionEdge.next();
+                ExceptionObjectNode exceptionEdge = invokeWithException.exceptionEdge();
 
                 exceptionMerge = graph.add(new MergeNode());
                 exceptionMerge.setProbability(exceptionEdge.probability());
 
-                FixedNode exceptionSux = exceptionObject.next();
+                FixedNode exceptionSux = exceptionEdge.next();
                 graph.addBeforeFixed(exceptionSux, exceptionMerge);
                 exceptionObjectPhi = graph.unique(new PhiNode(Kind.Object, exceptionMerge));
                 exceptionMerge.setStateAfter(exceptionEdge.stateAfter().duplicateModified(invoke.stateAfter().bci, true, Kind.Void, exceptionObjectPhi));
@@ -485,10 +484,9 @@
             // replace the invoke exception edge
             if (invoke instanceof InvokeWithExceptionNode) {
                 InvokeWithExceptionNode invokeWithExceptionNode = (InvokeWithExceptionNode) invoke;
-                BeginNode exceptionEdge = invokeWithExceptionNode.exceptionEdge();
-                ExceptionObjectNode exceptionObject = (ExceptionObjectNode) exceptionEdge.next();
-                exceptionObject.replaceAtUsages(exceptionObjectPhi);
-                exceptionObject.setNext(null);
+                ExceptionObjectNode exceptionEdge = invokeWithExceptionNode.exceptionEdge();
+                exceptionEdge.replaceAtUsages(exceptionObjectPhi);
+                exceptionEdge.setNext(null);
                 GraphUtil.killCFG(invokeWithExceptionNode.exceptionEdge());
             }
 
@@ -658,20 +656,17 @@
                 assert exceptionMerge != null && exceptionObjectPhi != null;
 
                 InvokeWithExceptionNode invokeWithException = (InvokeWithExceptionNode) invoke;
-                DispatchBeginNode exceptionEdge = invokeWithException.exceptionEdge();
-                ExceptionObjectNode exceptionObject = (ExceptionObjectNode) exceptionEdge.next();
-                FrameState stateAfterException = exceptionObject.stateAfter();
+                ExceptionObjectNode exceptionEdge = invokeWithException.exceptionEdge();
+                FrameState stateAfterException = exceptionEdge.stateAfter();
 
-                DispatchBeginNode newExceptionEdge = (DispatchBeginNode) exceptionEdge.copyWithInputs();
-                ExceptionObjectNode newExceptionObject = (ExceptionObjectNode) exceptionObject.copyWithInputs();
+                ExceptionObjectNode newExceptionEdge = (ExceptionObjectNode) exceptionEdge.copyWithInputs();
                 // set new state (pop old exception object, push new one)
-                newExceptionObject.setStateAfter(stateAfterException.duplicateModified(stateAfterException.bci, stateAfterException.rethrowException(), Kind.Object, newExceptionObject));
-                newExceptionEdge.setNext(newExceptionObject);
+                newExceptionEdge.setStateAfter(stateAfterException.duplicateModified(stateAfterException.bci, stateAfterException.rethrowException(), Kind.Object, newExceptionEdge));
 
                 EndNode endNode = graph.add(new EndNode());
-                newExceptionObject.setNext(endNode);
+                newExceptionEdge.setNext(endNode);
                 exceptionMerge.addForwardEnd(endNode);
-                exceptionObjectPhi.addInput(newExceptionObject);
+                exceptionObjectPhi.addInput(newExceptionEdge);
 
                 ((InvokeWithExceptionNode) result).setExceptionEdge(newExceptionEdge);
             }
@@ -1068,7 +1063,7 @@
             if (unwindNode != null) {
                 assert unwindNode.predecessor() != null;
                 assert invokeWithException.exceptionEdge().successors().count() == 1;
-                ExceptionObjectNode obj = (ExceptionObjectNode) invokeWithException.exceptionEdge().next();
+                ExceptionObjectNode obj = invokeWithException.exceptionEdge();
                 stateAtExceptionEdge = obj.stateAfter();
                 UnwindNode unwindDuplicate = (UnwindNode) duplicates.get(unwindNode);
                 obj.replaceAtUsages(unwindDuplicate.exception());
--- a/graal/com.oracle.graal.replacements.verifier/src/com/oracle/graal/replacements/verifier/ClassSubstitutionVerifier.java	Fri Mar 22 15:20:16 2013 +0100
+++ b/graal/com.oracle.graal.replacements.verifier/src/com/oracle/graal/replacements/verifier/ClassSubstitutionVerifier.java	Fri Mar 22 18:18:55 2013 +0100
@@ -71,16 +71,19 @@
         TypeMirror type = resolveAnnotationValue(TypeMirror.class, typeValue);
         String className = resolveAnnotationValue(String.class, stringValue);
         boolean optional = resolveAnnotationValue(Boolean.class, optionalValue);
-        if (!classSubstition.getAnnotationType().equals(type)) {
+
+        if (type.getKind() != TypeKind.DECLARED) {
+            env.getMessager().printMessage(Kind.ERROR, "The provided class must be a declared type.", sourceElement, classSubstition, typeValue);
+            return null;
+        }
+
+        if (!classSubstition.getAnnotationType().asElement().equals(((DeclaredType) type).asElement())) {
             if (!className.equals(STRING_VALUE_DEFAULT)) {
                 String msg = "The usage of value and className is exclusive.";
                 env.getMessager().printMessage(Kind.ERROR, msg, sourceElement, classSubstition, stringValue);
                 env.getMessager().printMessage(Kind.ERROR, msg, sourceElement, classSubstition, typeValue);
             }
-            if (type.getKind() != TypeKind.DECLARED) {
-                env.getMessager().printMessage(Kind.ERROR, "The provided class must be a declared type.", sourceElement, classSubstition, typeValue);
-                return null;
-            }
+
             return (TypeElement) ((DeclaredType) type).asElement();
         }