use of org.graalvm.compiler.nodes.java.NewArrayNode in project graal by oracle.
the class PartialEscapeAnalysisTest method testPartialEscapeAnalysis.
@SafeVarargs
protected final void testPartialEscapeAnalysis(String snippet, double expectedProbability, int expectedCount, Class<? extends Node>... invalidNodeClasses) {
prepareGraph(snippet, false);
for (AbstractMergeNode merge : graph.getNodes(AbstractMergeNode.TYPE)) {
merge.setStateAfter(null);
}
new DeadCodeEliminationPhase().apply(graph);
new CanonicalizerPhase().apply(graph, context);
try {
Assert.assertTrue("partial escape analysis should have removed all NewInstanceNode allocations", graph.getNodes().filter(NewInstanceNode.class).isEmpty());
Assert.assertTrue("partial escape analysis should have removed all NewArrayNode allocations", graph.getNodes().filter(NewArrayNode.class).isEmpty());
ControlFlowGraph cfg = ControlFlowGraph.compute(graph, true, true, false, false);
double probabilitySum = 0;
int materializeCount = 0;
for (CommitAllocationNode materialize : graph.getNodes().filter(CommitAllocationNode.class)) {
probabilitySum += cfg.blockFor(materialize).probability() * materialize.getVirtualObjects().size();
materializeCount += materialize.getVirtualObjects().size();
}
Assert.assertEquals("unexpected number of MaterializeObjectNodes", expectedCount, materializeCount);
Assert.assertEquals("unexpected probability of MaterializeObjectNodes", expectedProbability, probabilitySum, 0.01);
for (Node node : graph.getNodes()) {
for (Class<? extends Node> clazz : invalidNodeClasses) {
Assert.assertFalse("instance of invalid class: " + clazz.getSimpleName(), clazz.isInstance(node) && node.usages().isNotEmpty());
}
}
} catch (AssertionError e) {
TypeSystemTest.outputGraph(graph, snippet + ": " + e.getMessage());
throw e;
}
}
use of org.graalvm.compiler.nodes.java.NewArrayNode in project graal by oracle.
the class UnusedArray method test.
public void test(String method) {
StructuredGraph graph = parseEager(method, StructuredGraph.AllowAssumptions.YES);
new CanonicalizerPhase().apply(graph, new PhaseContext(getProviders()));
NodeIterable<NewArrayNode> newArrayNodes = graph.getNodes().filter(NewArrayNode.class);
assertThat(newArrayNodes, isEmpty());
}
Aggregations