use of org.graalvm.compiler.nodes.DirectCallTargetNode in project graal by oracle.
the class ArrayCopyIntrinsificationTest method getCode.
@Override
protected InstalledCode getCode(ResolvedJavaMethod method, StructuredGraph g, boolean forceCompile, boolean installAsDefault, OptionValues options) {
StructuredGraph graph = g == null ? parseForCompile(method) : g;
int nodeCount = graph.getNodeCount();
InstalledCode result = super.getCode(method, graph, forceCompile, installAsDefault, options);
boolean graphWasProcessed = nodeCount != graph.getNodeCount();
if (graphWasProcessed) {
if (mustIntrinsify) {
for (Node node : graph.getNodes()) {
if (node instanceof Invoke) {
Invoke invoke = (Invoke) node;
Assert.assertTrue(invoke.callTarget() instanceof DirectCallTargetNode);
LoweredCallTargetNode directCall = (LoweredCallTargetNode) invoke.callTarget();
JavaMethod callee = directCall.targetMethod();
if (callee.getDeclaringClass().equals(getMetaAccess().lookupJavaType(System.class)) && callee.getName().equals("arraycopy")) {
// A partial snippet (e.g., ArrayCopySnippets.checkcastArraycopy) may
// call the original arraycopy method
} else {
Assert.assertTrue(callee.toString(), callee.getName().equals("<init>"));
Assert.assertTrue(getMetaAccess().lookupJavaType(ArrayIndexOutOfBoundsException.class).equals(callee.getDeclaringClass()) || getMetaAccess().lookupJavaType(NullPointerException.class).equals(callee.getDeclaringClass()));
}
}
}
} else {
boolean found = false;
for (Node node : graph.getNodes()) {
if (node instanceof Invoke) {
Invoke invoke = (Invoke) node;
LoweredCallTargetNode directCall = (LoweredCallTargetNode) invoke.callTarget();
JavaMethod callee = directCall.targetMethod();
if (callee.getDeclaringClass().equals(getMetaAccess().lookupJavaType(System.class)) && callee.getName().equals("arraycopy")) {
found = true;
} else {
fail("found invoke to some method other than arraycopy: " + callee);
}
}
}
Assert.assertTrue("did not find invoke to arraycopy", found);
}
}
return result;
}
use of org.graalvm.compiler.nodes.DirectCallTargetNode in project graal by oracle.
the class NodeLIRBuilder method emitInvoke.
@Override
public void emitInvoke(Invoke x) {
LoweredCallTargetNode callTarget = (LoweredCallTargetNode) x.callTarget();
FrameMapBuilder frameMapBuilder = gen.getResult().getFrameMapBuilder();
CallingConvention invokeCc = frameMapBuilder.getRegisterConfig().getCallingConvention(callTarget.callType(), x.asNode().stamp(NodeView.DEFAULT).javaType(gen.getMetaAccess()), callTarget.signature(), gen);
frameMapBuilder.callsMethod(invokeCc);
Value[] parameters = visitInvokeArguments(invokeCc, callTarget.arguments());
LabelRef exceptionEdge = null;
if (x instanceof InvokeWithExceptionNode) {
exceptionEdge = getLIRBlock(((InvokeWithExceptionNode) x).exceptionEdge());
}
LIRFrameState callState = stateWithExceptionEdge(x, exceptionEdge);
Value result = invokeCc.getReturn();
if (callTarget instanceof DirectCallTargetNode) {
emitDirectCall((DirectCallTargetNode) callTarget, result, parameters, AllocatableValue.NONE, callState);
} else if (callTarget instanceof IndirectCallTargetNode) {
emitIndirectCall((IndirectCallTargetNode) callTarget, result, parameters, AllocatableValue.NONE, callState);
} else {
throw GraalError.shouldNotReachHere();
}
if (isLegal(result)) {
setResult(x.asNode(), gen.emitMove(result));
}
if (x instanceof InvokeWithExceptionNode) {
gen.emitJump(getLIRBlock(((InvokeWithExceptionNode) x).next()));
}
}
Aggregations