Search in sources :

Example 16 with DebugDumpScope

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);
    }
}
Also used : StructuredGraph(org.graalvm.compiler.nodes.StructuredGraph) DebugDumpScope(org.graalvm.compiler.debug.DebugDumpScope) Builder(org.graalvm.compiler.nodes.StructuredGraph.Builder) CanonicalizerPhase(org.graalvm.compiler.phases.common.CanonicalizerPhase) DebugContext(org.graalvm.compiler.debug.DebugContext) HighTierContext(org.graalvm.compiler.phases.tiers.HighTierContext) InliningPhase(org.graalvm.compiler.phases.common.inlining.InliningPhase) DeadCodeEliminationPhase(org.graalvm.compiler.phases.common.DeadCodeEliminationPhase) ResolvedJavaMethod(jdk.vm.ci.meta.ResolvedJavaMethod)

Example 17 with DebugDumpScope

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;
}
Also used : CompilationIdentifier(org.graalvm.compiler.core.common.CompilationIdentifier) StructuredGraph(org.graalvm.compiler.nodes.StructuredGraph) DebugDumpScope(org.graalvm.compiler.debug.DebugDumpScope) ArrayList(java.util.ArrayList) JavaMethod(jdk.vm.ci.meta.JavaMethod) ResolvedJavaMethod(jdk.vm.ci.meta.ResolvedJavaMethod) CompilationResult(org.graalvm.compiler.code.CompilationResult)

Example 18 with DebugDumpScope

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;
}
Also used : Graph(org.graalvm.compiler.graph.Graph) StructuredGraph(org.graalvm.compiler.nodes.StructuredGraph) DebugDumpScope(org.graalvm.compiler.debug.DebugDumpScope) JavaMethod(jdk.vm.ci.meta.JavaMethod) DebugConfig.asJavaMethod(org.graalvm.compiler.debug.DebugConfig.asJavaMethod) ResolvedJavaMethod(jdk.vm.ci.meta.ResolvedJavaMethod) DebugContext(org.graalvm.compiler.debug.DebugContext)

Aggregations

DebugDumpScope (org.graalvm.compiler.debug.DebugDumpScope)18 DebugContext (org.graalvm.compiler.debug.DebugContext)17 StructuredGraph (org.graalvm.compiler.nodes.StructuredGraph)16 CanonicalizerPhase (org.graalvm.compiler.phases.common.CanonicalizerPhase)10 HighTierContext (org.graalvm.compiler.phases.tiers.HighTierContext)6 PhaseContext (org.graalvm.compiler.phases.tiers.PhaseContext)6 LoweringPhase (org.graalvm.compiler.phases.common.LoweringPhase)5 InliningPhase (org.graalvm.compiler.phases.common.inlining.InliningPhase)5 ResolvedJavaMethod (jdk.vm.ci.meta.ResolvedJavaMethod)4 CompilationResult (org.graalvm.compiler.code.CompilationResult)3 CompilationIdentifier (org.graalvm.compiler.core.common.CompilationIdentifier)3 Node (org.graalvm.compiler.graph.Node)3 FloatingReadPhase (org.graalvm.compiler.phases.common.FloatingReadPhase)3 JavaMethod (jdk.vm.ci.meta.JavaMethod)2 ResolvedJavaField (jdk.vm.ci.meta.ResolvedJavaField)2 LoopBeginNode (org.graalvm.compiler.nodes.LoopBeginNode)2 FloatingReadNode (org.graalvm.compiler.nodes.memory.FloatingReadNode)2 OptionValues (org.graalvm.compiler.options.OptionValues)2 GuardLoweringPhase (org.graalvm.compiler.phases.common.GuardLoweringPhase)2 MidTierContext (org.graalvm.compiler.phases.tiers.MidTierContext)2