Search in sources :

Example 6 with PartialEscapePhase

use of org.graalvm.compiler.virtual.phases.ea.PartialEscapePhase in project graal by oracle.

the class EscapeAnalysisTest method testFullyUnrolledLoop.

@Test
public void testFullyUnrolledLoop() {
    prepareGraph("testFullyUnrolledLoopSnippet", false);
    new LoopFullUnrollPhase(new CanonicalizerPhase(), new DefaultLoopPolicies()).apply(graph, context);
    new PartialEscapePhase(false, new CanonicalizerPhase(), graph.getOptions()).apply(graph, context);
    Assert.assertEquals(1, returnNodes.size());
    Assert.assertTrue(returnNodes.get(0).result() instanceof AllocatedObjectNode);
    CommitAllocationNode commit = ((AllocatedObjectNode) returnNodes.get(0).result()).getCommit();
    Assert.assertEquals(2, commit.getValues().size());
    Assert.assertEquals(1, commit.getVirtualObjects().size());
    Assert.assertTrue("non-cyclic data structure expected", commit.getVirtualObjects().get(0) != commit.getValues().get(0));
}
Also used : LoopFullUnrollPhase(org.graalvm.compiler.loop.phases.LoopFullUnrollPhase) PartialEscapePhase(org.graalvm.compiler.virtual.phases.ea.PartialEscapePhase) AllocatedObjectNode(org.graalvm.compiler.nodes.virtual.AllocatedObjectNode) DefaultLoopPolicies(org.graalvm.compiler.loop.DefaultLoopPolicies) CanonicalizerPhase(org.graalvm.compiler.phases.common.CanonicalizerPhase) CommitAllocationNode(org.graalvm.compiler.nodes.virtual.CommitAllocationNode) Test(org.junit.Test)

Example 7 with PartialEscapePhase

use of org.graalvm.compiler.virtual.phases.ea.PartialEscapePhase 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 8 with PartialEscapePhase

use of org.graalvm.compiler.virtual.phases.ea.PartialEscapePhase 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)

Example 9 with PartialEscapePhase

use of org.graalvm.compiler.virtual.phases.ea.PartialEscapePhase in project graal by oracle.

the class BoxingEliminationTest method compareGraphs.

private void compareGraphs(final String snippet, final String referenceSnippet, final boolean loopPeeling, final boolean excludeVirtual) {
    graph = parseEager(snippet, AllowAssumptions.NO);
    HighTierContext context = getDefaultHighTierContext();
    CanonicalizerPhase canonicalizer = new CanonicalizerPhase();
    canonicalizer.apply(graph, context);
    new InliningPhase(new CanonicalizerPhase()).apply(graph, context);
    if (loopPeeling) {
        new LoopPeelingPhase(new DefaultLoopPolicies()).apply(graph, context);
    }
    new DeadCodeEliminationPhase().apply(graph);
    canonicalizer.apply(graph, context);
    new PartialEscapePhase(false, canonicalizer, graph.getOptions()).apply(graph, context);
    new DeadCodeEliminationPhase().apply(graph);
    canonicalizer.apply(graph, context);
    StructuredGraph referenceGraph = parseEager(referenceSnippet, AllowAssumptions.YES);
    new InliningPhase(new CanonicalizerPhase()).apply(referenceGraph, context);
    new DeadCodeEliminationPhase().apply(referenceGraph);
    new CanonicalizerPhase().apply(referenceGraph, context);
    assertEquals(referenceGraph, graph, excludeVirtual, true);
}
Also used : LoopPeelingPhase(org.graalvm.compiler.loop.phases.LoopPeelingPhase) PartialEscapePhase(org.graalvm.compiler.virtual.phases.ea.PartialEscapePhase) StructuredGraph(org.graalvm.compiler.nodes.StructuredGraph) DefaultLoopPolicies(org.graalvm.compiler.loop.DefaultLoopPolicies) CanonicalizerPhase(org.graalvm.compiler.phases.common.CanonicalizerPhase) HighTierContext(org.graalvm.compiler.phases.tiers.HighTierContext) InliningPhase(org.graalvm.compiler.phases.common.inlining.InliningPhase) DeadCodeEliminationPhase(org.graalvm.compiler.phases.common.DeadCodeEliminationPhase)

Example 10 with PartialEscapePhase

use of org.graalvm.compiler.virtual.phases.ea.PartialEscapePhase in project graal by oracle.

the class BoxingEliminationTest method processMethod.

private void processMethod(final String snippet) {
    graph = parseEager(snippet, AllowAssumptions.NO);
    HighTierContext context = getDefaultHighTierContext();
    new InliningPhase(new CanonicalizerPhase()).apply(graph, context);
    new PartialEscapePhase(false, new CanonicalizerPhase(), graph.getOptions()).apply(graph, context);
}
Also used : PartialEscapePhase(org.graalvm.compiler.virtual.phases.ea.PartialEscapePhase) CanonicalizerPhase(org.graalvm.compiler.phases.common.CanonicalizerPhase) HighTierContext(org.graalvm.compiler.phases.tiers.HighTierContext) InliningPhase(org.graalvm.compiler.phases.common.inlining.InliningPhase)

Aggregations

PartialEscapePhase (org.graalvm.compiler.virtual.phases.ea.PartialEscapePhase)15 CanonicalizerPhase (org.graalvm.compiler.phases.common.CanonicalizerPhase)14 StructuredGraph (org.graalvm.compiler.nodes.StructuredGraph)8 InliningPhase (org.graalvm.compiler.phases.common.inlining.InliningPhase)7 HighTierContext (org.graalvm.compiler.phases.tiers.HighTierContext)7 Test (org.junit.Test)5 PhaseContext (org.graalvm.compiler.phases.tiers.PhaseContext)4 ResolvedJavaMethod (jdk.vm.ci.meta.ResolvedJavaMethod)3 DebugContext (org.graalvm.compiler.debug.DebugContext)2 DefaultLoopPolicies (org.graalvm.compiler.loop.DefaultLoopPolicies)2 AllocatedObjectNode (org.graalvm.compiler.nodes.virtual.AllocatedObjectNode)2 CommitAllocationNode (org.graalvm.compiler.nodes.virtual.CommitAllocationNode)2 OptionValues (org.graalvm.compiler.options.OptionValues)2 DeadCodeEliminationPhase (org.graalvm.compiler.phases.common.DeadCodeEliminationPhase)2 InstalledCode (jdk.vm.ci.code.InstalledCode)1 Node (org.graalvm.compiler.graph.Node)1 LoopFullUnrollPhase (org.graalvm.compiler.loop.phases.LoopFullUnrollPhase)1 LoopPeelingPhase (org.graalvm.compiler.loop.phases.LoopPeelingPhase)1 ConstantNode (org.graalvm.compiler.nodes.ConstantNode)1 ReturnNode (org.graalvm.compiler.nodes.ReturnNode)1