use of org.graalvm.compiler.nodes.spi.CoreProviders in project graal by oracle.
the class ConditionalEliminationTestBase method testProxies.
public void testProxies(String snippet, int expectedProxiesCreated) {
StructuredGraph graph = parseEager(snippet, AllowAssumptions.YES);
CoreProviders context = getProviders();
CanonicalizerPhase canonicalizer1 = CanonicalizerPhase.createWithoutCFGSimplification();
canonicalizer1.apply(graph, context);
CanonicalizerPhase canonicalizer = createCanonicalizerPhase();
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.nodes.spi.CoreProviders 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");
CoreProviders context = getProviders();
CanonicalizerPhase canonicalizer1 = createCanonicalizerPhase();
CanonicalizerPhase canonicalizer = createCanonicalizerPhase();
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.nodes.spi.CoreProviders in project graal by oracle.
the class ConditionalEliminationTest15 method checkNodeCount.
private void checkNodeCount(String methodName, Class<? extends Node> nodeClass, int count) {
StructuredGraph graph = parseEager(methodName, AllowAssumptions.YES);
CanonicalizerPhase canonicalizer = this.createCanonicalizerPhase();
CoreProviders context = getProviders();
new LoweringPhase(this.createCanonicalizerPhase(), LoweringTool.StandardLoweringStage.HIGH_TIER).apply(graph, context);
canonicalizer.apply(graph, context);
// Merge arr.length reads.
new ReadEliminationPhase(canonicalizer).apply(graph, context);
new IterativeConditionalEliminationPhase(canonicalizer, true).apply(graph, context);
getDebugContext().dump(DebugContext.BASIC_LEVEL, graph, "After ConditionalEliminationPhase");
Assert.assertEquals(count, graph.getNodes().filter(nodeClass).count());
}
use of org.graalvm.compiler.nodes.spi.CoreProviders in project graal by oracle.
the class ConditionalEliminationTest2 method testInstanceOfCheckCastLowered.
@Test
public void testInstanceOfCheckCastLowered() {
StructuredGraph graph = parseEager("testInstanceOfCheckCastSnippet", AllowAssumptions.YES);
CanonicalizerPhase canonicalizer = createCanonicalizerPhase();
CoreProviders context = getProviders();
new LoweringPhase(canonicalizer, LoweringTool.StandardLoweringStage.HIGH_TIER).apply(graph, context);
canonicalizer.apply(graph, context);
new ConditionalEliminationPhase(true).apply(graph, context);
canonicalizer.apply(graph, context);
assertDeepEquals(0, graph.getNodes().filter(GuardNode.class).count());
}
use of org.graalvm.compiler.nodes.spi.CoreProviders in project graal by oracle.
the class ConditionalEliminationTest2 method checkInstanceOfCount.
private void checkInstanceOfCount(String methodName, int count) {
StructuredGraph graph = parseEager(methodName, AllowAssumptions.YES);
CanonicalizerPhase canonicalizer = this.createCanonicalizerPhase();
CoreProviders context = getProviders();
canonicalizer.apply(graph, context);
new ConditionalEliminationPhase(true).apply(graph, context);
getDebugContext().dump(DebugContext.BASIC_LEVEL, graph, "After ConditionalEliminationPhase");
canonicalizer.apply(graph, context);
Assert.assertEquals(count, graph.getNodes().filter(InstanceOfNode.class).count());
}
Aggregations