dispatchState.push(JavaKind.Object, dispatchBegin); dispatchState.setRethrowException(true); newExceptionObject.setStateAfter(dispatchState.create(bci, newExceptionObject)); } else { dispatchBegin = graph.add(new BeginNode());
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; }
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; }