Search in sources :

Example 1 with Node

use of com.oracle.truffle.api.nodes.Node in project graal by oracle.

the class TraceCallTreeListener method logTruffleCallTree.

private void logTruffleCallTree(OptimizedCallTarget compilable, TruffleInlining inliningDecision) {
    CallTreeNodeVisitor visitor = new CallTreeNodeVisitor() {

        @Override
        public boolean visit(List<TruffleInlining> decisionStack, Node node) {
            if (node instanceof OptimizedDirectCallNode) {
                OptimizedDirectCallNode callNode = ((OptimizedDirectCallNode) node);
                int depth = decisionStack == null ? 0 : decisionStack.size() - 1;
                TruffleInliningDecision inlining = CallTreeNodeVisitor.getCurrentInliningDecision(decisionStack);
                String dispatched = "<dispatched>";
                if (inlining != null && inlining.shouldInline()) {
                    dispatched = "";
                }
                Map<String, Object> properties = new LinkedHashMap<>();
                GraalTruffleRuntimeListener.addASTSizeProperty(callNode.getCurrentCallTarget(), inliningDecision, properties);
                properties.putAll(callNode.getCurrentCallTarget().getDebugProperties(inliningDecision));
                runtime.logEvent(depth, "opt call tree", callNode.getCurrentCallTarget().toString() + dispatched, properties);
            } else if (node instanceof OptimizedIndirectCallNode) {
                int depth = decisionStack == null ? 0 : decisionStack.size() - 1;
                runtime.logEvent(depth, "opt call tree", "<indirect>", new LinkedHashMap<>());
            }
            return true;
        }
    };
    compilable.accept(visitor, inliningDecision);
}
Also used : TruffleInliningDecision(org.graalvm.compiler.truffle.runtime.TruffleInliningDecision) OptimizedIndirectCallNode(org.graalvm.compiler.truffle.runtime.OptimizedIndirectCallNode) Node(com.oracle.truffle.api.nodes.Node) OptimizedIndirectCallNode(org.graalvm.compiler.truffle.runtime.OptimizedIndirectCallNode) OptimizedDirectCallNode(org.graalvm.compiler.truffle.runtime.OptimizedDirectCallNode) List(java.util.List) OptimizedDirectCallNode(org.graalvm.compiler.truffle.runtime.OptimizedDirectCallNode) CallTreeNodeVisitor(org.graalvm.compiler.truffle.runtime.TruffleInlining.CallTreeNodeVisitor) LinkedHashMap(java.util.LinkedHashMap)

Example 2 with Node

use of com.oracle.truffle.api.nodes.Node in project graal by oracle.

the class TraceCompilationListener method onCompilationSuccess.

@Override
public void onCompilationSuccess(OptimizedCallTarget target, TruffleInlining inliningDecision, GraphInfo graph, CompilationResultInfo result) {
    long timeCompilationFinished = System.nanoTime();
    int nodeCountLowered = graph.getNodeCount();
    Times compilation = currentCompilation.get();
    int calls = 0;
    int inlinedCalls;
    if (inliningDecision == null) {
        for (Node node : target.nodeIterable(null)) {
            if (node instanceof OptimizedDirectCallNode) {
                calls++;
            }
        }
        inlinedCalls = 0;
    } else {
        calls = inliningDecision.countCalls();
        inlinedCalls = inliningDecision.countInlinedCalls();
    }
    int dispatchedCalls = calls - inlinedCalls;
    Map<String, Object> properties = new LinkedHashMap<>();
    GraalTruffleRuntimeListener.addASTSizeProperty(target, inliningDecision, properties);
    properties.put("Time", // 
    String.format(// 
    "%5.0f(%4.0f+%-4.0f)ms", // 
    (timeCompilationFinished - compilation.timeCompilationStarted) / 1e6, // 
    (compilation.timePartialEvaluationFinished - compilation.timeCompilationStarted) / 1e6, (timeCompilationFinished - compilation.timePartialEvaluationFinished) / 1e6));
    properties.put("DirectCallNodes", String.format("I %4d/D %4d", inlinedCalls, dispatchedCalls));
    properties.put("GraalNodes", String.format("%5d/%5d", compilation.nodeCountPartialEval, nodeCountLowered));
    properties.put("CodeSize", result.getTargetCodeSize());
    properties.put("CodeAddress", "0x" + Long.toHexString(target.getCodeAddress()));
    properties.put("Source", formatSourceSection(target.getRootNode().getSourceSection()));
    runtime.logEvent(0, "opt done", target.toString(), properties);
    currentCompilation.set(null);
}
Also used : Node(com.oracle.truffle.api.nodes.Node) OptimizedDirectCallNode(org.graalvm.compiler.truffle.runtime.OptimizedDirectCallNode) OptimizedDirectCallNode(org.graalvm.compiler.truffle.runtime.OptimizedDirectCallNode) LinkedHashMap(java.util.LinkedHashMap)

Example 3 with Node

use of com.oracle.truffle.api.nodes.Node in project graal by oracle.

the class TraceCompilationPolymorphismListener method onCompilationSuccess.

