# HG changeset patch # User Gilles Duboscq # Date 1363887958 -3600 # Node ID 21bf57680185acdacb1d28499a25f378cb2698d3 # Parent 2d0160c35f8f115e1f8f841d988b8bf675a773a1 Fuse the ExceptionObject its DispatchBegin into a single node since it has to be atomic while gurads are floating diff -r 2d0160c35f8f -r 21bf57680185 graal/com.oracle.graal.java/src/com/oracle/graal/java/GraphBuilderPhase.java --- a/graal/com.oracle.graal.java/src/com/oracle/graal/java/GraphBuilderPhase.java Fri Mar 22 13:18:12 2013 +0100 +++ b/graal/com.oracle.graal.java/src/com/oracle/graal/java/GraphBuilderPhase.java Thu Mar 21 18:45:58 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; } @@ -1128,7 +1123,7 @@ frameState.pushReturn(resultType, result); } 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); diff -r 2d0160c35f8f -r 21bf57680185 graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/BeginNode.java --- a/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/BeginNode.java Fri Mar 22 13:18:12 2013 +0100 +++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/BeginNode.java Thu Mar 21 18:45:58 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; diff -r 2d0160c35f8f -r 21bf57680185 graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/BeginStateSplitNode.java --- a/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/BeginStateSplitNode.java Fri Mar 22 13:18:12 2013 +0100 +++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/BeginStateSplitNode.java Thu Mar 21 18:45:58 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. */ diff -r 2d0160c35f8f -r 21bf57680185 graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/DispatchBeginNode.java --- a/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/DispatchBeginNode.java Fri Mar 22 13:18:12 2013 +0100 +++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/DispatchBeginNode.java Thu Mar 21 18:45:58 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); + } } diff -r 2d0160c35f8f -r 21bf57680185 graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/InvokeWithExceptionNode.java --- a/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/InvokeWithExceptionNode.java Fri Mar 22 13:18:12 2013 +0100 +++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/InvokeWithExceptionNode.java Thu Mar 21 18:45:58 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; } diff -r 2d0160c35f8f -r 21bf57680185 graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/cfg/Block.java --- a/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/cfg/Block.java Fri Mar 22 13:18:12 2013 +0100 +++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/cfg/Block.java Thu Mar 21 18:45:58 2013 +0100 @@ -79,7 +79,7 @@ } public boolean isExceptionEntry() { - return getBeginNode().next() instanceof ExceptionObjectNode; + return getBeginNode() instanceof ExceptionObjectNode; } public Block getFirstPredecessor() { diff -r 2d0160c35f8f -r 21bf57680185 graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/java/ExceptionObjectNode.java --- a/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/java/ExceptionObjectNode.java Fri Mar 22 13:18:12 2013 +0100 +++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/java/ExceptionObjectNode.java Thu Mar 21 18:45:58 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(); diff -r 2d0160c35f8f -r 21bf57680185 graal/com.oracle.graal.phases.common/src/com/oracle/graal/phases/common/ConvertDeoptimizeToGuardPhase.java --- a/graal/com.oracle.graal.phases.common/src/com/oracle/graal/phases/common/ConvertDeoptimizeToGuardPhase.java Fri Mar 22 13:18:12 2013 +0100 +++ b/graal/com.oracle.graal.phases.common/src/com/oracle/graal/phases/common/ConvertDeoptimizeToGuardPhase.java Thu Mar 21 18:45:58 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); diff -r 2d0160c35f8f -r 21bf57680185 graal/com.oracle.graal.phases.common/src/com/oracle/graal/phases/common/InliningUtil.java --- a/graal/com.oracle.graal.phases.common/src/com/oracle/graal/phases/common/InliningUtil.java Fri Mar 22 13:18:12 2013 +0100 +++ b/graal/com.oracle.graal.phases.common/src/com/oracle/graal/phases/common/InliningUtil.java Thu Mar 21 18:45:58 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());