Search in sources :

Example 1 with LockEliminationPhase

use of org.graalvm.compiler.phases.common.LockEliminationPhase in project graal by oracle.

the class LockEliminationTest method testUnrolledSync.

@Test
public void testUnrolledSync() {
    StructuredGraph graph = getGraph("testUnrolledSyncSnippet");
    CanonicalizerPhase canonicalizer = new CanonicalizerPhase();
    canonicalizer.apply(graph, new PhaseContext(getProviders()));
    HighTierContext context = getDefaultHighTierContext();
    new LoopFullUnrollPhase(canonicalizer, new DefaultLoopPolicies()).apply(graph, context);
    new LockEliminationPhase().apply(graph);
    assertDeepEquals(1, graph.getNodes().filter(RawMonitorEnterNode.class).count());
    assertDeepEquals(1, graph.getNodes().filter(MonitorExitNode.class).count());
}
Also used : PhaseContext(org.graalvm.compiler.phases.tiers.PhaseContext) LoopFullUnrollPhase(org.graalvm.compiler.loop.phases.LoopFullUnrollPhase) 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) LockEliminationPhase(org.graalvm.compiler.phases.common.LockEliminationPhase) Test(org.junit.Test)

Example 2 with LockEliminationPhase

use of org.graalvm.compiler.phases.common.LockEliminationPhase in project graal by oracle.

the class LockEliminationTest method getGraph.

private StructuredGraph getGraph(String snippet) {
    ResolvedJavaMethod method = getResolvedJavaMethod(snippet);
    StructuredGraph graph = parseEager(method, AllowAssumptions.YES);
    HighTierContext context = getDefaultHighTierContext();
    new CanonicalizerPhase().apply(graph, context);
    new InliningPhase(new CanonicalizerPhase()).apply(graph, context);
    new CanonicalizerPhase().apply(graph, context);
    new DeadCodeEliminationPhase().apply(graph);
    new LoweringPhase(new CanonicalizerPhase(), LoweringTool.StandardLoweringStage.HIGH_TIER).apply(graph, context);
    new LockEliminationPhase().apply(graph);
    return graph;
}
Also used : StructuredGraph(org.graalvm.compiler.nodes.StructuredGraph) LoweringPhase(org.graalvm.compiler.phases.common.LoweringPhase) CanonicalizerPhase(org.graalvm.compiler.phases.common.CanonicalizerPhase) HighTierContext(org.graalvm.compiler.phases.tiers.HighTierContext) LockEliminationPhase(org.graalvm.compiler.phases.common.LockEliminationPhase) InliningPhase(org.graalvm.compiler.phases.common.inlining.InliningPhase) DeadCodeEliminationPhase(org.graalvm.compiler.phases.common.DeadCodeEliminationPhase) ResolvedJavaMethod(jdk.vm.ci.meta.ResolvedJavaMethod)

Example 3 with LockEliminationPhase

use of org.graalvm.compiler.phases.common.LockEliminationPhase in project graal by oracle.

the class LockEliminationTest method testLock.

@Test
public void testLock() {
    test("testSynchronizedSnippet", new A(), new A());
    StructuredGraph graph = getGraph("testSynchronizedSnippet");
    new CanonicalizerPhase().apply(graph, new PhaseContext(getProviders()));
    new LockEliminationPhase().apply(graph);
    assertDeepEquals(1, graph.getNodes().filter(RawMonitorEnterNode.class).count());
    assertDeepEquals(1, graph.getNodes().filter(MonitorExitNode.class).count());
}
Also used : PhaseContext(org.graalvm.compiler.phases.tiers.PhaseContext) StructuredGraph(org.graalvm.compiler.nodes.StructuredGraph) CanonicalizerPhase(org.graalvm.compiler.phases.common.CanonicalizerPhase) LockEliminationPhase(org.graalvm.compiler.phases.common.LockEliminationPhase) Test(org.junit.Test)

Example 4 with LockEliminationPhase

use of org.graalvm.compiler.phases.common.LockEliminationPhase in project graal by oracle.

the class LockEliminationTest method testSynchronizedMethod.

@Test
public void testSynchronizedMethod() {
    test("testSynchronizedMethodSnippet", new A());
    StructuredGraph graph = getGraph("testSynchronizedMethodSnippet");
    new CanonicalizerPhase().apply(graph, new PhaseContext(getProviders()));
    new LockEliminationPhase().apply(graph);
    assertDeepEquals(1, graph.getNodes().filter(RawMonitorEnterNode.class).count());
    assertDeepEquals(1, graph.getNodes().filter(MonitorExitNode.class).count());
}
Also used : PhaseContext(org.graalvm.compiler.phases.tiers.PhaseContext) StructuredGraph(org.graalvm.compiler.nodes.StructuredGraph) CanonicalizerPhase(org.graalvm.compiler.phases.common.CanonicalizerPhase) LockEliminationPhase(org.graalvm.compiler.phases.common.LockEliminationPhase) Test(org.junit.Test)

Aggregations

StructuredGraph (org.graalvm.compiler.nodes.StructuredGraph)4 CanonicalizerPhase (org.graalvm.compiler.phases.common.CanonicalizerPhase)4 LockEliminationPhase (org.graalvm.compiler.phases.common.LockEliminationPhase)4 PhaseContext (org.graalvm.compiler.phases.tiers.PhaseContext)3 Test (org.junit.Test)3 HighTierContext (org.graalvm.compiler.phases.tiers.HighTierContext)2 ResolvedJavaMethod (jdk.vm.ci.meta.ResolvedJavaMethod)1 DefaultLoopPolicies (org.graalvm.compiler.loop.DefaultLoopPolicies)1 LoopFullUnrollPhase (org.graalvm.compiler.loop.phases.LoopFullUnrollPhase)1 DeadCodeEliminationPhase (org.graalvm.compiler.phases.common.DeadCodeEliminationPhase)1 LoweringPhase (org.graalvm.compiler.phases.common.LoweringPhase)1 InliningPhase (org.graalvm.compiler.phases.common.inlining.InliningPhase)1