use of org.graalvm.compiler.nodes.extended.ForeignCallNode in project graal by oracle.
the class InvokeWithExceptionNode method intrinsify.
@Override
public void intrinsify(Node node) {
assert !(node instanceof ValueNode) || (((ValueNode) node).getStackKind() == JavaKind.Void) == (getStackKind() == JavaKind.Void);
CallTargetNode call = callTarget;
FrameState state = stateAfter();
if (exceptionEdge != null) {
killExceptionEdge();
}
if (node instanceof StateSplit) {
StateSplit stateSplit = (StateSplit) node;
stateSplit.setStateAfter(state);
}
if (node instanceof ForeignCallNode) {
ForeignCallNode foreign = (ForeignCallNode) node;
foreign.setBci(bci());
}
if (node == null) {
assert getStackKind() == JavaKind.Void && hasNoUsages();
graph().removeSplit(this, next());
} else if (node instanceof ControlSinkNode) {
this.replaceAtPredecessor(node);
this.replaceAtUsages(null);
GraphUtil.killCFG(this);
return;
} else {
graph().replaceSplit(this, node, next());
}
GraphUtil.killWithUnusedFloatingInputs(call);
if (state.hasNoUsages()) {
GraphUtil.killWithUnusedFloatingInputs(state);
}
}
use of org.graalvm.compiler.nodes.extended.ForeignCallNode in project graal by oracle.
the class MethodTypeFlowBuilder method registerUsedElements.
public static void registerUsedElements(BigBang bb, StructuredGraph graph, MethodTypeFlow methodFlow) {
for (Node n : graph.getNodes()) {
if (n instanceof InstanceOfNode) {
InstanceOfNode node = (InstanceOfNode) n;
AnalysisType type = (AnalysisType) node.type().getType();
type.registerAsInTypeCheck();
} else if (n instanceof NewInstanceNode) {
NewInstanceNode node = (NewInstanceNode) n;
AnalysisType type = (AnalysisType) node.instanceClass();
type.registerAsAllocated(node);
} else if (n instanceof NewArrayNode) {
NewArrayNode node = (NewArrayNode) n;
AnalysisType type = ((AnalysisType) node.elementType()).getArrayClass();
type.registerAsAllocated(node);
} else if (n instanceof NewMultiArrayNode) {
NewMultiArrayNode node = (NewMultiArrayNode) n;
AnalysisType type = ((AnalysisType) node.type());
for (int i = 0; i < node.dimensionCount(); i++) {
type.registerAsAllocated(node);
type = type.getComponentType();
}
} else if (n instanceof BoxNode) {
BoxNode node = (BoxNode) n;
AnalysisType type = (AnalysisType) StampTool.typeOrNull(node);
type.registerAsAllocated(node);
} else if (n instanceof LoadFieldNode) {
LoadFieldNode node = (LoadFieldNode) n;
AnalysisField field = (AnalysisField) node.field();
field.registerAsRead(methodFlow);
} else if (n instanceof StoreFieldNode) {
StoreFieldNode node = (StoreFieldNode) n;
AnalysisField field = (AnalysisField) node.field();
field.registerAsWritten(methodFlow);
} else if (n instanceof StoreIndexedNode) {
StoreIndexedNode node = (StoreIndexedNode) n;
AnalysisType arrayType = (AnalysisType) StampTool.typeOrNull(node.array());
if (arrayType != null) {
assert arrayType.isArray();
arrayType.getComponentType().registerAsInTypeCheck();
}
} else if (n instanceof BytecodeExceptionNode) {
BytecodeExceptionNode node = (BytecodeExceptionNode) n;
AnalysisType type = bb.getMetaAccess().lookupJavaType(node.getExceptionClass());
type.registerAsInHeap();
} else if (n instanceof ConstantNode) {
ConstantNode cn = (ConstantNode) n;
if (cn.hasUsages() && cn.asJavaConstant().getJavaKind() == JavaKind.Object && cn.asJavaConstant().isNonNull()) {
assert StampTool.isExactType(cn);
AnalysisType type = (AnalysisType) StampTool.typeOrNull(cn);
type.registerAsInHeap();
}
} else if (n instanceof ForeignCallNode) {
ForeignCallNode node = (ForeignCallNode) n;
registerForeignCall(bb, node.getDescriptor());
} else if (n instanceof UnaryMathIntrinsicNode) {
UnaryMathIntrinsicNode node = (UnaryMathIntrinsicNode) n;
registerForeignCall(bb, node.getOperation().foreignCallDescriptor);
} else if (n instanceof BinaryMathIntrinsicNode) {
BinaryMathIntrinsicNode node = (BinaryMathIntrinsicNode) n;
registerForeignCall(bb, node.getOperation().foreignCallDescriptor);
}
}
}
use of org.graalvm.compiler.nodes.extended.ForeignCallNode in project graal by oracle.
the class CompileQueue method insertDeoptTests.
/**
* Inserts a call to {@link DeoptTester#deoptTest} right after FixedWithNextNode StateSplits.
*
* @param method method that is being augmented with deopt test calls
* @param graph The graph of a deoptimizable method or the corresponding deopt target method.
*/
private static void insertDeoptTests(HostedMethod method, StructuredGraph graph) {
for (Node node : graph.getNodes()) {
if (node instanceof FixedWithNextNode && node instanceof StateSplit && !(node instanceof InvokeNode) && !(node instanceof ForeignCallNode) && !(node instanceof DeoptTestNode) && !(method.isSynchronized() && node instanceof StartNode)) {
FixedWithNextNode fixedWithNext = (FixedWithNextNode) node;
FixedNode next = fixedWithNext.next();
DeoptTestNode testNode = graph.add(new DeoptTestNode());
fixedWithNext.setNext(null);
testNode.setNext(next);
fixedWithNext.setNext(testNode);
}
}
}
use of org.graalvm.compiler.nodes.extended.ForeignCallNode in project graal by oracle.
the class DefaultJavaLoweringProvider method lowerBinaryMath.
private void lowerBinaryMath(BinaryMathIntrinsicNode 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 = graph.add(new ForeignCallNode(foreignCalls, toForeignCall(math.getOperation()), math.getX(), math.getY()));
graph.addAfterFixed(tool.lastFixedNode(), call);
math.replaceAtUsages(call);
}
}
use of org.graalvm.compiler.nodes.extended.ForeignCallNode in project graal by oracle.
the class ImplicitExceptionsPlugin method handleInvoke.
@Override
public boolean handleInvoke(GraphBuilderContext b, ResolvedJavaMethod method, ValueNode[] args) {
String parsedMethodName = b.getMethod().getDeclaringClass().getName();
if (!parsedMethodName.startsWith("Lcom/oracle/svm")) {
return false;
}
SubstrateForeignCallDescriptor descriptor = runtimeAssertionFatalReplacements.get(method);
if (descriptor != null) {
b.add(new ForeignCallNode(foreignCalls, descriptor, args));
b.add(new DeadEndNode());
return true;
}
return false;
}
Aggregations