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));
}
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());
}
}
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());
}
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);
}
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);
}
Aggregations