Search in sources :

Example 6 with PhaseContext

use of org.graalvm.compiler.phases.tiers.PhaseContext in project graal by oracle.

the class UnsafeVirtualizationTest method testPartialEscapeReadElimination.

public void testPartialEscapeReadElimination(String snippet, boolean canonicalizeBefore, Object... args) {
    assert AF1Offset % 8 == 0 : "First of the two int-fields must be 8-byte aligned";
    ResolvedJavaMethod method = getResolvedJavaMethod(snippet);
    StructuredGraph graph = parseEager(snippet, AllowAssumptions.NO);
    OptionValues options = graph.getOptions();
    PhaseContext context = getDefaultHighTierContext();
    CanonicalizerPhase canonicalizer = new CanonicalizerPhase();
    if (canonicalizeBefore) {
        canonicalizer.apply(graph, context);
    }
    Result r = executeExpected(method, null, args);
    new PartialEscapePhase(true, true, canonicalizer, null, options).apply(graph, context);
    try {
        InstalledCode code = getCode(method, graph);
        Object result = code.executeVarargs(args);
        assertEquals(r, new Result(result, null));
    } catch (Throwable e) {
        assertFalse(true, e.toString());
    }
}
Also used : PhaseContext(org.graalvm.compiler.phases.tiers.PhaseContext) PartialEscapePhase(org.graalvm.compiler.virtual.phases.ea.PartialEscapePhase) StructuredGraph(org.graalvm.compiler.nodes.StructuredGraph) OptionValues(org.graalvm.compiler.options.OptionValues) InstalledCode(jdk.vm.ci.code.InstalledCode) CanonicalizerPhase(org.graalvm.compiler.phases.common.CanonicalizerPhase) ResolvedJavaMethod(jdk.vm.ci.meta.ResolvedJavaMethod)

Example 7 with PhaseContext

use of org.graalvm.compiler.phases.tiers.PhaseContext in project graal by oracle.

the class StraighteningTest method test.

private void test(final String snippet) {
    // No debug scope to reduce console noise for @Test(expected = ...) tests
    StructuredGraph graph = parseEager(snippet, AllowAssumptions.YES);
    DebugContext debug = graph.getDebug();
    debug.dump(DebugContext.BASIC_LEVEL, graph, "Graph");
    new CanonicalizerPhase().apply(graph, new PhaseContext(getProviders()));
    StructuredGraph referenceGraph = parseEager(REFERENCE_SNIPPET, AllowAssumptions.YES);
    assertEquals(referenceGraph, graph);
}
Also used : PhaseContext(org.graalvm.compiler.phases.tiers.PhaseContext) StructuredGraph(org.graalvm.compiler.nodes.StructuredGraph) CanonicalizerPhase(org.graalvm.compiler.phases.common.CanonicalizerPhase) DebugContext(org.graalvm.compiler.debug.DebugContext)

Example 8 with PhaseContext

use of org.graalvm.compiler.phases.tiers.PhaseContext in project graal by oracle.

the class TypeSystemTest method test.

private void test(String snippet, String referenceSnippet) {
    StructuredGraph graph = parseEager(snippet, AllowAssumptions.NO);
    DebugContext debug = graph.getDebug();
    debug.dump(DebugContext.BASIC_LEVEL, graph, "Graph");
    /*
         * When using FlowSensitiveReductionPhase instead of ConditionalEliminationPhase,
         * tail-duplication gets activated thus resulting in a graph with more nodes than the
         * reference graph.
         */
    new ConditionalEliminationPhase(false).apply(graph, new PhaseContext(getProviders()));
    new CanonicalizerPhase().apply(graph, new PhaseContext(getProviders()));
    // a second canonicalizer is needed to process nested MaterializeNodes
    new CanonicalizerPhase().apply(graph, new PhaseContext(getProviders()));
    StructuredGraph referenceGraph = parseEager(referenceSnippet, AllowAssumptions.NO);
    new ConditionalEliminationPhase(false).apply(referenceGraph, new PhaseContext(getProviders()));
    new CanonicalizerPhase().apply(referenceGraph, new PhaseContext(getProviders()));
    new CanonicalizerPhase().apply(referenceGraph, new PhaseContext(getProviders()));
    assertEquals(referenceGraph, graph);
}
Also used : PhaseContext(org.graalvm.compiler.phases.tiers.PhaseContext) StructuredGraph(org.graalvm.compiler.nodes.StructuredGraph) ConditionalEliminationPhase(org.graalvm.compiler.phases.common.ConditionalEliminationPhase) CanonicalizerPhase(org.graalvm.compiler.phases.common.CanonicalizerPhase) DebugContext(org.graalvm.compiler.debug.DebugContext)

