Search in sources :

Example 96 with OptionValues

use of org.graalvm.compiler.options.OptionValues 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)

Example 97 with OptionValues

use of org.graalvm.compiler.options.OptionValues 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 98 with OptionValues

use of org.graalvm.compiler.options.OptionValues in project graal by oracle.

the class CompressedNullCheckTest method testExplicit.

@SuppressWarnings("try")
private void testExplicit(Integer i) {
    Assume.assumeTrue(runtime().getVMConfig().useCompressedOops);
    Container c = new Container();
    c.i = i;
    test(new OptionValues(getInitialOptions(), OptImplicitNullChecks, false), "testSnippet", c);
}
Also used : OptionValues(org.graalvm.compiler.options.OptionValues)

Example 99 with OptionValues

use of org.graalvm.compiler.options.OptionValues in project graal by oracle.

the class NodeUsagesTests method testReplaceAtUsagesWithPredicate203.

@Test
public void testReplaceAtUsagesWithPredicate203() {
    OptionValues options = getOptions();
    Graph graph = new Graph(options, getDebug(options));
    Def def0 = graph.add(new Def());
    Def def1 = graph.add(new Def());
    Use use0 = graph.add(new Use(def0, null, null));
    Use use1 = graph.add(new Use(null, def0, null));
    Use use2 = graph.add(new Use(null, null, def0));
    Use use3 = graph.add(new Use(null, null, def0));
    assertEquals(4, def0.getUsageCount());
    assertThat(def0.usages(), contains(use0));
    assertThat(def0.usages(), contains(use1));
    assertThat(def0.usages(), contains(use2));
    assertThat(def0.usages(), contains(use3));
    assertThat(def0.usages(), isNotEmpty());
    assertThat(def1.usages(), isEmpty());
    def0.replaceAtMatchingUsages(def1, u -> u == use2);
    assertEquals(1, def1.getUsageCount());
    assertThat(def1.usages(), contains(use2));
    assertThat(def1.usages(), isNotEmpty());
    assertEquals(3, def0.getUsageCount());
    assertThat(def0.usages(), contains(use0));
    assertThat(def0.usages(), contains(use1));
    assertThat(def0.usages(), contains(use3));
    assertThat(def0.usages(), isNotEmpty());
}
Also used : Graph(org.graalvm.compiler.graph.Graph) OptionValues(org.graalvm.compiler.options.OptionValues) Test(org.junit.Test)

Example 100 with OptionValues

use of org.graalvm.compiler.options.OptionValues in project graal by oracle.

the class NodeUsagesTests method testReplaceAtUsagesWithPredicate013.

@Test
public void testReplaceAtUsagesWithPredicate013() {
    OptionValues options = getOptions();
    Graph graph = new Graph(options, getDebug(options));
    Def def0 = graph.add(new Def());
    Def def1 = graph.add(new Def());
    Use use0 = graph.add(new Use(def0, null, null));
    Use use1 = graph.add(new Use(null, def0, null));
    Use use2 = graph.add(new Use(null, null, def0));
    Use use3 = graph.add(new Use(null, null, def0));
    assertEquals(4, def0.getUsageCount());
    assertThat(def0.usages(), contains(use0));
    assertThat(def0.usages(), contains(use1));
    assertThat(def0.usages(), contains(use2));
    assertThat(def0.usages(), contains(use3));
    assertThat(def0.usages(), isNotEmpty());
    assertThat(def1.usages(), isEmpty());
    def0.replaceAtMatchingUsages(def1, u -> u != use2);
    assertEquals(1, def0.getUsageCount());
    assertThat(def0.usages(), contains(use2));
    assertThat(def0.usages(), isNotEmpty());
    assertEquals(3, def1.getUsageCount());
    assertThat(def1.usages(), contains(use0));
    assertThat(def1.usages(), contains(use1));
    assertThat(def1.usages(), contains(use3));
    assertThat(def1.usages(), isNotEmpty());
}
Also used : Graph(org.graalvm.compiler.graph.Graph) OptionValues(org.graalvm.compiler.options.OptionValues) Test(org.junit.Test)

Aggregations

OptionValues (org.graalvm.compiler.options.OptionValues)158 Test (org.junit.Test)65 DebugContext (org.graalvm.compiler.debug.DebugContext)50 StructuredGraph (org.graalvm.compiler.nodes.StructuredGraph)36 ResolvedJavaMethod (jdk.vm.ci.meta.ResolvedJavaMethod)30 Graph (org.graalvm.compiler.graph.Graph)22 OptionKey (org.graalvm.compiler.options.OptionKey)16 HighTierContext (org.graalvm.compiler.phases.tiers.HighTierContext)13 Plugins (org.graalvm.compiler.nodes.graphbuilderconf.GraphBuilderConfiguration.Plugins)11 GraphBuilderConfiguration (org.graalvm.compiler.nodes.graphbuilderconf.GraphBuilderConfiguration)10 InvocationPlugins (org.graalvm.compiler.nodes.graphbuilderconf.InvocationPlugins)10 CanonicalizerPhase (org.graalvm.compiler.phases.common.CanonicalizerPhase)10 MetaAccessProvider (jdk.vm.ci.meta.MetaAccessProvider)9 DebugCloseable (org.graalvm.compiler.debug.DebugCloseable)9 GraphBuilderPhase (org.graalvm.compiler.java.GraphBuilderPhase)9 Providers (org.graalvm.compiler.phases.util.Providers)9 IOException (java.io.IOException)8 Method (java.lang.reflect.Method)8 CompilationResult (org.graalvm.compiler.code.CompilationResult)7 CompilationIdentifier (org.graalvm.compiler.core.common.CompilationIdentifier)7