Search in sources :

Example 16 with RootCallTarget

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

the class OptimizedOSRLoopNodeTest method testNoInvalidationWithoutFirstExecution.

/*
     * Test that if osr compilation is forced without any execution we do not deoptimize on first
     * execution.
     */
@Theory
public void testNoInvalidationWithoutFirstExecution(OSRLoopFactory factory) {
    TestRootNode rootNode = new TestRootNode(factory, new TestRepeatingNode());
    RootCallTarget target = runtime.createCallTarget(rootNode);
    rootNode.forceOSR();
    assertCompiled(rootNode.getOSRTarget());
    // should not invalidate OSR
    target.call(1);
    assertCompiled(rootNode.getOSRTarget());
    Assert.assertTrue(rootNode.wasRepeatingCalledCompiled());
}
Also used : RootCallTarget(com.oracle.truffle.api.RootCallTarget) Theory(org.junit.experimental.theories.Theory)

Example 17 with RootCallTarget

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

the class TruffleBoundaryInliningTest method runTest.

private void runTest() {
    RootNode n1 = createRootNodeAllowInline();
    RootCallTarget c1 = runtime.createCallTarget(n1);
    StructuredGraph allowInline = partialEval((OptimizedCallTarget) c1, new Object[] {}, StructuredGraph.AllowAssumptions.YES, CompilationIdentifier.INVALID_COMPILATION_ID);
    RootNode n2 = createRootNodeNoInline();
    RootCallTarget c2 = runtime.createCallTarget(n2);
    StructuredGraph noInline = partialEval((OptimizedCallTarget) c2, new Object[] {}, StructuredGraph.AllowAssumptions.YES, CompilationIdentifier.INVALID_COMPILATION_ID);
    checkHasTestMethod(allowInline);
    checkHasTestMethod(noInline);
}
Also used : RootNode(com.oracle.truffle.api.nodes.RootNode) StructuredGraph(org.graalvm.compiler.nodes.StructuredGraph) RootCallTarget(com.oracle.truffle.api.RootCallTarget)

Example 18 with RootCallTarget

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

the class Context method parse.

@Override
protected CallTarget parse(ParsingRequest request) throws Exception {
    Source code = request.getSource();
    SourceSection outer = code.createSection(0, code.getLength());
    BaseNode node;
    try {
        node = parse(code);
    } catch (LanguageError e) {
        throw new IOException(e);
    }
    RootCallTarget afterTarget = getContextReference().get().afterTarget;
    return Truffle.getRuntime().createCallTarget(new InstrumentationTestRootNode(this, "", outer, afterTarget, node));
}
Also used : SourceSection(com.oracle.truffle.api.source.SourceSection) IOException(java.io.IOException) RootCallTarget(com.oracle.truffle.api.RootCallTarget) Source(com.oracle.truffle.api.source.Source)

Example 19 with RootCallTarget

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

the class GraalTruffleRuntime method createCallTarget.

@Override
public RootCallTarget createCallTarget(RootNode rootNode) {
    CompilerAsserts.neverPartOfCompilation();
    final RootCallTarget newCallTarget = createClonedCallTarget(null, rootNode);
    TruffleSplittingStrategy.newTargetCreated(tvmci, newCallTarget);
    return newCallTarget;
}
Also used : RootCallTarget(com.oracle.truffle.api.RootCallTarget)

Example 20 with RootCallTarget

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

the class TruffleTreeDumpHandler method dumpInlinedTrees.

private static void dumpInlinedTrees(GraphOutput<AST, ?> output, final RootCallTarget callTarget, TruffleInlining inlining, List<RootCallTarget> dumped) throws IOException {
    for (DirectCallNode callNode : NodeUtil.findAllNodeInstances(callTarget.getRootNode(), DirectCallNode.class)) {
        CallTarget inlinedCallTarget = callNode.getCurrentCallTarget();
        if (inlinedCallTarget instanceof RootCallTarget && callNode instanceof OptimizedDirectCallNode) {
            TruffleInliningDecision decision = inlining.findByCall((OptimizedDirectCallNode) callNode);
            if (decision != null && decision.shouldInline()) {
                final RootCallTarget rootCallTarget = (RootCallTarget) inlinedCallTarget;
                if (!dumped.contains(rootCallTarget)) {
                    AST ast = new AST(rootCallTarget);
                    output.beginGroup(ast, inlinedCallTarget.toString(), rootCallTarget.getRootNode().getName(), null, 0, DebugContext.addVersionProperties(null));
                    output.print(ast, Collections.emptyMap(), 0, AFTER_PROFILING);
                    output.endGroup();
                    dumped.add(rootCallTarget);
                    dumpInlinedTrees(output, (OptimizedCallTarget) inlinedCallTarget, decision, dumped);
                }
            }
        }
    }
}
Also used : RootCallTarget(com.oracle.truffle.api.RootCallTarget) CallTarget(com.oracle.truffle.api.CallTarget) DirectCallNode(com.oracle.truffle.api.nodes.DirectCallNode) 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