Search in sources :

Example 1 with OptimizedDirectCallNode

use of org.graalvm.compiler.truffle.runtime.OptimizedDirectCallNode in project graal by oracle.

the class ExperimentalSplittingStrategyTest method testNoSplitsDirectCallsBecauseFirstExecution.

@Test
public void testNoSplitsDirectCallsBecauseFirstExecution() {
    final OptimizedCallTarget callTarget = (OptimizedCallTarget) runtime.createCallTarget(new SplittableRootNode() {

        @Child
        private OptimizedDirectCallNode callNode = (OptimizedDirectCallNode) runtime.createDirectCallNode(runtime.createCallTarget(new SplittingTestRootNode(ExperimentalSplittingStrategyTestFactory.TurnsPolymorphicOnZeroNodeGen.create(new ReturnsArgumentNode()))));

        @Override
        public Object execute(VirtualFrame frame) {
            final Object[] first = { 1 };
            callNode.call(first);
            callNode.call(first);
            // This call turns the node polymorphic
            final Object[] second = { 0 };
            callNode.call(second);
            return null;
        }
    });
    // Multiple call nodes
    runtime.createDirectCallNode(callTarget);
    runtime.createDirectCallNode(callTarget);
    final DirectCallNode directCallNode = runtime.createDirectCallNode(callTarget);
    directCallNode.call(new Object[] { 0 });
    Assert.assertFalse("Target needs split after first execution", getNeedsSplit(callTarget));
}
Also used : VirtualFrame(com.oracle.truffle.api.frame.VirtualFrame) OptimizedCallTarget(org.graalvm.compiler.truffle.runtime.OptimizedCallTarget) OptimizedDirectCallNode(org.graalvm.compiler.truffle.runtime.OptimizedDirectCallNode) DirectCallNode(com.oracle.truffle.api.nodes.DirectCallNode) OptimizedDirectCallNode(org.graalvm.compiler.truffle.runtime.OptimizedDirectCallNode) Test(org.junit.Test)

Example 2 with OptimizedDirectCallNode

use of org.graalvm.compiler.truffle.runtime.OptimizedDirectCallNode 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 3 with OptimizedDirectCallNode

use of org.graalvm.compiler.truffle.runtime.OptimizedDirectCallNode 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)

Aggregations

OptimizedDirectCallNode (org.graalvm.compiler.truffle.runtime.OptimizedDirectCallNode)3 Node (com.oracle.truffle.api.nodes.Node)2 LinkedHashMap (java.util.LinkedHashMap)2 VirtualFrame (com.oracle.truffle.api.frame.VirtualFrame)1 DirectCallNode (com.oracle.truffle.api.nodes.DirectCallNode)1 List (java.util.List)1 OptimizedCallTarget (org.graalvm.compiler.truffle.runtime.OptimizedCallTarget)1 OptimizedIndirectCallNode (org.graalvm.compiler.truffle.runtime.OptimizedIndirectCallNode)1 CallTreeNodeVisitor (org.graalvm.compiler.truffle.runtime.TruffleInlining.CallTreeNodeVisitor)1 TruffleInliningDecision (org.graalvm.compiler.truffle.runtime.TruffleInliningDecision)1 Test (org.junit.Test)1