use of org.graalvm.compiler.nodes.StructuredGraph 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.StructuredGraph 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.StructuredGraph in project graal by oracle.
the class UninterruptibleAnnotationChecker method checkUninterruptibleAllocations.
/**
* Check that each method that is annotated with {@linkplain Uninterruptible} contains no
* allocations.
*/
@SuppressWarnings("try")
private void checkUninterruptibleAllocations(DebugContext debug) {
for (HostedMethod method : methodCollection) {
try (DebugContext.Scope s = debug.scope("CheckUninterruptibleAllocations", method.compilationInfo.graph, method, this)) {
Uninterruptible methodAnnotation = method.getAnnotation(Uninterruptible.class);
StructuredGraph graph = method.compilationInfo.getGraph();
if (methodAnnotation != null && graph != null) {
for (Node node : graph.getNodes()) {
if (node instanceof AbstractNewObjectNode) {
postUninterruptibleWarning("Annotated method: " + method.format("%h.%n(%p)") + " allocates.");
}
}
}
} catch (Throwable t) {
throw debug.handle(t);
}
}
}
use of org.graalvm.compiler.nodes.StructuredGraph in project graal by oracle.
the class SnippetStub method getGraph.
@Override
@SuppressWarnings("try")
protected StructuredGraph getGraph(DebugContext debug, CompilationIdentifier compilationId) {
Plugins defaultPlugins = providers.getGraphBuilderPlugins();
MetaAccessProvider metaAccess = providers.getMetaAccess();
SnippetReflectionProvider snippetReflection = providers.getSnippetReflection();
Plugins plugins = new Plugins(defaultPlugins);
plugins.prependParameterPlugin(new ConstantBindingParameterPlugin(makeConstArgs(), metaAccess, snippetReflection));
GraphBuilderConfiguration config = GraphBuilderConfiguration.getSnippetDefault(plugins);
// Stubs cannot have optimistic assumptions since they have
// to be valid for the entire run of the VM.
final StructuredGraph graph = new StructuredGraph.Builder(options, debug).method(method).compilationId(compilationId).build();
try (DebugContext.Scope outer = debug.scope("SnippetStub", graph)) {
graph.disableUnsafeAccessTracking();
IntrinsicContext initialIntrinsicContext = new IntrinsicContext(method, method, getReplacementsBytecodeProvider(), INLINE_AFTER_PARSING);
GraphBuilderPhase.Instance instance = new GraphBuilderPhase.Instance(metaAccess, providers.getStampProvider(), providers.getConstantReflection(), providers.getConstantFieldProvider(), config, OptimisticOptimizations.NONE, initialIntrinsicContext);
instance.apply(graph);
for (ParameterNode param : graph.getNodes(ParameterNode.TYPE)) {
int index = param.index();
if (method.getParameterAnnotation(NonNullParameter.class, index) != null) {
param.setStamp(param.stamp(NodeView.DEFAULT).join(StampFactory.objectNonNull()));
}
}
new RemoveValueProxyPhase().apply(graph);
graph.setGuardsStage(GuardsStage.FLOATING_GUARDS);
CanonicalizerPhase canonicalizer = new CanonicalizerPhase();
PhaseContext context = new PhaseContext(providers);
canonicalizer.apply(graph, context);
new LoweringPhase(canonicalizer, LoweringTool.StandardLoweringStage.HIGH_TIER).apply(graph, context);
} catch (Throwable e) {
throw debug.handle(e);
}
return graph;
}
use of org.graalvm.compiler.nodes.StructuredGraph in project graal by oracle.
the class Stub method buildCompilationResult.
@SuppressWarnings("try")
private CompilationResult buildCompilationResult(DebugContext debug, final Backend backend) {
CompilationIdentifier compilationId = getStubCompilationId();
final StructuredGraph graph = getGraph(debug, compilationId);
CompilationResult compResult = new CompilationResult(compilationId, toString(), GeneratePIC.getValue(options));
// Stubs cannot be recompiled so they cannot be compiled with assumptions
assert graph.getAssumptions() == null;
if (!(graph.start() instanceof StubStartNode)) {
StubStartNode newStart = graph.add(new StubStartNode(Stub.this));
newStart.setStateAfter(graph.start().stateAfter());
graph.replaceFixed(graph.start(), newStart);
}
try (DebugContext.Scope s0 = debug.scope("StubCompilation", graph, providers.getCodeCache())) {
Suites suites = createSuites();
emitFrontEnd(providers, backend, graph, providers.getSuites().getDefaultGraphBuilderSuite(), OptimisticOptimizations.ALL, DefaultProfilingInfo.get(TriState.UNKNOWN), suites);
LIRSuites lirSuites = createLIRSuites();
emitBackEnd(graph, Stub.this, getInstalledCodeOwner(), backend, compResult, CompilationResultBuilderFactory.Default, getRegisterConfig(), lirSuites);
assert checkStubInvariants(compResult);
} catch (Throwable e) {
throw debug.handle(e);
}
return compResult;
}
Aggregations