Search in sources :

Example 1 with RootCallTarget

use of com.oracle.truffle.api.RootCallTarget in project graal by oracle.

the class ExperimentalSplittingStrategyTest method testDoesNotSplitDirectCallHelper.

private void testDoesNotSplitDirectCallHelper(OptimizedCallTarget callTarget, Object[] firstArgs, Object[] secondArgs) {
    final RootCallTarget outer = runtime.createCallTarget(new CallsInnerNode(callTarget));
    outer.call(firstArgs);
    Assert.assertFalse("Target needs split before the node went polymorphic", getNeedsSplit(callTarget));
    outer.call(firstArgs);
    Assert.assertFalse("Target needs split before the node went polymorphic", getNeedsSplit(callTarget));
    outer.call(secondArgs);
    Assert.assertFalse("Target needs split even though it has only one caller", getNeedsSplit(callTarget));
    // Test new dirrectCallNode will NOT split
    final DirectCallNode newCallNode = runtime.createDirectCallNode(callTarget);
    newCallNode.call(secondArgs);
    Assert.assertFalse("new call node to \"needs split\" target is not split", newCallNode.isCallTargetCloned());
}
Also used : RootCallTarget(com.oracle.truffle.api.RootCallTarget) DirectCallNode(com.oracle.truffle.api.nodes.DirectCallNode) OptimizedDirectCallNode(org.graalvm.compiler.truffle.runtime.OptimizedDirectCallNode)

Example 2 with RootCallTarget

use of com.oracle.truffle.api.RootCallTarget in project graal by oracle.

the class ExperimentalSplittingStrategyTest method testIncreaseInPolymorphism.

@Test
public void testIncreaseInPolymorphism() {
    OptimizedCallTarget callTarget = (OptimizedCallTarget) runtime.createCallTarget(new SplittingTestRootNode(ExperimentalSplittingStrategyTestFactory.TurnsPolymorphicOnZeroNodeGen.create(new ReturnsArgumentNode())));
    final RootCallTarget outerTarget = runtime.createCallTarget(new CallsInnerNode(callTarget));
    Object[] firstArgs = new Object[] { 1 };
    outerTarget.call(firstArgs);
    Assert.assertFalse("Target needs split before the node went polymorphic", getNeedsSplit(callTarget));
    outerTarget.call(firstArgs);
    Assert.assertFalse("Target needs split before the node went polymorphic", getNeedsSplit(callTarget));
    Object[] secondArgs = new Object[] { 0 };
    // Turns polymorphic
    outerTarget.call(secondArgs);
    Assert.assertFalse("Target needs split even though there is only 1 caller", getNeedsSplit(callTarget));
    // Add second caller
    final DirectCallNode directCallNode = runtime.createDirectCallNode(callTarget);
    outerTarget.call(secondArgs);
    Assert.assertFalse("Target needs split with no increase in polymorphism", getNeedsSplit(callTarget));
    outerTarget.call(new Object[] { "foo" });
    Assert.assertTrue("Target does not need split after increase in polymorphism", getNeedsSplit(callTarget));
    // Test new dirrectCallNode will split
    outerTarget.call(firstArgs);
    directCallNode.call(firstArgs);
    Assert.assertTrue("new call node to \"needs split\" target is not split", directCallNode.isCallTargetCloned());
}
Also used : OptimizedCallTarget(org.graalvm.compiler.truffle.runtime.OptimizedCallTarget) RootCallTarget(com.oracle.truffle.api.RootCallTarget) DirectCallNode(com.oracle.truffle.api.nodes.DirectCallNode) OptimizedDirectCallNode(org.graalvm.compiler.truffle.runtime.OptimizedDirectCallNode) Test(org.junit.Test)

Example 3 with RootCallTarget

use of com.oracle.truffle.api.RootCallTarget in project graal by oracle.

the class ExperimentalSplittingStrategyTest method testSoloTarget.

@Test
public void testSoloTarget() {
    final ExposesReportPolymorphicSpecializeRootNode rootNode = new ExposesReportPolymorphicSpecializeRootNode();
    final RootCallTarget callTarget = runtime.createCallTarget(rootNode);
    callTarget.call(noArguments);
    rootNode.report();
}
Also used : RootCallTarget(com.oracle.truffle.api.RootCallTarget) Test(org.junit.Test)

Example 4 with RootCallTarget

use of com.oracle.truffle.api.RootCallTarget in project graal by oracle.

the class CastExactPartialEvaluationTest method testCommon.

