use of org.graalvm.compiler.nodes.extended.ForeignCallNode in project graal by oracle.
the class DefaultJavaLoweringProvider method lowerUnaryMath.
private void lowerUnaryMath(UnaryMathIntrinsicNode math, LoweringTool tool) {
if (tool.getLoweringStage() == LoweringTool.StandardLoweringStage.HIGH_TIER) {
return;
}
ResolvedJavaMethod method = math.graph().method();
if (method != null) {
if (method.getAnnotation(Snippet.class) != null) {
/*
* In the context of the snippet use the LIR lowering instead of the Node lowering.
*/
return;
}
if (method.getName().equalsIgnoreCase(math.getOperation().name()) && tool.getMetaAccess().lookupJavaType(Math.class).equals(method.getDeclaringClass())) {
/*
* A root compilation of the intrinsic method should emit the full assembly
* implementation.
*/
return;
}
}
ForeignCallDescriptor foreignCall = toForeignCall(math.getOperation());
if (foreignCall != null) {
StructuredGraph graph = math.graph();
ForeignCallNode call = math.graph().add(new ForeignCallNode(foreignCalls, foreignCall, math.getValue()));
graph.addAfterFixed(tool.lastFixedNode(), call);
math.replaceAtUsages(call);
}
}
use of org.graalvm.compiler.nodes.extended.ForeignCallNode in project graal by oracle.
the class InvokeNode method intrinsify.
@Override
public void intrinsify(Node node) {
assert !(node instanceof ValueNode) || node.isAllowedUsageType(InputType.Value) == isAllowedUsageType(InputType.Value) : "replacing " + this + " with " + node;
CallTargetNode call = callTarget;
FrameState currentStateAfter = stateAfter();
if (node instanceof StateSplit) {
StateSplit stateSplit = (StateSplit) node;
stateSplit.setStateAfter(currentStateAfter);
}
if (node instanceof ForeignCallNode) {
ForeignCallNode foreign = (ForeignCallNode) node;
foreign.setBci(bci());
}
if (node instanceof FixedWithNextNode) {
graph().replaceFixedWithFixed(this, (FixedWithNextNode) node);
} else if (node instanceof ControlSinkNode) {
this.replaceAtPredecessor(node);
this.replaceAtUsages(null);
GraphUtil.killCFG(this);
return;
} else {
graph().replaceFixed(this, node);
}
GraphUtil.killWithUnusedFloatingInputs(call);
if (currentStateAfter.hasNoUsages()) {
GraphUtil.killWithUnusedFloatingInputs(currentStateAfter);
}
}
use of org.graalvm.compiler.nodes.extended.ForeignCallNode 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;
}
Aggregations