use of com.oracle.svm.core.nodes.SubstrateMethodCallTargetNode in project graal by oracle.
the class ExceptionSynthesizer method throwException.
public static void throwException(GraphBuilderContext b, Method throwExceptionMethod, String message) {
ValueNode messageNode = ConstantNode.forConstant(b.getConstantReflection().forString(message), b.getMetaAccess(), b.getGraph());
ResolvedJavaMethod exceptionMethod = b.getMetaAccess().lookupJavaMethod(throwExceptionMethod);
assert exceptionMethod.isStatic();
StampPair returnStamp = StampFactory.forDeclaredType(b.getGraph().getAssumptions(), exceptionMethod.getSignature().getReturnType(null), false);
MethodCallTargetNode callTarget = b.add(new SubstrateMethodCallTargetNode(InvokeKind.Static, exceptionMethod, new ValueNode[] { messageNode }, returnStamp, null, null));
b.add(new InvokeWithExceptionNode(callTarget, null, b.bci()));
/* The invoked method always throws an exception, i.e., never returns. */
b.add(new LoweredDeadEndNode());
}
use of com.oracle.svm.core.nodes.SubstrateMethodCallTargetNode in project graal by oracle.
the class DevirtualizeCallsPhase method run.
@Override
protected void run(StructuredGraph graph) {
for (Invoke invoke : graph.getInvokes()) {
if (invoke.callTarget() instanceof SubstrateMethodCallTargetNode) {
SubstrateMethodCallTargetNode callTarget = (SubstrateMethodCallTargetNode) invoke.callTarget();
if (callTarget.invokeKind().isDirect() && !((HostedMethod) callTarget.targetMethod()).getWrapped().isSimplyImplementationInvoked()) {
/*
* This is a direct call to a method that the static analysis did not see as
* invoked. This can happen when the receiver is always null. In most cases, the
* method profile also has a length of 0 and the below code to kill the invoke
* would trigger. But not all methods have profiles, for example methods with
* manually constructed graphs.
*/
unreachableInvoke(graph, invoke, callTarget);
continue;
}
JavaMethodProfile methodProfile = callTarget.getMethodProfile();
if (methodProfile != null) {
if (methodProfile.getMethods().length == 0) {
unreachableInvoke(graph, invoke, callTarget);
} else if (methodProfile.getMethods().length == 1) {
if (callTarget.invokeKind().isIndirect()) {
singleCallee((HostedMethod) methodProfile.getMethods()[0].getMethod(), graph, invoke, callTarget);
}
}
}
}
}
}
Aggregations