use of org.graalvm.compiler.phases.common.CanonicalizerPhase in project graal by oracle.
the class InvokeHintsTest method test.
private void test(String snippet) {
StructuredGraph graph = parseEager(snippet, AllowAssumptions.NO);
Map<Invoke, Double> hints = new HashMap<>();
for (Invoke invoke : graph.getInvokes()) {
hints.put(invoke, 1000d);
}
HighTierContext context = getDefaultHighTierContext();
new InliningPhase(hints, new CanonicalizerPhase()).apply(graph, context);
new CanonicalizerPhase().apply(graph, context);
new DeadCodeEliminationPhase().apply(graph);
StructuredGraph referenceGraph = parseEager(REFERENCE_SNIPPET, AllowAssumptions.NO);
assertEquals(referenceGraph, graph);
}
use of org.graalvm.compiler.phases.common.CanonicalizerPhase in project graal by oracle.
the class ConditionalEliminationTestBase method testProxies.
public void testProxies(String snippet, int expectedProxiesCreated) {
StructuredGraph graph = parseEager(snippet, AllowAssumptions.YES);
PhaseContext context = new PhaseContext(getProviders());
CanonicalizerPhase canonicalizer1 = new CanonicalizerPhase();
canonicalizer1.disableSimplification();
canonicalizer1.apply(graph, context);
CanonicalizerPhase canonicalizer = new CanonicalizerPhase();
new LoweringPhase(canonicalizer, LoweringTool.StandardLoweringStage.HIGH_TIER).apply(graph, context);
canonicalizer.apply(graph, context);
int baseProxyCount = graph.getNodes().filter(ProxyNode.class).count();
new ConditionalEliminationPhase(true).apply(graph, context);
canonicalizer.apply(graph, context);
new SchedulePhase(graph.getOptions()).apply(graph, context);
int actualProxiesCreated = graph.getNodes().filter(ProxyNode.class).count() - baseProxyCount;
Assert.assertEquals(expectedProxiesCreated, actualProxiesCreated);
}
use of org.graalvm.compiler.phases.common.CanonicalizerPhase in project graal by oracle.
the class ConditionalEliminationTestBase method testConditionalElimination.
@SuppressWarnings("try")
protected void testConditionalElimination(String snippet, String referenceSnippet, boolean applyConditionalEliminationOnReference, boolean applyLowering) {
StructuredGraph graph = parseEager(snippet, AllowAssumptions.YES);
DebugContext debug = graph.getDebug();
debug.dump(DebugContext.BASIC_LEVEL, graph, "Graph");
PhaseContext context = new PhaseContext(getProviders());
CanonicalizerPhase canonicalizer1 = new CanonicalizerPhase();
CanonicalizerPhase canonicalizer = new CanonicalizerPhase();
try (DebugContext.Scope scope = debug.scope("ConditionalEliminationTest", graph)) {
prepareGraph(graph, canonicalizer1, context, applyLowering);
new IterativeConditionalEliminationPhase(canonicalizer, true).apply(graph, context);
canonicalizer.apply(graph, context);
canonicalizer.apply(graph, context);
} catch (Throwable t) {
debug.handle(t);
}
StructuredGraph referenceGraph = parseEager(referenceSnippet, AllowAssumptions.YES);
try (DebugContext.Scope scope = debug.scope("ConditionalEliminationTest.ReferenceGraph", referenceGraph)) {
prepareGraph(referenceGraph, canonicalizer, context, applyLowering);
if (applyConditionalEliminationOnReference) {
new ConditionalEliminationPhase(true).apply(referenceGraph, context);
}
canonicalizer.apply(referenceGraph, context);
canonicalizer.apply(referenceGraph, context);
} catch (Throwable t) {
debug.handle(t);
}
assertEquals(referenceGraph, graph);
}
use of org.graalvm.compiler.phases.common.CanonicalizerPhase 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());
}
use of org.graalvm.compiler.phases.common.CanonicalizerPhase 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());
}
Aggregations