use of org.graalvm.compiler.phases.common.CanonicalizerPhase 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));
}
use of org.graalvm.compiler.phases.common.CanonicalizerPhase 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());
}
}
use of org.graalvm.compiler.phases.common.CanonicalizerPhase 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);
}
use of org.graalvm.compiler.phases.common.CanonicalizerPhase 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);
}
use of org.graalvm.compiler.phases.common.CanonicalizerPhase 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());
}
Aggregations