use of org.graalvm.compiler.nodes.Invoke in project graal by oracle.
the class UninterruptibleAnnotationChecker method checkUninterruptibleCallees.
/**
* Check that each method annotated with {@link Uninterruptible} calls only methods that are
* also annotated with {@link Uninterruptible}, or methods annotated with {@link CFunction} that
* specify "Transition = NO_TRANSITION".
*
* A caller can be annotated with "calleeMustBe = false" to allow calls to methods that are not
* annotated with {@link Uninterruptible}, to allow the few cases where that should be allowed.
*/
@SuppressWarnings("try")
private void checkUninterruptibleCallees(DebugContext debug) {
if (Options.PrintUninterruptibleCalleeDOTGraph.getValue()) {
System.out.println("/* DOT */ digraph uninterruptible {");
}
for (HostedMethod caller : methodCollection) {
try (DebugContext.Scope s = debug.scope("CheckUninterruptibleCallees", caller.compilationInfo.graph, caller, this)) {
Uninterruptible callerAnnotation = caller.getAnnotation(Uninterruptible.class);
StructuredGraph graph = caller.compilationInfo.getGraph();
if (callerAnnotation != null) {
if (callerAnnotation.calleeMustBe()) {
if (graph != null) {
for (Invoke invoke : graph.getInvokes()) {
HostedMethod callee = (HostedMethod) invoke.callTarget().targetMethod();
if (Options.PrintUninterruptibleCalleeDOTGraph.getValue()) {
printDotGraphEdge(caller, callee);
}
if (!isNotInterruptible(callee)) {
postUninterruptibleWarning("Unannotated callee: " + callee.format("%h.%n(%p)") + " called by annotated caller " + caller.format("%h.%n(%p)"));
}
}
}
} else {
// Print DOT graph edge even if callee need not be annotated.
if (graph != null) {
for (Invoke invoke : graph.getInvokes()) {
HostedMethod callee = (HostedMethod) invoke.callTarget().targetMethod();
if (Options.PrintUninterruptibleCalleeDOTGraph.getValue()) {
printDotGraphEdge(caller, callee);
}
}
}
}
}
} catch (Throwable t) {
throw debug.handle(t);
}
}
if (Options.PrintUninterruptibleCalleeDOTGraph.getValue()) {
System.out.println("/* DOT */ }");
}
}
use of org.graalvm.compiler.nodes.Invoke in project graal by oracle.
the class UninterruptibleAnnotationChecker method checkUninterruptibleCallers.
/**
* Check that each method that calls a method annotated with {@linkplain Uninterruptible} that
* has "callerMustBeUninterrutible = true" is also annotated with {@linkplain Uninterruptible}.
*/
@SuppressWarnings("try")
private void checkUninterruptibleCallers(DebugContext debug) {
for (HostedMethod caller : methodCollection) {
try (DebugContext.Scope s = debug.scope("CheckUninterruptibleCallers", caller.compilationInfo.graph, caller, this)) {
Uninterruptible callerAnnotation = caller.getAnnotation(Uninterruptible.class);
StructuredGraph graph = caller.compilationInfo.getGraph();
if (callerAnnotation == null && graph != null) {
for (Invoke invoke : graph.getInvokes()) {
HostedMethod callee = (HostedMethod) invoke.callTarget().targetMethod();
if (isCallerMustBe(callee)) {
postUninterruptibleWarning("Unannotated caller: " + caller.format("%h.%n(%p)") + " calls annotated callee " + callee.format("%h.%n(%p)"));
}
}
}
} catch (Throwable t) {
throw debug.handle(t);
}
}
}
use of org.graalvm.compiler.nodes.Invoke in project graal by oracle.
the class BytecodeParser method createNonInlinedInvoke.
protected Invoke createNonInlinedInvoke(ExceptionEdgeAction exceptionEdge, int invokeBci, ValueNode[] invokeArgs, ResolvedJavaMethod targetMethod, InvokeKind invokeKind, JavaKind resultType, JavaType returnType, JavaTypeProfile profile) {
StampPair returnStamp = graphBuilderConfig.getPlugins().getOverridingStamp(this, returnType, false);
if (returnStamp == null) {
returnStamp = StampFactory.forDeclaredType(graph.getAssumptions(), returnType, false);
}
MethodCallTargetNode callTarget = graph.add(createMethodCallTarget(invokeKind, targetMethod, invokeArgs, returnStamp, profile));
Invoke invoke = createNonInlinedInvoke(exceptionEdge, invokeBci, callTarget, resultType);
for (InlineInvokePlugin plugin : graphBuilderConfig.getPlugins().getInlineInvokePlugins()) {
plugin.notifyNotInlined(this, targetMethod, invoke);
}
return invoke;
}
use of org.graalvm.compiler.nodes.Invoke in project graal by oracle.
the class PEGraphDecoder method tryInvocationPlugin.
protected boolean tryInvocationPlugin(PEMethodScope methodScope, LoopScope loopScope, InvokeData invokeData, MethodCallTargetNode callTarget) {
if (invocationPlugins == null || invocationPlugins.isEmpty()) {
return false;
}
Invoke invoke = invokeData.invoke;
ResolvedJavaMethod targetMethod = callTarget.targetMethod();
InvocationPlugin invocationPlugin = getInvocationPlugin(targetMethod);
if (invocationPlugin == null) {
return false;
}
ValueNode[] arguments = callTarget.arguments().toArray(new ValueNode[0]);
FixedWithNextNode invokePredecessor = (FixedWithNextNode) invoke.asNode().predecessor();
/*
* Remove invoke from graph so that invocation plugin can append nodes to the predecessor.
*/
invoke.asNode().replaceAtPredecessor(null);
PEMethodScope inlineScope = new PEMethodScope(graph, methodScope, loopScope, null, targetMethod, invokeData, methodScope.inliningDepth + 1, loopExplosionPlugin, arguments);
PEAppendGraphBuilderContext graphBuilderContext = new PEAppendGraphBuilderContext(inlineScope, invokePredecessor);
InvocationPluginReceiver invocationPluginReceiver = new InvocationPluginReceiver(graphBuilderContext);
if (invocationPlugin.execute(graphBuilderContext, targetMethod, invocationPluginReceiver.init(targetMethod, arguments), arguments)) {
if (graphBuilderContext.invokeConsumed) {
/* Nothing to do. */
} else if (graphBuilderContext.lastInstr != null) {
registerNode(loopScope, invokeData.invokeOrderId, graphBuilderContext.pushedNode, true, true);
invoke.asNode().replaceAtUsages(graphBuilderContext.pushedNode);
graphBuilderContext.lastInstr.setNext(nodeAfterInvoke(methodScope, loopScope, invokeData, AbstractBeginNode.prevBegin(graphBuilderContext.lastInstr)));
deleteInvoke(invoke);
} else {
assert graphBuilderContext.pushedNode == null : "Why push a node when the invoke does not return anyway?";
invoke.asNode().replaceAtUsages(null);
deleteInvoke(invoke);
}
return true;
} else {
/* Intrinsification failed, restore original state: invoke is in Graph. */
invokePredecessor.setNext(invoke.asNode());
return false;
}
}
use of org.graalvm.compiler.nodes.Invoke in project graal by oracle.
the class VerifyDebugUsage method verifyParameters.
private void verifyParameters(StructuredGraph callerGraph, MethodCallTargetNode debugCallTarget, List<? extends ValueNode> args, ResolvedJavaType stringType, int startArgIdx, int varArgsIndex) {
ResolvedJavaMethod verifiedCallee = debugCallTarget.targetMethod();
Integer dumpLevel = null;
int argIdx = startArgIdx;
int varArgsElementIndex = 0;
boolean reportVarArgs = false;
for (int i = 0; i < args.size(); i++) {
ValueNode arg = args.get(i);
if (arg instanceof Invoke) {
reportVarArgs = varArgsIndex >= 0 && argIdx >= varArgsIndex;
Invoke invoke = (Invoke) arg;
CallTargetNode callTarget = invoke.callTarget();
if (callTarget instanceof MethodCallTargetNode) {
ResolvedJavaMethod m = ((MethodCallTargetNode) callTarget).targetMethod();
if (m.getName().equals("toString")) {
int bci = invoke.bci();
int nonVarArgIdx = reportVarArgs ? argIdx - varArgsElementIndex : argIdx;
verifyStringConcat(callerGraph, verifiedCallee, bci, nonVarArgIdx, reportVarArgs ? varArgsElementIndex : -1, m);
verifyToStringCall(callerGraph, verifiedCallee, stringType, m, bci, nonVarArgIdx, reportVarArgs ? varArgsElementIndex : -1);
} else if (m.getName().equals("format")) {
int bci = invoke.bci();
int nonVarArgIdx = reportVarArgs ? argIdx - varArgsElementIndex : argIdx;
verifyFormatCall(callerGraph, verifiedCallee, stringType, m, bci, nonVarArgIdx, reportVarArgs ? varArgsElementIndex : -1);
}
}
}
if (i == 1) {
if (verifiedCallee.getName().equals("dump")) {
dumpLevel = verifyDumpLevelParameter(callerGraph, debugCallTarget, verifiedCallee, arg);
}
} else if (i == 2) {
if (dumpLevel != null) {
verifyDumpObjectParameter(callerGraph, debugCallTarget, arg, verifiedCallee, dumpLevel);
}
}
if (varArgsIndex >= 0 && i >= varArgsIndex) {
varArgsElementIndex++;
}
argIdx++;
}
}
Aggregations