private static BailoutException bailout(GraphBuilderContext b, String msg) { throw b.bailout(msg + "\nat " + b.getCode().asStackTraceElement(b.bci())); } }
@Override public boolean apply(GraphBuilderContext b, ResolvedJavaMethod targetMethod, Receiver receiver, ValueNode value) { ValueNode curValue = value; if (curValue instanceof BoxNode) { BoxNode boxNode = (BoxNode) curValue; curValue = boxNode.getValue(); } if (curValue.isConstant()) { return true; } else if (canDelayIntrinsification) { return false; } else { StringBuilder sb = new StringBuilder(); sb.append(curValue); if (curValue instanceof ValuePhiNode) { ValuePhiNode valuePhi = (ValuePhiNode) curValue; sb.append(" ("); for (Node n : valuePhi.inputs()) { sb.append(n); sb.append("; "); } sb.append(")"); } value.getDebug().dump(DebugContext.VERBOSE_LEVEL, value.graph(), "Graph before bailout at node %s", sb); throw b.bailout("Partial evaluation did not reduce value to a constant, is a regular compiler node: " + sb); } } });
@Override public boolean apply(GraphBuilderContext b, ResolvedJavaMethod targetMethod, Receiver receiver, ValueNode message) { if (message.isConstant()) { String messageString = message.asConstant().toValueString(); b.add(new NeverPartOfCompilationNode(messageString)); return true; } else { throw b.bailout("message for never part of compilation is non-constant"); } } });
private static ResolvedJavaType typeValue(ConstantReflectionProvider constantReflection, GraphBuilderContext b, ResolvedJavaMethod targetMethod, ValueNode typeNode, String name) { if (!typeNode.isConstant()) { throw b.bailout("parameter " + name + " is not a compile time constant for call to " + targetMethod.format("%H.%n(%p)") + " in " + b.getMethod().asStackTraceElement(b.bci())); } ResolvedJavaType type = constantReflection.asJavaType(typeNode.asConstant()); if (type == null) { throw b.bailout("parameter " + name + " is null for call to " + targetMethod.format("%H.%n(%p)") + " in " + b.getMethod().asStackTraceElement(b.bci())); } return type; }
protected static long longValue(GraphBuilderContext b, ResolvedJavaMethod targetMethod, ValueNode node, String name) { if (!node.isConstant()) { throw b.bailout("parameter " + name + " is not a compile time constant for call to " + targetMethod.format("%H.%n(%p)") + " in " + b.getMethod().asStackTraceElement(b.bci())); } return node.asJavaConstant().asLong(); }
@Override public boolean apply(GraphBuilderContext b, ResolvedJavaMethod targetMethod, Receiver receiver, ValueNode descriptor, ValueNode args) { if (canDelayIntrinsification) { return false; } if (!descriptor.isJavaConstant()) { throw b.bailout("Parameter 'descriptor' is not a compile-time constant"); } ValueNode nonNullArguments = b.add(PiNode.create(args, StampFactory.objectNonNull(StampTool.typeReferenceOrNull(args)))); b.addPush(JavaKind.Object, new NewFrameNode(b, descriptor, nonNullArguments, types)); return true; } });
@Override public boolean apply(GraphBuilderContext b, ResolvedJavaMethod targetMethod, Receiver receiver, ValueNode message) { if (canDelayIntrinsification) { /* * We do not want to bailout yet, since we are still parsing individual methods * and constant folding could still eliminate the call to bailout(). However, we * also want to stop parsing, since we are sure that we will never need the * graph beyond the bailout point. * * Therefore, we manually emit the call to bailout, which will be intrinsified * later when intrinsifications can no longer be delayed. The call is followed * by a NeverPartOfCompilationNode, which is a control sink and therefore stops * any further parsing. */ StampPair returnStamp = b.getInvokeReturnStamp(b.getAssumptions()); CallTargetNode callTarget = b.add(new MethodCallTargetNode(InvokeKind.Static, targetMethod, new ValueNode[]{message}, returnStamp, null)); b.add(new InvokeNode(callTarget, b.bci())); b.add(new NeverPartOfCompilationNode("intrinsification of call to bailout() will abort entire compilation")); return true; } if (message.isConstant()) { throw b.bailout(message.asConstant().toValueString()); } throw b.bailout("bailout (message is not compile-time constant, so no additional information is available)"); } });
throw new GraalError(message); throw b.bailout(message);