@Override public void lower(LoweringTool tool) { if (graph().getGuardsStage() == StructuredGraph.GuardsStage.FIXED_DEOPTS) { /* * Now the lowering to BeginNode+LoadExceptionNode can be performed, since no more * deopts can float in between the begin node and the load exception node. */ LocationIdentity locationsKilledByInvoke = ((InvokeWithExceptionNode) predecessor()).getLocationIdentity(); AbstractBeginNode entry = graph().add(KillingBeginNode.create(locationsKilledByInvoke)); LoadExceptionObjectNode loadException = graph().add(new LoadExceptionObjectNode(stamp(NodeView.DEFAULT))); loadException.setStateAfter(stateAfter()); replaceAtUsages(InputType.Value, loadException); graph().replaceFixedWithFixed(this, entry); entry.graph().addAfterFixed(entry, loadException); loadException.lower(tool); } }
@Override public boolean verify() { assertTrue(stateAfter() != null, "an exception handler needs a frame state"); assertTrue(stateAfter().stackSize() == 1 && stateAfter().stackAt(0).stamp(NodeView.DEFAULT).getStackKind() == JavaKind.Object, "an exception handler's frame state must have only the exception on the stack"); return super.verify(); } }
assert invokeWithException.exceptionEdge().successors().count() == 1; ExceptionObjectNode obj = (ExceptionObjectNode) invokeWithException.exceptionEdge(); obj.replaceAtUsages(unwindNode.exception()); Node n = obj.next(); obj.setNext(null); unwindNode.replaceAndDelete(n); obj.replaceAtPredecessor(null); obj.safeDelete(); } else { invokeWithException.killExceptionEdge();
FixedNode exceptionSux = exceptionEdge.next(); graph.addBeforeFixed(exceptionSux, exceptionMerge); exceptionObjectPhi = graph.addWithoutUnique(new ValuePhiNode(StampFactory.forKind(JavaKind.Object), exceptionMerge)); exceptionMerge.setStateAfter(exceptionEdge.stateAfter().duplicateModified(invoke.stateAfter().bci, true, JavaKind.Object, new JavaKind[]{JavaKind.Object}, new ValueNode[]{exceptionObjectPhi})); InvokeWithExceptionNode invokeWithExceptionNode = (InvokeWithExceptionNode) invoke; ExceptionObjectNode exceptionEdge = (ExceptionObjectNode) invokeWithExceptionNode.exceptionEdge(); exceptionEdge.replaceAtUsages(exceptionObjectPhi); exceptionEdge.setNext(null); GraphUtil.killCFG(invokeWithExceptionNode.exceptionEdge());
private static Invoke duplicateInvokeForInlining(StructuredGraph graph, Invoke invoke, AbstractMergeNode exceptionMerge, PhiNode exceptionObjectPhi, boolean useForInlining) { Invoke result = (Invoke) invoke.asNode().copyWithInputs(); Node callTarget = result.callTarget().copyWithInputs(); result.asNode().replaceFirstInput(result.callTarget(), callTarget); result.setUseForInlining(useForInlining); JavaKind kind = invoke.asNode().getStackKind(); if (kind != JavaKind.Void) { FrameState stateAfter = invoke.stateAfter(); stateAfter = stateAfter.duplicate(stateAfter.bci); stateAfter.replaceFirstInput(invoke.asNode(), result.asNode()); result.setStateAfter(stateAfter); } if (invoke instanceof InvokeWithExceptionNode) { assert exceptionMerge != null && exceptionObjectPhi != null; InvokeWithExceptionNode invokeWithException = (InvokeWithExceptionNode) invoke; ExceptionObjectNode exceptionEdge = (ExceptionObjectNode) invokeWithException.exceptionEdge(); FrameState stateAfterException = exceptionEdge.stateAfter(); ExceptionObjectNode newExceptionEdge = (ExceptionObjectNode) exceptionEdge.copyWithInputs(); // set new state (pop old exception object, push new one) newExceptionEdge.setStateAfter(stateAfterException.duplicateModified(JavaKind.Object, JavaKind.Object, newExceptionEdge)); EndNode endNode = graph.add(new EndNode()); newExceptionEdge.setNext(endNode); exceptionMerge.addForwardEnd(endNode); exceptionObjectPhi.addInput(newExceptionEdge); ((InvokeWithExceptionNode) result).setExceptionEdge(newExceptionEdge); } return result; }
writeOrderId(exceptionEdge.stateAfter(), nodeOrder); writeOrderId(exceptionEdge.next(), nodeOrder);
ExceptionObjectNode newExceptionObject = graph.add(new ExceptionObjectNode(metaAccess)); dispatchBegin = newExceptionObject; dispatchState.push(JavaKind.Object, dispatchBegin); dispatchState.setRethrowException(true); newExceptionObject.setStateAfter(dispatchState.create(bci, newExceptionObject)); } else { dispatchBegin = graph.add(new BeginNode());
} else if (instr instanceof ExceptionObjectNode && getMethod().compilationInfo.isDeoptEntry(((ExceptionObjectNode) instr).stateAfter().bci, true, false)) {
@Override @SuppressWarnings("deprecation") protected void run(StructuredGraph graph) { for (Node n : graph.getNodes()) { if (n instanceof InvokeWithExceptionNode) { InvokeWithExceptionNode invoke = (InvokeWithExceptionNode) n; ExceptionObjectNode exceptionObject = (ExceptionObjectNode) invoke.exceptionEdge(); FixedNode originalNext = exceptionObject.next(); if (!(originalNext instanceof DeoptimizeNode) && invoke.callTarget().targetMethod() != null) { TruffleBoundary truffleBoundary = invoke.callTarget().targetMethod().getAnnotation(TruffleBoundary.class); if (truffleBoundary != null) { if (!truffleBoundary.throwsControlFlowException() && truffleBoundary.transferToInterpreterOnException()) { addDeoptimizeNode(graph, originalNext); } } } } } }
public InvokeWithExceptionNode startInvokeWithException(MethodCallTargetNode callTarget, FrameStateBuilder frameStateBuilder, int invokeBci, int exceptionEdgeBci) { ExceptionObjectNode exceptionObject = add(new ExceptionObjectNode(getMetaAccess())); if (frameStateBuilder != null) { FrameStateBuilder exceptionState = frameStateBuilder.copy(); exceptionState.clearStack(); exceptionState.push(JavaKind.Object, exceptionObject); exceptionState.setRethrowException(false); exceptionObject.setStateAfter(exceptionState.create(exceptionEdgeBci, exceptionObject)); } InvokeWithExceptionNode invoke = append(new InvokeWithExceptionNode(callTarget, exceptionObject, invokeBci)); AbstractBeginNode noExceptionEdge = graph.add(KillingBeginNode.create(LocationIdentity.any())); invoke.setNext(noExceptionEdge); if (frameStateBuilder != null) { if (invoke.getStackKind() != JavaKind.Void) { frameStateBuilder.push(invoke.getStackKind(), invoke); } invoke.setStateAfter(frameStateBuilder.create(invokeBci, invoke)); if (invoke.getStackKind() != JavaKind.Void) { frameStateBuilder.pop(invoke.getStackKind()); } } lastFixedNode = null; InvokeWithExceptionStructure s = new InvokeWithExceptionStructure(); s.state = InvokeWithExceptionStructure.State.INVOKE; s.noExceptionEdge = noExceptionEdge; s.exceptionEdge = exceptionObject; s.exceptionObject = exceptionObject; pushStructure(s); return invoke; }
if (unwindNode != null) { ExceptionObjectNode obj = (ExceptionObjectNode) invokeWithException.exceptionEdge(); stateAtExceptionEdge = obj.stateAfter();