Search in sources :

Example 6 with CompilationIdentifier

use of org.graalvm.compiler.core.common.CompilationIdentifier 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 7 with CompilationIdentifier

use of org.graalvm.compiler.core.common.CompilationIdentifier in project graal by oracle.

the class PartialEvaluationTest method assertPartialEvalEquals.

protected OptimizedCallTarget assertPartialEvalEquals(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);
    removeFrameStates(actual);
    StructuredGraph expected = parseForComparison(methodName, actual.getDebug());
    Assert.assertEquals(getCanonicalGraphString(expected, true, true), getCanonicalGraphString(actual, true, true));
    return compilable;
}
Also used : CompilationIdentifier(org.graalvm.compiler.core.common.CompilationIdentifier) StructuredGraph(org.graalvm.compiler.nodes.StructuredGraph) OptimizedCallTarget(org.graalvm.compiler.truffle.runtime.OptimizedCallTarget)

Example 8 with CompilationIdentifier

use of org.graalvm.compiler.core.common.CompilationIdentifier 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)

Example 9 with CompilationIdentifier

use of org.graalvm.compiler.core.common.CompilationIdentifier in project graal by oracle.

the class PerformanceWarningTest method testHelper.

@SuppressWarnings("try")
private static void testHelper(RootNode rootNode, boolean expectException, String... outputStrings) {
    GraalTruffleRuntime runtime = GraalTruffleRuntime.getRuntime();
    OptimizedCallTarget target = (OptimizedCallTarget) runtime.createCallTarget(rootNode);
    // Compile and capture output to TTY.
    ByteArrayOutputStream outContent = new ByteArrayOutputStream();
    boolean seenException = false;
    try (TTY.Filter filter = new TTY.Filter(new LogStream(outContent))) {
        try (TruffleOptionsOverrideScope scope = TruffleCompilerOptions.overrideOptions(TruffleCompilerOptions.TraceTrufflePerformanceWarnings, Boolean.TRUE);
            TruffleOptionsOverrideScope scope2 = TruffleCompilerOptions.overrideOptions(TruffleCompilerOptions.TrufflePerformanceWarningsAreFatal, Boolean.TRUE)) {
            OptionValues options = TruffleCompilerOptions.getOptions();
            DebugContext debug = DebugContext.create(options, DebugHandlersFactory.LOADER);
            try (DebugCloseable d = debug.disableIntercept();
                DebugContext.Scope s = debug.scope("PerformanceWarningTest")) {
                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);
            }
        } catch (AssertionError e) {
            seenException = true;
            if (!expectException) {
                throw new AssertionError("Unexpected exception caught", e);
            }
        }
    }
    if (expectException && !seenException) {
        Assert.assertTrue("Expected exception not caught.", false);
    }
    // Check output on TTY.
    String output = outContent.toString();
    if (outputStrings == EMPTY_PERF_WARNINGS) {
        Assert.assertEquals("", output);
    } else {
        for (String s : outputStrings) {
            Assert.assertTrue(String.format("Root node class %s: \"%s\" not found in output \"%s\"", rootNode.getClass(), s, output), output.contains(s));
        }
    }
}
Also used : CompilationIdentifier(org.graalvm.compiler.core.common.CompilationIdentifier) OptionValues(org.graalvm.compiler.options.OptionValues) TruffleCompilerImpl(org.graalvm.compiler.truffle.compiler.TruffleCompilerImpl) OptimizedCallTarget(org.graalvm.compiler.truffle.runtime.OptimizedCallTarget) ByteArrayOutputStream(java.io.ByteArrayOutputStream) LogStream(org.graalvm.compiler.debug.LogStream) DebugContext(org.graalvm.compiler.debug.DebugContext) TruffleInliningPlan(org.graalvm.compiler.truffle.common.TruffleInliningPlan) GraalTruffleRuntime(org.graalvm.compiler.truffle.runtime.GraalTruffleRuntime) DefaultInliningPolicy(org.graalvm.compiler.truffle.runtime.DefaultInliningPolicy) TruffleInlining(org.graalvm.compiler.truffle.runtime.TruffleInlining) TTY(org.graalvm.compiler.debug.TTY) TruffleOptionsOverrideScope(org.graalvm.compiler.truffle.common.TruffleCompilerOptions.TruffleOptionsOverrideScope) DebugCloseable(org.graalvm.compiler.debug.DebugCloseable)

Example 10 with CompilationIdentifier

use of org.graalvm.compiler.core.common.CompilationIdentifier in project graal by oracle.

the class GraalCompilerState method prepareRequest.

/**
 * Copies the {@link #originalGraph original graph} and prepares the {@link #request}.
 *
 * The {@link Suites} can be changed by overriding {@link #createSuites}. {@link LIRSuites} can
 * be changed by overriding {@link #createLIRSuites}.
 */
protected final void prepareRequest() {
    assert originalGraph != null : "call initialzeMethod first";
    CompilationIdentifier compilationId = backend.getCompilationIdentifier(originalGraph.method());
    graph = originalGraph.copyWithIdentifier(compilationId, originalGraph.getDebug());
    assert !graph.isFrozen();
    ResolvedJavaMethod installedCodeOwner = graph.method();
    request = new Request<>(graph, installedCodeOwner, getProviders(), getBackend(), getDefaultGraphBuilderSuite(), OptimisticOptimizations.ALL, graph.getProfilingInfo(), createSuites(getOptions()), createLIRSuites(getOptions()), new CompilationResult(graph.compilationId()), CompilationResultBuilderFactory.Default);
}
Also used : CompilationIdentifier(org.graalvm.compiler.core.common.CompilationIdentifier) CompilationResult(org.graalvm.compiler.code.CompilationResult) ResolvedJavaMethod(jdk.vm.ci.meta.ResolvedJavaMethod)

Aggregations

CompilationIdentifier (org.graalvm.compiler.core.common.CompilationIdentifier)16 DebugContext (org.graalvm.compiler.debug.DebugContext)10 StructuredGraph (org.graalvm.compiler.nodes.StructuredGraph)10 CompilationResult (org.graalvm.compiler.code.CompilationResult)7 OptionValues (org.graalvm.compiler.options.OptionValues)7 ResolvedJavaMethod (jdk.vm.ci.meta.ResolvedJavaMethod)6 OptimizedCallTarget (org.graalvm.compiler.truffle.runtime.OptimizedCallTarget)4 DebugDumpScope (org.graalvm.compiler.debug.DebugDumpScope)3 InstalledCode (jdk.vm.ci.code.InstalledCode)2 Scope (org.graalvm.compiler.debug.DebugContext.Scope)2 GraalError (org.graalvm.compiler.debug.GraalError)2 LIRSuites (org.graalvm.compiler.lir.phases.LIRSuites)2 RemoveValueProxyPhase (org.graalvm.compiler.phases.common.RemoveValueProxyPhase)2 Suites (org.graalvm.compiler.phases.tiers.Suites)2 TruffleOptionsOverrideScope (org.graalvm.compiler.truffle.common.TruffleCompilerOptions.TruffleOptionsOverrideScope)2 RootNode (com.oracle.truffle.api.nodes.RootNode)1 ByteArrayOutputStream (java.io.ByteArrayOutputStream)1 ArrayList (java.util.ArrayList)1 ServiceConfigurationError (java.util.ServiceConfigurationError)1 BailoutException (jdk.vm.ci.code.BailoutException)1