Search in sources :

Example 11 with JavaMethod

use of jdk.vm.ci.meta.JavaMethod in project graal by oracle.

the class DebugConfigImpl method checkMethodFilter.

private boolean checkMethodFilter(DebugContext.Scope scope) {
    if (methodFilter == null) {
        return true;
    } else {
        JavaMethod lastMethod = null;
        Iterable<Object> context = scope.getCurrentContext();
        for (Object o : context) {
            if (methodFilter != null) {
                JavaMethod method = DebugConfig.asJavaMethod(o);
                if (method != null) {
                    if (!DebugOptions.MethodFilterRootOnly.getValue(options)) {
                        if (org.graalvm.compiler.debug.MethodFilter.matches(methodFilter, method)) {
                            return true;
                        }
                    } else {
                        /*
                             * The context values operate as a stack so if we want MethodFilter to
                             * only apply to the root method we have to check only the last method
                             * seen.
                             */
                        lastMethod = method;
                    }
                }
            }
        }
        if (lastMethod != null && org.graalvm.compiler.debug.MethodFilter.matches(methodFilter, lastMethod)) {
            return true;
        }
        return false;
    }
}
Also used : JavaMethod(jdk.vm.ci.meta.JavaMethod)

Example 12 with JavaMethod

use of jdk.vm.ci.meta.JavaMethod 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 13 with JavaMethod

use of jdk.vm.ci.meta.JavaMethod 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

JavaMethod (jdk.vm.ci.meta.JavaMethod)13 ResolvedJavaMethod (jdk.vm.ci.meta.ResolvedJavaMethod)12 StructuredGraph (org.graalvm.compiler.nodes.StructuredGraph)3 DebugDumpScope (org.graalvm.compiler.debug.DebugDumpScope)2 ByteArrayOutputStream (java.io.ByteArrayOutputStream)1 PrintStream (java.io.PrintStream)1 ArrayList (java.util.ArrayList)1 Formattable (java.util.Formattable)1 Formatter (java.util.Formatter)1 InstalledCode (jdk.vm.ci.code.InstalledCode)1 ConstantPool (jdk.vm.ci.meta.ConstantPool)1 CompilationResult (org.graalvm.compiler.code.CompilationResult)1 CompilationIdentifier (org.graalvm.compiler.core.common.CompilationIdentifier)1 DebugConfig.asJavaMethod (org.graalvm.compiler.debug.DebugConfig.asJavaMethod)1 DebugContext (org.graalvm.compiler.debug.DebugContext)1 Graph (org.graalvm.compiler.graph.Graph)1 Node (org.graalvm.compiler.graph.Node)1 DirectCallTargetNode (org.graalvm.compiler.nodes.DirectCallTargetNode)1 Invoke (org.graalvm.compiler.nodes.Invoke)1 LoweredCallTargetNode (org.graalvm.compiler.nodes.LoweredCallTargetNode)1