use of com.oracle.svm.core.graal.nodes.DeoptEntryBeginNode in project graal by oracle.
the class HostedBciBlockMapping method insertDeoptNode.
/**
* Inserts either a DeoptEntryNode or DeoptProxyAnchorNode into the graph.
*/
private void insertDeoptNode(HostedBciBlockMapping.DeoptEntryInsertionPoint deopt) {
/* Ensuring current frameState matches the expectations of the DeoptEntryInsertionPoint. */
if (deopt instanceof HostedBciBlockMapping.DeoptBciBlock) {
assert !frameState.rethrowException();
} else {
assert deopt instanceof HostedBciBlockMapping.DeoptExceptionDispatchBlock;
assert frameState.rethrowException();
}
DeoptEntrySupport deoptNode = graph.add(deopt.isProxy() ? new DeoptProxyAnchorNode() : new DeoptEntryNode());
FrameState stateAfter = frameState.create(deopt.frameStateBci(), deoptNode);
deoptNode.setStateAfter(stateAfter);
if (lastInstr != null) {
lastInstr.setNext(deoptNode.asFixedNode());
}
if (deopt.isProxy()) {
lastInstr = (DeoptProxyAnchorNode) deoptNode;
} else {
assert !deopt.duringCall() : "Implicit deopt entries from invokes cannot have explicit deopt entries.";
DeoptEntryNode deoptEntryNode = (DeoptEntryNode) deoptNode;
deoptEntryNode.setNext(graph.add(new DeoptEntryBeginNode()));
/*
* DeoptEntries for positions not during an exception dispatch (rethrowException) also
* must be linked to their exception target.
*/
if (!deopt.rethrowException()) {
/*
* Saving frameState so that different modifications can be made for next() and
* exceptionEdge().
*/
FrameStateBuilder originalFrameState = frameState.copy();
/* Creating exception object and its state after. */
ExceptionObjectNode newExceptionObject = graph.add(new ExceptionObjectNode(getMetaAccess()));
frameState.clearStack();
frameState.push(JavaKind.Object, newExceptionObject);
frameState.setRethrowException(true);
int bci = ((HostedBciBlockMapping.DeoptBciBlock) deopt).getStartBci();
newExceptionObject.setStateAfter(frameState.create(bci, newExceptionObject));
deoptEntryNode.setExceptionEdge(newExceptionObject);
/* Inserting proxies for the exception edge. */
insertProxies(newExceptionObject, frameState);
/* Linking exception object to exception target. */
newExceptionObject.setNext(handleException(newExceptionObject, bci, false));
/* Now restoring FrameState so proxies can be inserted for the next() edge. */
frameState = originalFrameState;
} else {
/* Otherwise, indicate that the exception edge is not reachable. */
AbstractBeginNode newExceptionEdge = graph.add(new UnreachableBeginNode());
newExceptionEdge.setNext(graph.add(new LoweredDeadEndNode()));
deoptEntryNode.setExceptionEdge(newExceptionEdge);
}
/* Correctly setting last instruction. */
lastInstr = deoptEntryNode.next();
}
insertProxies(deoptNode.asFixedNode(), frameState);
}
Aggregations