use of com.oracle.svm.core.graal.nodes.LoweredDeadEndNode in project graal by oracle.
the class ReflectionGraphKit method emitIllegalArgumentException.
/**
* To reduce machine code size, we want only one call site for each exception class that can be
* thrown. We also do not want arguments that require phi functions. So we cannot have an error
* message that, e.g., prints which exact cast failed. But we have the member that the stub is
* for, and the provided argument arrays, which allows a good enough error message.
*/
public void emitIllegalArgumentException(Executable member, ValueNode obj, ValueNode args) {
continueWithMerge(illegalArgumentExceptionPaths);
ValueNode memberNode = createConstant(SubstrateObjectConstant.forObject(member), JavaKind.Object);
ResolvedJavaMethod targetMethod;
ValueNode[] arguments;
if (obj == null) {
targetMethod = findMethod(ReflectionAccessorHolder.class, "throwIllegalArgumentExceptionWithoutReceiver", true);
arguments = new ValueNode[] { memberNode, args };
} else {
targetMethod = findMethod(ReflectionAccessorHolder.class, "throwIllegalArgumentExceptionWithReceiver", true);
arguments = new ValueNode[] { memberNode, obj, args };
}
createJavaCallWithExceptionAndUnwind(CallTargetNode.InvokeKind.Static, targetMethod, arguments);
append(new LoweredDeadEndNode());
}
use of com.oracle.svm.core.graal.nodes.LoweredDeadEndNode 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.graal.nodes.LoweredDeadEndNode in project graal by oracle.
the class SubstrateStrengthenGraphs method createUnreachable.
@Override
protected FixedNode createUnreachable(StructuredGraph graph, CoreProviders providers, Supplier<String> message) {
FixedNode unreachableNode = graph.add(new LoweredDeadEndNode());
/*
* To aid debugging of static analysis problems, we can print details about why the place is
* unreachable before failing fatally. But since these strings are long and not useful for
* non-VM developers, we only do it when assertions are enabled for the image builder. And
* Uninterruptible methods might not be able to access the heap yet for the error message
* constant, so we skip it for such methods too.
*/
if (SubstrateUtil.assertionsEnabled() && !Uninterruptible.Utils.isUninterruptible(graph.method())) {
ConstantNode messageNode = ConstantNode.forConstant(providers.getConstantReflection().forString(message.get()), providers.getMetaAccess(), graph);
ForeignCallNode foreignCallNode = graph.add(new ForeignCallNode(SnippetRuntime.UNSUPPORTED_FEATURE, messageNode));
foreignCallNode.setNext(unreachableNode);
unreachableNode = foreignCallNode;
}
return unreachableNode;
}
use of com.oracle.svm.core.graal.nodes.LoweredDeadEndNode in project graal by oracle.
the class JNICallTrampolineMethod method buildGraph.
@Override
public StructuredGraph buildGraph(DebugContext debug, ResolvedJavaMethod method, HostedProviders providers, Purpose purpose) {
HostedGraphKit kit = new JNIGraphKit(debug, providers, method);
kit.append(new LoweredDeadEndNode());
return kit.finalizeGraph();
}
use of com.oracle.svm.core.graal.nodes.LoweredDeadEndNode in project graal by oracle.
the class CEntryPointCallStubMethod method generateExceptionHandler.
private void generateExceptionHandler(HostedProviders providers, SubstrateGraphKit kit, ExceptionObjectNode exception, JavaKind returnKind) {
if (entryPointData.getExceptionHandler() == CEntryPoint.FatalExceptionHandler.class) {
kit.appendStateSplitProxy(exception.stateAfter());
CEntryPointLeaveNode leave = new CEntryPointLeaveNode(LeaveAction.ExceptionAbort, exception);
kit.append(leave);
kit.append(new LoweredDeadEndNode());
} else {
ResolvedJavaType throwable = providers.getMetaAccess().lookupJavaType(Throwable.class);
ResolvedJavaType handler = providers.getMetaAccess().lookupJavaType(entryPointData.getExceptionHandler());
ResolvedJavaMethod[] handlerMethods = handler.getDeclaredMethods();
UserError.guarantee(handlerMethods.length == 1 && handlerMethods[0].isStatic(), "Exception handler class must declare exactly one static method: %s -> %s", targetMethod, handler);
UserError.guarantee(Uninterruptible.Utils.isUninterruptible(handlerMethods[0]), "Exception handler method must be annotated with @%s: %s", Uninterruptible.class.getSimpleName(), handlerMethods[0]);
JavaType[] handlerParameterTypes = handlerMethods[0].toParameterTypes();
UserError.guarantee(handlerParameterTypes.length == 1 && ((ResolvedJavaType) handlerParameterTypes[0]).isAssignableFrom(throwable), "Exception handler method must have exactly one parameter of type Throwable: %s -> %s", targetMethod, handlerMethods[0]);
InvokeWithExceptionNode handlerInvoke = kit.startInvokeWithException(handlerMethods[0], InvokeKind.Static, kit.getFrameState(), kit.bci(), exception);
kit.noExceptionPart();
ValueNode returnValue = handlerInvoke;
if (handlerInvoke.getStackKind() != returnKind) {
JavaKind fromKind = handlerInvoke.getStackKind();
if (fromKind == JavaKind.Float && returnKind == JavaKind.Double) {
returnValue = kit.unique(new FloatConvertNode(FloatConvert.F2D, returnValue));
} else if (fromKind.isUnsigned() && returnKind.isNumericInteger() && returnKind.getBitCount() > fromKind.getBitCount()) {
returnValue = kit.unique(new ZeroExtendNode(returnValue, returnKind.getBitCount()));
} else if (fromKind.isNumericInteger() && returnKind.isNumericInteger() && returnKind.getBitCount() > fromKind.getBitCount()) {
returnValue = kit.unique(new SignExtendNode(returnValue, returnKind.getBitCount()));
} else {
throw UserError.abort("Exception handler method return type must be assignable to entry point method return type: %s -> %s", targetMethod, handlerMethods[0]);
}
}
/* The exception is handled, we can continue with the normal epilogue. */
generateEpilogue(providers, kit);
kit.createReturn(returnValue, returnValue.getStackKind());
// fail-safe for exceptions in exception handler
kit.exceptionPart();
kit.append(new CEntryPointLeaveNode(LeaveAction.ExceptionAbort, kit.exceptionObject()));
kit.append(new LoweredDeadEndNode());
kit.endInvokeWithException();
}
}
Aggregations