Search in sources :

Example 1 with TruffleInlining

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

the class BasicTruffleInliningTest method testDontInlineBigWithCallSites.

@Test
public void testDontInlineBigWithCallSites() {
    // Do not inline a function if it's size * cappedCallSites is too big
    // @formatter:off
    TruffleInlining decisions = builder.target("callee", TruffleCompilerOptions.getValue(TruffleInliningMaxCallerSize) / 3).target("caller").calls("callee").calls("callee").calls("callee").buildDecisions(true);
    // @formatter:on
    assertNotInlined(decisions, "callee");
    Assert.assertTrue("Wrong reason for not inlining!", decisions.getCallSites().get(0).getProfile().getFailedReason().startsWith("deepNodeCount * callSites  >"));
}
Also used : TruffleInlining(org.graalvm.compiler.truffle.runtime.TruffleInlining) Test(org.junit.Test)

Example 2 with TruffleInlining

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

the class BasicTruffleInliningTest method testInlineBigFunctions.

@Test
public void testInlineBigFunctions() {
    // @formatter:off
    TruffleInlining decisions = builder.target("callee", TruffleCompilerOptions.getValue(TruffleInliningMaxCallerSize) - 3).target("caller").calls("callee").buildDecisions();
    // @formatter:on
    assertInlined(decisions, "callee");
}
Also used : TruffleInlining(org.graalvm.compiler.truffle.runtime.TruffleInlining) Test(org.junit.Test)

Example 3 with TruffleInlining

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

the class BasicTruffleInliningTest method testDontInlineBigFunctions.

@Test
public void testDontInlineBigFunctions() {
    // @formatter:off
    TruffleInlining decisions = builder.target("callee", TruffleCompilerOptions.getValue(TruffleInliningMaxCallerSize)).target("caller").calls("callee").buildDecisions();
    // @formatter:on
    assertNotInlined(decisions, "callee");
}
Also used : TruffleInlining(org.graalvm.compiler.truffle.runtime.TruffleInlining) Test(org.junit.Test)

Example 4 with TruffleInlining

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

the class BasicTruffleInliningTest method testDoubleRecursiveInline.

@Test
public void testDoubleRecursiveInline() {
    TruffleInlining decisions = builder.target("recursive").calls("recursive").calls("recursive").buildDecisions();
    int n = TruffleCompilerOptions.getValue(TruffleMaximumRecursiveInlining).intValue();
    // sum of geometric
    long geometricSum = 2 * (1 - ((long) Math.pow(2, n))) / (1 - 2);
    // progression a*r^n is
    // (a(1-r^n))/(1-r)
    // for 2*2^n it is
    // 2*(1-2^n)/(1-2)
    Assert.assertEquals(geometricSum, countInlines(decisions, "recursive"));
}
Also used : TruffleInlining(org.graalvm.compiler.truffle.runtime.TruffleInlining) Test(org.junit.Test)

Example 5 with TruffleInlining

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

the class BasicTruffleInliningTest method testMultipleInline.

@Test
public void testMultipleInline() {
    // @formatter:off
    TruffleInlining decisions = builder.target("callee").target("caller").calls("callee").calls("callee").buildDecisions();
    // @formatter:on
    Assert.assertTrue(countInlines(decisions, "callee") == 2);
    int inlineCount = 100;
    builder.target("callee").target("caller", inlineCount);
    for (int i = 0; i < inlineCount; i++) {
        builder.calls("callee");
    }
    Assert.assertEquals(inlineCount, countInlines(builder.buildDecisions(), "callee"));
}
Also used : TruffleInlining(org.graalvm.compiler.truffle.runtime.TruffleInlining) Test(org.junit.Test)

Aggregations

TruffleInlining (org.graalvm.compiler.truffle.runtime.TruffleInlining)21 Test (org.junit.Test)16 DebugContext (org.graalvm.compiler.debug.DebugContext)4 OptionValues (org.graalvm.compiler.options.OptionValues)4 DefaultInliningPolicy (org.graalvm.compiler.truffle.runtime.DefaultInliningPolicy)4 SpeculationLog (jdk.vm.ci.meta.SpeculationLog)2 CompilationIdentifier (org.graalvm.compiler.core.common.CompilationIdentifier)2 TruffleDebugJavaMethod (org.graalvm.compiler.truffle.common.TruffleDebugJavaMethod)2 TruffleInliningPlan (org.graalvm.compiler.truffle.common.TruffleInliningPlan)2 TruffleCompilerImpl (org.graalvm.compiler.truffle.compiler.TruffleCompilerImpl)2 GraalTruffleRuntime (org.graalvm.compiler.truffle.runtime.GraalTruffleRuntime)2 OptimizedCallTarget (org.graalvm.compiler.truffle.runtime.OptimizedCallTarget)2 RootNode (com.oracle.truffle.api.nodes.RootNode)1 ByteArrayOutputStream (java.io.ByteArrayOutputStream)1 Method (java.lang.reflect.Method)1 DebugCloseable (org.graalvm.compiler.debug.DebugCloseable)1 LogStream (org.graalvm.compiler.debug.LogStream)1 TTY (org.graalvm.compiler.debug.TTY)1 TruffleCompilerOptions (org.graalvm.compiler.truffle.common.TruffleCompilerOptions)1 TruffleOptionsOverrideScope (org.graalvm.compiler.truffle.common.TruffleCompilerOptions.TruffleOptionsOverrideScope)1