private void testCommon(AbstractTestNode testNode, String testName) {
    FrameDescriptor fd = new FrameDescriptor();
    RootNode rootNode = new RootTestNode(fd, testName, testNode);
    RootCallTarget callTarget = Truffle.getRuntime().createCallTarget(rootNode);
    Assert.assertEquals(42, callTarget.call(newBuffer()));
    assertPartialEvalNoInvokes(callTarget, new Object[] { newBuffer() });
}
Also used : FrameDescriptor(com.oracle.truffle.api.frame.FrameDescriptor) RootNode(com.oracle.truffle.api.nodes.RootNode) RootCallTarget(com.oracle.truffle.api.RootCallTarget) RootTestNode(org.graalvm.compiler.truffle.test.nodes.RootTestNode)

Example 5 with RootCallTarget

use of com.oracle.truffle.api.RootCallTarget in project graal by oracle.

the class TruffleTreeDumpHandler method dumpASTAndCallTrees.

private static void dumpASTAndCallTrees(DebugContext debug, TruffleTreeDump truffleTreeDump) throws IOException {
    final RootCallTarget callTarget = truffleTreeDump.callTarget;
    if (callTarget.getRootNode() != null && callTarget instanceof OptimizedCallTarget) {
        AST ast = new AST(callTarget);
        final GraphOutput<AST, ?> astOutput = debug.buildOutput(GraphOutput.newBuilder(AST_DUMP_STRUCTURE).blocks(AST_DUMP_STRUCTURE));
        astOutput.beginGroup(ast, "AST", "AST", null, 0, DebugContext.addVersionProperties(null));
        astOutput.print(ast, Collections.emptyMap(), 0, AFTER_PROFILING);
        final TruffleInlining inlining = truffleTreeDump.inlining;
        if (inlining.countInlinedCalls() > 0) {
            dumpInlinedTrees(astOutput, callTarget, inlining, new ArrayList<>());
            ast.inline(truffleTreeDump.inlining);
            astOutput.print(ast, null, 1, AFTER_INLINING);
        }
        // AST
        astOutput.endGroup();
        astOutput.close();
        CallTree callTree = new CallTree(truffleTreeDump.callTarget, null);
        final GraphOutput<CallTree, ?> callTreeOutput = debug.buildOutput(GraphOutput.newBuilder(CALL_GRAPH_DUMP_STRUCTURE).blocks(CALL_GRAPH_DUMP_STRUCTURE));
        callTreeOutput.beginGroup(null, "Call Tree", "Call Tree", null, 0, DebugContext.addVersionProperties(null));
        callTreeOutput.print(callTree, null, 0, AFTER_PROFILING);
        if (inlining.countInlinedCalls() > 0) {
            callTree = new CallTree(truffleTreeDump.callTarget, truffleTreeDump.inlining);
            callTreeOutput.print(callTree, null, 0, AFTER_INLINING);
        }
        // Call Tree
        callTreeOutput.endGroup();
        callTreeOutput.close();
    }
}
Also used : RootCallTarget(com.oracle.truffle.api.RootCallTarget)

Aggregations

RootCallTarget (com.oracle.truffle.api.RootCallTarget)26 RootNode (com.oracle.truffle.api.nodes.RootNode)8 CallTarget (com.oracle.truffle.api.CallTarget)4 DirectCallNode (com.oracle.truffle.api.nodes.DirectCallNode)4 Source (com.oracle.truffle.api.source.Source)4 Test (org.junit.Test)4 FrameDescriptor (com.oracle.truffle.api.frame.FrameDescriptor)3 StackPointer (com.oracle.truffle.llvm.runtime.memory.LLVMStack.StackPointer)3 TruffleObject (com.oracle.truffle.api.interop.TruffleObject)2 SourceSection (com.oracle.truffle.api.source.SourceSection)2 GlobalValueSymbol (com.oracle.truffle.llvm.parser.model.symbols.globals.GlobalValueSymbol)2 LLVMContext (com.oracle.truffle.llvm.runtime.LLVMContext)2 LLVMExpressionNode (com.oracle.truffle.llvm.runtime.nodes.api.LLVMExpressionNode)2 OptimizedDirectCallNode (org.graalvm.compiler.truffle.runtime.OptimizedDirectCallNode)2 RootTestNode (org.graalvm.compiler.truffle.test.nodes.RootTestNode)2 TruffleBoundary (com.oracle.truffle.api.CompilerDirectives.TruffleBoundary)1 Truffle (com.oracle.truffle.api.Truffle)1 TruffleContext (com.oracle.truffle.api.TruffleContext)1 Env (com.oracle.truffle.api.TruffleLanguage.Env)1 ControlFlowException (com.oracle.truffle.api.nodes.ControlFlowException)1