@Override
public void onCompilationSuccess(OptimizedCallTarget target, TruffleInlining inliningDecision, GraphInfo graph, CompilationResultInfo result) {
    for (Node node : target.nodeIterable(inliningDecision)) {
        if (node != null && (node.getCost() == NodeCost.MEGAMORPHIC || node.getCost() == NodeCost.POLYMORPHIC)) {
            NodeCost cost = node.getCost();
            Map<String, Object> props = new LinkedHashMap<>();
            props.put("simpleName", node.getClass().getSimpleName());
            props.put("subtree", "\n" + NodeUtil.printCompactTreeToString(node));
            String msg = cost == NodeCost.MEGAMORPHIC ? "megamorphic" : "polymorphic";
            runtime.logEvent(0, msg, node.toString(), props);
        }
    }
}
Also used : Node(com.oracle.truffle.api.nodes.Node) NodeCost(com.oracle.truffle.api.nodes.NodeCost) LinkedHashMap(java.util.LinkedHashMap)

Example 4 with Node

use of com.oracle.truffle.api.nodes.Node in project graal by oracle.

the class TruffleTreeDumpHandler method findNamedNodeChildren.

@SuppressWarnings("deprecation")
private static LinkedHashMap<String, Node> findNamedNodeChildren(Node node) {
    LinkedHashMap<String, Node> nodes = new LinkedHashMap<>();
    NodeClass nodeClass = NodeClass.get(node);
    for (com.oracle.truffle.api.nodes.NodeFieldAccessor field : findNodeFields(nodeClass)) {
        if (isChildField(nodeClass, field)) {
            Object value = findFieldObject(nodeClass, field, node);
            if (value != null) {
                nodes.put(findFieldName(nodeClass, field), (Node) value);
            }
        } else if (isChildrenField(nodeClass, field)) {
            Object value = findFieldObject(nodeClass, field, node);
            if (value != null) {
                Object[] children = (Object[]) value;
                for (int i = 0; i < children.length; i++) {
                    if (children[i] != null) {
                        nodes.put(findFieldName(nodeClass, field) + "[" + i + "]", (Node) children[i]);
                    }
                }
            }
        }
    }
    return nodes;
}
Also used : NodeClass(com.oracle.truffle.api.nodes.NodeClass) DirectCallNode(com.oracle.truffle.api.nodes.DirectCallNode) RootNode(com.oracle.truffle.api.nodes.RootNode) Node(com.oracle.truffle.api.nodes.Node) LinkedHashMap(java.util.LinkedHashMap)

Example 5 with Node

use of com.oracle.truffle.api.nodes.Node in project graal by oracle.

the class OptimizedOSRLoopNode method compileImpl.

private OptimizedCallTarget compileImpl(VirtualFrame frame) {
    RootNode root = getRootNode();
    Node parent = getParent();
    if (speculationLog == null) {
        speculationLog = GraalTruffleRuntime.getRuntime().createSpeculationLog();
    }
    OptimizedCallTarget osrTarget = (OptimizedCallTarget) GraalTruffleRuntime.getRuntime().createCallTarget(createRootNodeImpl(root, frame.getClass()));
    osrTarget.setSpeculationLog(speculationLog);
    // let the old parent re-adopt the children
    parent.adoptChildren();
    osrTarget.compile();
    return osrTarget;
}
Also used : RootNode(com.oracle.truffle.api.nodes.RootNode) Node(com.oracle.truffle.api.nodes.Node) LoopNode(com.oracle.truffle.api.nodes.LoopNode) RootNode(com.oracle.truffle.api.nodes.RootNode) RepeatingNode(com.oracle.truffle.api.nodes.RepeatingNode)

Aggregations

Node (com.oracle.truffle.api.nodes.Node)101 RootNode (com.oracle.truffle.api.nodes.RootNode)65 Test (org.junit.Test)46 InstrumentableNode (com.oracle.truffle.api.instrumentation.InstrumentableNode)21 ProbeNode (com.oracle.truffle.api.instrumentation.ProbeNode)21 Source (com.oracle.truffle.api.source.Source)16 NodeVisitor (com.oracle.truffle.api.nodes.NodeVisitor)11 CallTarget (com.oracle.truffle.api.CallTarget)9 TruffleObject (com.oracle.truffle.api.interop.TruffleObject)9 DirectCallNode (com.oracle.truffle.api.nodes.DirectCallNode)8 WrapperNode (com.oracle.truffle.api.instrumentation.InstrumentableNode.WrapperNode)7 TruffleRuntime (com.oracle.truffle.api.TruffleRuntime)6 SourceSection (com.oracle.truffle.api.source.SourceSection)6 TestHelper.createNode (com.oracle.truffle.api.dsl.test.TestHelper.createNode)5 ValueNode (com.oracle.truffle.api.dsl.test.TypeSystemTest.ValueNode)5 SLEvalRootNode (com.oracle.truffle.sl.nodes.SLEvalRootNode)5 SLStatementNode (com.oracle.truffle.sl.nodes.SLStatementNode)5 SLBlockNode (com.oracle.truffle.sl.nodes.controlflow.SLBlockNode)5 LinkedHashMap (java.util.LinkedHashMap)5 TruffleInstrument (com.oracle.truffle.api.instrumentation.TruffleInstrument)4