Search in sources :

Example 6 with TruffleInlining

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

the class BasicTruffleInliningTest method testTruffleFunctionInliningFlag.

@Test
@SuppressWarnings("try")
public void testTruffleFunctionInliningFlag() {
    try (TruffleCompilerOptions.TruffleOptionsOverrideScope scope = overrideOptions(TruffleFunctionInlining, false)) {
        // @formatter:off
        TruffleInlining decisions = builder.target("callee").target("caller").calls("callee", 2).buildDecisions();
        // @formatter:on
        Assert.assertTrue("Decisions where made!", decisions.getCallSites().isEmpty());
    }
}
Also used : TruffleInlining(org.graalvm.compiler.truffle.runtime.TruffleInlining) TruffleCompilerOptions(org.graalvm.compiler.truffle.common.TruffleCompilerOptions) Test(org.junit.Test)

Example 7 with TruffleInlining

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

the class TransferToInterpreterTest method test.

@Test
public void test() {
    RootNode rootNode = new TestRootNode();
    GraalTruffleRuntime runtime = GraalTruffleRuntime.getRuntime();
    OptimizedCallTarget target = (OptimizedCallTarget) runtime.createCallTarget(rootNode);
    target.call(0);
    Assert.assertFalse(target.isValid());
    OptionValues options = TruffleCompilerOptions.getOptions();
    DebugContext debug = DebugContext.create(options, DebugHandlersFactory.LOADER);
    final OptimizedCallTarget compilable = target;
    TruffleCompilerImpl compiler = (TruffleCompilerImpl) runtime.newTruffleCompiler();
    CompilationIdentifier compilationId = compiler.getCompilationIdentifier(compilable);
    TruffleInliningPlan inliningPlan = new TruffleInlining(compilable, new DefaultInliningPolicy());
    compiler.compileAST(debug, compilable, inliningPlan, compilationId, null, null);
    Assert.assertTrue(target.isValid());
    target.call(0);
    Assert.assertTrue(target.isValid());
    target.call(1);
    Assert.assertFalse(target.isValid());
}
Also used : RootNode(com.oracle.truffle.api.nodes.RootNode) TruffleInliningPlan(org.graalvm.compiler.truffle.common.TruffleInliningPlan) CompilationIdentifier(org.graalvm.compiler.core.common.CompilationIdentifier) OptionValues(org.graalvm.compiler.options.OptionValues) TruffleCompilerImpl(org.graalvm.compiler.truffle.compiler.TruffleCompilerImpl) GraalTruffleRuntime(org.graalvm.compiler.truffle.runtime.GraalTruffleRuntime) DefaultInliningPolicy(org.graalvm.compiler.truffle.runtime.DefaultInliningPolicy) TruffleInlining(org.graalvm.compiler.truffle.runtime.TruffleInlining) OptimizedCallTarget(org.graalvm.compiler.truffle.runtime.OptimizedCallTarget) DebugContext(org.graalvm.compiler.debug.DebugContext) Test(org.junit.Test)

Example 8 with TruffleInlining

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

the class PerformanceTruffleInliningTest method assertRootCallsExplored.

private static void assertRootCallsExplored(OptimizedCallTarget target, int explored) {
    final TruffleInlining truffleInliningDecisions = new TruffleInlining(target, POLICY);
    int knowsCallSites = 0;
    for (TruffleInliningDecision decision : truffleInliningDecisions) {
        if (decision.getCallSites().size() > 0) {
            knowsCallSites++;
        }
    }
    // The exploration brudged should be blown before exploring the other 2 call sites of the
    // root
    Assert.assertEquals("Only one target should not know about it's call sites!", explored, knowsCallSites);
}
Also used : TruffleInliningDecision(org.graalvm.compiler.truffle.runtime.TruffleInliningDecision) TruffleInlining(org.graalvm.compiler.truffle.runtime.TruffleInlining)

Example 9 with TruffleInlining

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

the class TruffleToTruffleCallExceptionHandlerTest method partialEval.

@SuppressWarnings("try")
private static StructuredGraph partialEval(OptimizedCallTarget compilable, Object[] arguments, AllowAssumptions allowAssumptions) {
    compilable.call(arguments);
    compilable.call(arguments);
    compilable.call(arguments);
    OptionValues options = TruffleCompilerOptions.getOptions();
    DebugContext debug = DebugContext.create(options, DebugHandlersFactory.LOADER);
    try (DebugContext.Scope s = debug.scope("TruffleCompilation", new TruffleDebugJavaMethod(compilable))) {
        TruffleInlining inliningDecision = new TruffleInlining(compilable, new DefaultInliningPolicy());
        SpeculationLog speculationLog = compilable.getSpeculationLog();
        return truffleCompiler.getPartialEvaluator().createGraph(debug, compilable, inliningDecision, allowAssumptions, INVALID_COMPILATION_ID, speculationLog, null);
    } catch (Throwable e) {
        throw debug.handle(e);
    }
}
Also used : SpeculationLog(jdk.vm.ci.meta.SpeculationLog) OptionValues(org.graalvm.compiler.options.OptionValues) DefaultInliningPolicy(org.graalvm.compiler.truffle.runtime.DefaultInliningPolicy) TruffleInlining(org.graalvm.compiler.truffle.runtime.TruffleInlining) TruffleDebugJavaMethod(org.graalvm.compiler.truffle.common.TruffleDebugJavaMethod) DebugContext(org.graalvm.compiler.debug.DebugContext)

Example 10 with TruffleInlining

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

the class PartialEvaluationTest method partialEval.

@SuppressWarnings("try")
protected StructuredGraph partialEval(OptimizedCallTarget compilable, Object[] arguments, AllowAssumptions allowAssumptions, CompilationIdentifier compilationId) {
    // Executed AST so that all classes are loaded and initialized.
    compilable.call(arguments);
    compilable.call(arguments);
    compilable.call(arguments);
    OptionValues options = TruffleCompilerOptions.getOptions();
    DebugContext debug = getDebugContext(options);
    try (DebugContext.Scope s = debug.scope("TruffleCompilation", new TruffleDebugJavaMethod(compilable))) {
        TruffleInlining inliningDecision = new TruffleInlining(compilable, new DefaultInliningPolicy());
        SpeculationLog speculationLog = compilable.getSpeculationLog();
        return truffleCompiler.getPartialEvaluator().createGraph(debug, compilable, inliningDecision, allowAssumptions, compilationId, speculationLog, null);
    } catch (Throwable e) {
        throw debug.handle(e);
    }
}
Also used : SpeculationLog(jdk.vm.ci.meta.SpeculationLog) OptionValues(org.graalvm.compiler.options.OptionValues) DefaultInliningPolicy(org.graalvm.compiler.truffle.runtime.DefaultInliningPolicy) TruffleInlining(org.graalvm.compiler.truffle.runtime.TruffleInlining) TruffleDebugJavaMethod(org.graalvm.compiler.truffle.common.TruffleDebugJavaMethod) DebugContext(org.graalvm.compiler.debug.DebugContext)

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