Example 9 with PhaseContext

use of org.graalvm.compiler.phases.tiers.PhaseContext in project graal by oracle.

the class TypeSystemTest method testHelper.

private <T extends Node> void testHelper(String snippet, Class<T> clazz) {
    StructuredGraph graph = parseEager(snippet, AllowAssumptions.NO);
    new CanonicalizerPhase().apply(graph, new PhaseContext(getProviders()));
    new CanonicalizerPhase().apply(graph, new PhaseContext(getProviders()));
    DebugContext debug = graph.getDebug();
    debug.dump(DebugContext.BASIC_LEVEL, graph, "Graph " + snippet);
    Assert.assertFalse("shouldn't have nodes of type " + clazz, graph.getNodes().filter(clazz).iterator().hasNext());
}
Also used : PhaseContext(org.graalvm.compiler.phases.tiers.PhaseContext) StructuredGraph(org.graalvm.compiler.nodes.StructuredGraph) CanonicalizerPhase(org.graalvm.compiler.phases.common.CanonicalizerPhase) DebugContext(org.graalvm.compiler.debug.DebugContext)

Example 10 with PhaseContext

use of org.graalvm.compiler.phases.tiers.PhaseContext in project graal by oracle.

the class UnsafeReadEliminationTest method testPartialEscapeReadElimination.

public void testPartialEscapeReadElimination(StructuredGraph graph, int reads, int writes) {
    OptionValues options = graph.getOptions();
    PhaseContext context = getDefaultHighTierContext();
    CanonicalizerPhase canonicalizer = new CanonicalizerPhase();
    canonicalizer.apply(graph, context);
    new PartialEscapePhase(true, true, canonicalizer, null, options).apply(graph, context);
    Assert.assertEquals(3, graph.getNodes().filter(UnsafeAccessNode.class).count());
    // after lowering the same applies for reads and writes
    new LoweringPhase(canonicalizer, LoweringTool.StandardLoweringStage.HIGH_TIER).apply(graph, context);
    canonicalizer.apply(graph, context);
    new PartialEscapePhase(true, true, canonicalizer, null, options).apply(graph, context);
    Assert.assertEquals(reads, graph.getNodes().filter(ReadNode.class).count());
    Assert.assertEquals(writes, graph.getNodes().filter(WriteNode.class).count());
}
Also used : PhaseContext(org.graalvm.compiler.phases.tiers.PhaseContext) PartialEscapePhase(org.graalvm.compiler.virtual.phases.ea.PartialEscapePhase) OptionValues(org.graalvm.compiler.options.OptionValues) LoweringPhase(org.graalvm.compiler.phases.common.LoweringPhase) CanonicalizerPhase(org.graalvm.compiler.phases.common.CanonicalizerPhase)

Aggregations

PhaseContext (org.graalvm.compiler.phases.tiers.PhaseContext)60 CanonicalizerPhase (org.graalvm.compiler.phases.common.CanonicalizerPhase)59 StructuredGraph (org.graalvm.compiler.nodes.StructuredGraph)56 DebugContext (org.graalvm.compiler.debug.DebugContext)24 LoweringPhase (org.graalvm.compiler.phases.common.LoweringPhase)19 Test (org.junit.Test)18 HighTierContext (org.graalvm.compiler.phases.tiers.HighTierContext)8 ConditionalEliminationPhase (org.graalvm.compiler.phases.common.ConditionalEliminationPhase)7 FloatingReadPhase (org.graalvm.compiler.phases.common.FloatingReadPhase)7 GraalCompilerTest (org.graalvm.compiler.core.test.GraalCompilerTest)6 DebugDumpScope (org.graalvm.compiler.debug.DebugDumpScope)6 FrameState (org.graalvm.compiler.nodes.FrameState)6 GraphBuilderConfiguration (org.graalvm.compiler.nodes.graphbuilderconf.GraphBuilderConfiguration)6 ResolvedJavaMethod (jdk.vm.ci.meta.ResolvedJavaMethod)5 Node (org.graalvm.compiler.graph.Node)5 OptionValues (org.graalvm.compiler.options.OptionValues)5 GuardLoweringPhase (org.graalvm.compiler.phases.common.GuardLoweringPhase)5 IterativeConditionalEliminationPhase (org.graalvm.compiler.phases.common.IterativeConditionalEliminationPhase)4 InliningPhase (org.graalvm.compiler.phases.common.inlining.InliningPhase)4 PartialEscapePhase (org.graalvm.compiler.virtual.phases.ea.PartialEscapePhase)4