Search in sources :

Example 26 with OptimizedCallTarget

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

the class PerformanceTruffleInliningTest method testTangledGraph.

@Test
public void testTangledGraph() {
    int depth = 15;
    for (int i = 0; i < depth; i++) {
        builder.target(Integer.toString(i));
        for (int j = i; j < depth; j++) {
            builder.calls(Integer.toString(j));
        }
    }
    OptimizedCallTarget target = builder.target("main").calls("0").buildTarget();
    assertRootCallsExplored(target, 1);
    assertBudget(target);
}
Also used : OptimizedCallTarget(org.graalvm.compiler.truffle.runtime.OptimizedCallTarget) Test(org.junit.Test)

Example 27 with OptimizedCallTarget

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

the class PerformanceTruffleInliningTest method testFourTangledRecursions.

@Test
public void testFourTangledRecursions() {
    // @formatter:off
    OptimizedCallTarget target = builder.target("four").calls("four").calls("three").calls("two").calls("one").target("three").calls("three").calls("two").calls("one").calls("four").target("two").calls("two").calls("one").calls("three").calls("four").target("one").calls("one").calls("two").calls("three").calls("four").buildTarget();
    // @formatter:on
    assertRootCallsExplored(target, 1);
    assertBudget(target);
}
Also used : OptimizedCallTarget(org.graalvm.compiler.truffle.runtime.OptimizedCallTarget) Test(org.junit.Test)

Example 28 with OptimizedCallTarget

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

the class SLDisableSplittingBuiltin method disableSplitting.

@Specialization
@TruffleBoundary
public SLFunction disableSplitting(SLFunction function) {
    OptimizedCallTarget target = (OptimizedCallTarget) function.getCallTarget();
    ((SLRootNode) target.getRootNode()).setCloningAllowed(false);
    return function;
}
Also used : OptimizedCallTarget(org.graalvm.compiler.truffle.runtime.OptimizedCallTarget) SLRootNode(com.oracle.truffle.sl.nodes.SLRootNode) Specialization(com.oracle.truffle.api.dsl.Specialization) TruffleBoundary(com.oracle.truffle.api.CompilerDirectives.TruffleBoundary)

Example 29 with OptimizedCallTarget

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

the class OptimizedOSRLoopNodeTest method testOuterInvalidationTriggersOSR.

/*
     * Test outer invalidation still triggers OSR.
     */
@Theory
public void testOuterInvalidationTriggersOSR(OSRLoopFactory factory) {
    TestRepeatingNode repeating = new TestRepeatingNode();
    TestRootNode rootNode = new TestRootNode(factory, repeating);
    OptimizedCallTarget target = (OptimizedCallTarget) runtime.createCallTarget(rootNode);
    // compile inner
    target.call(OSR_THRESHOLD + 1);
    OptimizedCallTarget osrTarget = rootNode.getOSRTarget();
    assertCompiled(osrTarget);
    int i;
    for (i = 0; i < TruffleCompilerOptions.getValue(TruffleMinInvokeThreshold) - 2; i++) {
        target.call(0);
        assertNotCompiled(target);
        assertCompiled(rootNode.getOSRTarget());
    }
    target.call(0);
    assertCompiled(target);
    assertCompiled(rootNode.getOSRTarget());
    assertSame(rootNode.getOSRTarget(), osrTarget);
    target.invalidate(this, "test");
    assertNotCompiled(target);
    assertCompiled(rootNode.getOSRTarget());
    assertSame(rootNode.getOSRTarget(), osrTarget);
    // after invalidating the outer method the osr target should still be valid and used
    target.call(15);
    // even though target is compiled it is invoked in interpreter
    target.invalidate(this, "test");
    assertCompiled(rootNode.getOSRTarget());
    assertSame(rootNode.getOSRTarget(), osrTarget);
    // assertNotCompiled(target);
    // now externally invalidate the osr target and see if we compile again
    rootNode.getOSRTarget().invalidate(this, "test");
    target.call(OSR_THRESHOLD + 1);
    assertCompiled(rootNode.getOSRTarget());
}
Also used : OptimizedCallTarget(org.graalvm.compiler.truffle.runtime.OptimizedCallTarget) DataPoint(org.junit.experimental.theories.DataPoint) Theory(org.junit.experimental.theories.Theory)

Example 30 with OptimizedCallTarget

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

the class PartialEvaluationTest method compileHelper.

protected OptimizedCallTarget compileHelper(String methodName, RootNode root, Object[] arguments) {
    final OptimizedCallTarget compilable = (OptimizedCallTarget) (Truffle.getRuntime()).createCallTarget(root);
    CompilationIdentifier compilationId = getCompilationId(compilable);
    StructuredGraph actual = partialEval(compilable, arguments, AllowAssumptions.YES, compilationId);
    truffleCompiler.compilePEGraph(actual, methodName, null, compilable, asCompilationRequest(compilationId), null);
    return compilable;
}
Also used : CompilationIdentifier(org.graalvm.compiler.core.common.CompilationIdentifier) StructuredGraph(org.graalvm.compiler.nodes.StructuredGraph) OptimizedCallTarget(org.graalvm.compiler.truffle.runtime.OptimizedCallTarget)

Aggregations

OptimizedCallTarget (org.graalvm.compiler.truffle.runtime.OptimizedCallTarget)57 Test (org.junit.Test)42 RootNode (com.oracle.truffle.api.nodes.RootNode)18 FrameDescriptor (com.oracle.truffle.api.frame.FrameDescriptor)14 RootTestNode (org.graalvm.compiler.truffle.test.nodes.RootTestNode)14 VirtualFrame (com.oracle.truffle.api.frame.VirtualFrame)13 AbstractTestNode (org.graalvm.compiler.truffle.test.nodes.AbstractTestNode)11 TruffleOptionsOverrideScope (org.graalvm.compiler.truffle.common.TruffleCompilerOptions.TruffleOptionsOverrideScope)8 DirectCallNode (com.oracle.truffle.api.nodes.DirectCallNode)6 TruffleCompilerOptions (org.graalvm.compiler.truffle.common.TruffleCompilerOptions)6 Specialization (com.oracle.truffle.api.dsl.Specialization)4 CompilationIdentifier (org.graalvm.compiler.core.common.CompilationIdentifier)4 GraalTruffleRuntime (org.graalvm.compiler.truffle.runtime.GraalTruffleRuntime)4 OptimizedDirectCallNode (org.graalvm.compiler.truffle.runtime.OptimizedDirectCallNode)4 Theory (org.junit.experimental.theories.Theory)4 Assumption (com.oracle.truffle.api.Assumption)3 LoopNode (com.oracle.truffle.api.nodes.LoopNode)3 Ignore (org.junit.Ignore)3 Node (com.oracle.truffle.api.nodes.Node)2 WeakReference (java.lang.ref.WeakReference)2