use of jdk.vm.ci.meta.JavaKind in project graal by oracle.
the class ReturnNode method verifyReturn.
private boolean verifyReturn(TargetDescription target) {
if (graph().method() != null) {
JavaKind actual = result == null ? JavaKind.Void : result.getStackKind();
JavaKind expected = graph().method().getSignature().getReturnKind().getStackKind();
if (actual == target.wordJavaKind && expected == JavaKind.Object) {
// OK, we're compiling a snippet that returns a Word
return true;
}
assert actual == expected : "return kind doesn't match: actual " + actual + ", expected: " + expected;
}
return true;
}
use of jdk.vm.ci.meta.JavaKind in project graal by oracle.
the class InliningUtil method handleAfterBciFrameState.
private static FrameState handleAfterBciFrameState(FrameState frameState, Invoke invoke, boolean alwaysDuplicateStateAfter) {
FrameState stateAtReturn = invoke.stateAfter();
JavaKind invokeReturnKind = invoke.asNode().getStackKind();
FrameState stateAfterReturn = stateAtReturn;
if (frameState.getCode() == null) {
// that was parsed for post-parse intrinsification
for (Node usage : frameState.usages()) {
if (usage instanceof ForeignCallNode) {
// A foreign call inside an intrinsic needs to have
// the BCI of the invoke being intrinsified
ForeignCallNode foreign = (ForeignCallNode) usage;
foreign.setBci(invoke.bci());
}
}
}
// value (top of stack)
assert !frameState.rethrowException() : frameState;
if (frameState.stackSize() > 0 && (alwaysDuplicateStateAfter || stateAfterReturn.stackAt(0) != frameState.stackAt(0))) {
// A non-void return value.
stateAfterReturn = stateAtReturn.duplicateModified(invokeReturnKind, invokeReturnKind, frameState.stackAt(0));
} else {
// A void return value.
stateAfterReturn = stateAtReturn.duplicate();
}
assert stateAfterReturn.bci != BytecodeFrame.UNKNOWN_BCI;
// Return value does no longer need to be limited by the monitor exit.
for (MonitorExitNode n : frameState.usages().filter(MonitorExitNode.class)) {
n.clearEscapedReturnValue();
}
frameState.replaceAndDelete(stateAfterReturn);
return stateAfterReturn;
}
use of jdk.vm.ci.meta.JavaKind in project graal by oracle.
the class InliningUtil method processFrameStates.
protected static void processFrameStates(Invoke invoke, StructuredGraph inlineGraph, EconomicMap<Node, Node> duplicates, FrameState stateAtExceptionEdge, boolean alwaysDuplicateStateAfter) {
FrameState stateAtReturn = invoke.stateAfter();
FrameState outerFrameState = null;
JavaKind invokeReturnKind = invoke.asNode().getStackKind();
EconomicMap<Node, Node> replacements = EconomicMap.create();
for (FrameState original : inlineGraph.getNodes(FrameState.TYPE)) {
FrameState frameState = (FrameState) duplicates.get(original);
if (frameState != null && frameState.isAlive()) {
if (outerFrameState == null) {
outerFrameState = stateAtReturn.duplicateModifiedDuringCall(invoke.bci(), invokeReturnKind);
}
processFrameState(frameState, invoke, replacements, inlineGraph.method(), stateAtExceptionEdge, outerFrameState, alwaysDuplicateStateAfter, invoke.callTarget().targetMethod(), invoke.callTarget().arguments());
}
}
// If processing the frame states replaced any nodes, update the duplicates map.
duplicates.replaceAll((key, value) -> replacements.containsKey(value) ? replacements.get(value) : value);
}
use of jdk.vm.ci.meta.JavaKind in project graal by oracle.
the class InliningUtil method processFrameState.
public static FrameState processFrameState(FrameState frameState, Invoke invoke, EconomicMap<Node, Node> replacements, ResolvedJavaMethod inlinedMethod, FrameState stateAtExceptionEdge, FrameState outerFrameState, boolean alwaysDuplicateStateAfter, ResolvedJavaMethod invokeTargetMethod, List<ValueNode> invokeArgsList) {
assert outerFrameState == null || !outerFrameState.isDeleted() : outerFrameState;
final FrameState stateAtReturn = invoke.stateAfter();
JavaKind invokeReturnKind = invoke.asNode().getStackKind();
if (frameState.bci == BytecodeFrame.AFTER_BCI) {
return handleAfterBciFrameState(frameState, invoke, alwaysDuplicateStateAfter);
} else if (stateAtExceptionEdge != null && isStateAfterException(frameState)) {
// pop exception object from invoke's stateAfter and replace with this frameState's
// exception object (top of stack)
FrameState stateAfterException = stateAtExceptionEdge;
if (frameState.stackSize() > 0 && stateAtExceptionEdge.stackAt(0) != frameState.stackAt(0)) {
stateAfterException = stateAtExceptionEdge.duplicateModified(JavaKind.Object, JavaKind.Object, frameState.stackAt(0));
}
frameState.replaceAndDelete(stateAfterException);
return stateAfterException;
} else if ((frameState.bci == BytecodeFrame.UNWIND_BCI && frameState.graph().getGuardsStage() == GuardsStage.FLOATING_GUARDS) || frameState.bci == BytecodeFrame.AFTER_EXCEPTION_BCI) {
/*
* This path converts the frame states relevant for exception unwinding to
* deoptimization. This is only allowed in configurations when Graal compiles code for
* speculative execution (e.g., JIT compilation in HotSpot) but not when compiled code
* must be deoptimization free (e.g., AOT compilation for native image generation).
* There is currently no global flag in StructuredGraph to distinguish such modes, but
* the GuardsStage during inlining indicates the mode in which Graal operates.
*/
handleMissingAfterExceptionFrameState(frameState, invoke, replacements, alwaysDuplicateStateAfter);
return frameState;
} else if (frameState.bci == BytecodeFrame.BEFORE_BCI) {
// must re-execute the intrinsified invocation
assert frameState.outerFrameState() == null;
ValueNode[] invokeArgs = invokeArgsList.isEmpty() ? NO_ARGS : invokeArgsList.toArray(new ValueNode[invokeArgsList.size()]);
FrameState stateBeforeCall = stateAtReturn.duplicateModifiedBeforeCall(invoke.bci(), invokeReturnKind, invokeTargetMethod.getSignature().toParameterKinds(!invokeTargetMethod.isStatic()), invokeArgs);
frameState.replaceAndDelete(stateBeforeCall);
return stateBeforeCall;
} else {
// only handle the outermost frame states
if (frameState.outerFrameState() == null) {
assert checkInlineeFrameState(invoke, inlinedMethod, frameState);
frameState.setOuterFrameState(outerFrameState);
}
return frameState;
}
}
use of jdk.vm.ci.meta.JavaKind in project graal by oracle.
the class MultiTypeGuardInlineInfo method duplicateInvokeForInlining.
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;
}
Aggregations