use of org.graalvm.compiler.debug.DebugDumpScope in project graal by oracle.
the class PolymorphicInliningTest method getGraph.
@SuppressWarnings("try")
private StructuredGraph getGraph(final String snippet, final boolean eagerInfopointMode) {
DebugContext debug = getDebugContext();
try (DebugContext.Scope s = debug.scope("InliningTest", new DebugDumpScope(snippet, true))) {
ResolvedJavaMethod method = getResolvedJavaMethod(snippet);
Builder builder = builder(method, AllowAssumptions.YES, debug);
StructuredGraph graph = eagerInfopointMode ? parse(builder, getDebugGraphBuilderSuite()) : parse(builder, getEagerGraphBuilderSuite());
try (DebugContext.Scope s2 = debug.scope("Inlining", graph)) {
PhaseSuite<HighTierContext> graphBuilderSuite = eagerInfopointMode ? getCustomGraphBuilderSuite(GraphBuilderConfiguration.getDefault(getDefaultGraphBuilderPlugins()).withFullInfopoints(true)) : getDefaultGraphBuilderSuite();
HighTierContext context = new HighTierContext(getProviders(), graphBuilderSuite, OptimisticOptimizations.ALL);
debug.dump(DebugContext.BASIC_LEVEL, graph, "Graph");
new CanonicalizerPhase().apply(graph, context);
new InliningPhase(new CanonicalizerPhase()).apply(graph, context);
debug.dump(DebugContext.BASIC_LEVEL, graph, "Graph");
new CanonicalizerPhase().apply(graph, context);
new DeadCodeEliminationPhase().apply(graph);
return graph;
}
} catch (Throwable e) {
throw debug.handle(e);
}
}
use of org.graalvm.compiler.debug.DebugDumpScope in project graal by oracle.
the class CFGPrinterObserver method checkMethodScope.
/**
* Looks for the outer most method and its {@link DebugDumpScope#decorator}s in the current
* debug scope and opens a new compilation scope if this pair does not match the current method
* and decorator pair.
*/
private boolean checkMethodScope(DebugContext debug) {
JavaMethod method = null;
CompilationIdentifier compilation = null;
ArrayList<String> decorators = new ArrayList<>();
for (Object o : debug.context()) {
if (o instanceof JavaMethod) {
method = (JavaMethod) o;
decorators.clear();
} else if (o instanceof StructuredGraph) {
StructuredGraph graph = (StructuredGraph) o;
if (graph.method() != null) {
method = graph.method();
decorators.clear();
compilation = graph.compilationId();
}
} else if (o instanceof DebugDumpScope) {
DebugDumpScope debugDumpScope = (DebugDumpScope) o;
if (debugDumpScope.decorator) {
decorators.add(debugDumpScope.name);
}
} else if (o instanceof CompilationResult) {
CompilationResult compilationResult = (CompilationResult) o;
compilation = compilationResult.getCompilationId();
}
}
if (method == null && compilation == null) {
return false;
}
if (compilation != null) {
if (!compilation.equals(curCompilation) || !curDecorators.equals(decorators)) {
cfgPrinter.printCompilation(compilation);
}
} else {
if (!method.equals(curMethod) || !curDecorators.equals(decorators)) {
cfgPrinter.printCompilation(method);
}
}
curCompilation = compilation;
curMethod = method;
curDecorators = decorators;
return true;
}
use of org.graalvm.compiler.debug.DebugDumpScope in project graal by oracle.
the class GraphPrinterDumpHandler method getInlineContext.
private List<String> getInlineContext(Graph graph) {
List<String> result = inlineContextMap.get(graph);
if (result == null) {
result = new ArrayList<>();
Object lastMethodOrGraph = null;
boolean graphSeen = false;
DebugContext debug = graph.getDebug();
for (Object o : debug.context()) {
if (o == graph) {
graphSeen = true;
}
if (o instanceof DebugDumpScope) {
DebugDumpScope debugDumpScope = (DebugDumpScope) o;
if (debugDumpScope.decorator && !result.isEmpty()) {
result.set(result.size() - 1, debugDumpScope.name + ":" + result.get(result.size() - 1));
} else {
result.add(debugDumpScope.name);
}
} else {
addMethodContext(result, o, lastMethodOrGraph);
}
if (o instanceof JavaMethod || o instanceof Graph) {
lastMethodOrGraph = o;
}
}
if (result.size() == 2 && result.get(1).startsWith("TruffleGraal")) {
result.clear();
result.add("Graal Graphs");
}
if (result.isEmpty()) {
result.add(graph.toString());
graphSeen = true;
}
// Reverse list such that inner method comes after outer method.
Collections.reverse(result);
if (!graphSeen) {
/*
* The graph isn't in any context but is being processed within another graph so add
* it to the end of the scopes.
*/
if (asJavaMethod(graph) != null) {
addMethodContext(result, graph, lastMethodOrGraph);
} else {
result.add(graph.toString());
}
}
inlineContextMap.put(graph, result);
}
return result;
}
Aggregations