use of org.graalvm.compiler.nodes.ReturnNode in project graal by oracle.
the class CEntryPointCallStubMethod method inlinePrologueAndEpilogue.
private static void inlinePrologueAndEpilogue(SubstrateGraphKit kit, InvokeNode prologueInvoke, InvokeNode epilogueInvoke, JavaKind returnKind) {
assert (prologueInvoke != null) == (epilogueInvoke != null);
if (prologueInvoke != null) {
kit.inline(prologueInvoke);
NodeIterable<CEntryPointPrologueBailoutNode> bailoutNodes = kit.getGraph().getNodes().filter(CEntryPointPrologueBailoutNode.class);
for (CEntryPointPrologueBailoutNode node : bailoutNodes) {
ValueNode result = node.getResult();
switch(returnKind) {
case Float:
assert result.getStackKind().isNumericFloat();
result = kit.unique(new FloatConvertNode(FloatConvert.D2F, result));
break;
case Byte:
case Char:
case Short:
case Int:
assert result.getStackKind().isNumericInteger();
result = kit.unique(new NarrowNode(result, returnKind.getBitCount()));
break;
default:
// no conversion necessary
break;
}
ReturnNode returnNode = kit.add(new ReturnNode(result));
node.replaceAndDelete(returnNode);
}
if (epilogueInvoke.isAlive()) {
kit.inline(epilogueInvoke);
}
}
}
use of org.graalvm.compiler.nodes.ReturnNode in project graal by oracle.
the class ProbabilityDirectiveTest method returnValue.
private static int returnValue(AbstractBeginNode b) {
ControlFlowAnchorNode anchor = (ControlFlowAnchorNode) b.next();
ReturnNode returnNode = (ReturnNode) anchor.next();
return returnNode.result().asJavaConstant().asInt();
}
use of org.graalvm.compiler.nodes.ReturnNode in project graal by oracle.
the class BytecodeParser method genReturn.
protected void genReturn(ValueNode returnVal, JavaKind returnKind) {
if (parsingIntrinsic() && returnVal != null) {
if (returnVal instanceof StateSplit) {
StateSplit stateSplit = (StateSplit) returnVal;
FrameState stateAfter = stateSplit.stateAfter();
if (stateSplit.hasSideEffect()) {
assert stateSplit != null;
if (stateAfter.bci == BytecodeFrame.AFTER_BCI) {
assert stateAfter.usages().count() == 1;
assert stateAfter.usages().first() == stateSplit;
stateAfter.replaceAtUsages(graph.add(new FrameState(BytecodeFrame.AFTER_BCI, returnVal)));
GraphUtil.killWithUnusedFloatingInputs(stateAfter);
} else {
/*
* This must be the return value from within a partial intrinsification.
*/
assert !BytecodeFrame.isPlaceholderBci(stateAfter.bci);
}
} else {
assert stateAfter == null;
}
}
}
ValueNode realReturnVal = processReturnValue(returnVal, returnKind);
frameState.setRethrowException(false);
frameState.clearStack();
beforeReturn(realReturnVal, returnKind);
if (parent == null) {
append(new ReturnNode(realReturnVal));
} else {
if (returnDataList == null) {
returnDataList = new ArrayList<>();
}
returnDataList.add(new ReturnToCallerData(realReturnVal, lastInstr));
lastInstr = null;
}
}
use of org.graalvm.compiler.nodes.ReturnNode in project graal by oracle.
the class MethodTypeFlow method computeReturnedParamter.
private ParameterNode computeReturnedParamter() {
if (graphRef == null) {
// Some methods, e.g., native ones, don't have a graph.
return null;
}
ParameterNode retParam = null;
for (ParameterNode param : graphRef.getNodes(ParameterNode.TYPE)) {
if (param.stamp(NodeView.DEFAULT) instanceof ObjectStamp) {
boolean returnsParameter = true;
NodeIterable<ReturnNode> retIterable = graphRef.getNodes(ReturnNode.TYPE);
returnsParameter &= retIterable.count() > 0;
for (ReturnNode ret : retIterable) {
returnsParameter &= ret.result() == param;
}
if (returnsParameter) {
retParam = param;
}
}
}
return retParam;
}
use of org.graalvm.compiler.nodes.ReturnNode in project graal by oracle.
the class MethodSafepointInsertionPhase method run.
@Override
protected void run(StructuredGraph graph) {
if (graph.method().getAnnotation(Uninterruptible.class) != null) {
/*
* If a method is annotated with {@link Uninterruptible}, then I do not want a test for
* a safepoint at the return.
*/
return;
}
if (graph.method().getAnnotation(CFunction.class) != null) {
/*
* If a method transfers from Java to C, then the return transition (if any) contains
* the safepoint test and one is not needed at the return of the transferring method.
*/
return;
}
if (((SharedMethod) graph.method()).isEntryPoint()) {
/*
* If a method is transferring from C to Java, then no safepoint test is needed at the
* return of the transferring method.
*/
return;
}
for (ReturnNode returnNode : graph.getNodes(ReturnNode.TYPE)) {
SafepointNode safepointNode = graph.add(new SafepointNode());
graph.addBeforeFixed(returnNode, safepointNode);
}
}
Aggregations