Search in sources :

Example 1 with OptimizedIndirectCallNode

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

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

the class IndirectCallSiteTest method testIndirectCallNodeDoesNotDeopOnFirstCall.

@Test
public void testIndirectCallNodeDoesNotDeopOnFirstCall() {
    final Object[] noArguments = new Object[0];
    final OptimizedCallTarget innerTarget = (OptimizedCallTarget) runtime.createCallTarget(new RootNode(null) {

        @Override
        public Object execute(VirtualFrame frame) {
            return null;
        }
    });
    final OptimizedCallTarget uninitializedInnerTarget = (OptimizedCallTarget) runtime.createCallTarget(new RootNode(null) {

        @Override
        public Object execute(VirtualFrame frame) {
            return null;
        }
    });
    final OptimizedCallTarget outerTarget = (OptimizedCallTarget) runtime.createCallTarget(new RootNode(null) {

        @Child
        OptimizedIndirectCallNode indirectCallNode = (OptimizedIndirectCallNode) runtime.createIndirectCallNode();

        @Override
        public Object execute(VirtualFrame frame) {
            if (frame.getArguments().length == 0) {
                return indirectCallNode.call(innerTarget, noArguments);
            } else {
                return indirectCallNode.call(uninitializedInnerTarget, noArguments);
            }
        }
    });
    final int compilationThreshold = TruffleCompilerOptions.getValue(TruffleCompilationThreshold);
    for (int i = 0; i < compilationThreshold; i++) {
        outerTarget.call(noArguments);
    }
    assertCompiled(outerTarget);
    outerTarget.call(new Object[] { null });
    assertCompiled(outerTarget);
}
Also used : VirtualFrame(com.oracle.truffle.api.frame.VirtualFrame) RootNode(com.oracle.truffle.api.nodes.RootNode) OptimizedIndirectCallNode(org.graalvm.compiler.truffle.runtime.OptimizedIndirectCallNode) OptimizedCallTarget(org.graalvm.compiler.truffle.runtime.OptimizedCallTarget) Test(org.junit.Test)

Aggregations

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