use of org.graalvm.compiler.nodes.cfg.Block in project graal by oracle.
the class MemoryScheduleTest method assertReadWithinAllReturnBlocks.
private void assertReadWithinAllReturnBlocks(ScheduleResult schedule, boolean withinReturnBlock) {
StructuredGraph graph = schedule.getCFG().graph;
assertTrue(graph.getNodes(ReturnNode.TYPE).isNotEmpty());
int withRead = 0;
int returnBlocks = 0;
for (ReturnNode returnNode : graph.getNodes(ReturnNode.TYPE)) {
Block block = schedule.getCFG().getNodeToBlock().get(returnNode);
for (Node node : schedule.getBlockToNodesMap().get(block)) {
if (node instanceof FloatingReadNode) {
withRead++;
break;
}
}
returnBlocks++;
}
assertDeepEquals(withRead == returnBlocks, withinReturnBlock);
}
use of org.graalvm.compiler.nodes.cfg.Block in project graal by oracle.
the class MemoryScheduleTest method testLoop9.
@Test
public void testLoop9() {
ScheduleResult schedule = getFinalSchedule("testLoop9Snippet", TestMode.WITHOUT_FRAMESTATES);
StructuredGraph graph = schedule.getCFG().getStartBlock().getBeginNode().graph();
assertThat(graph.getNodes(ReturnNode.TYPE), hasCount(1));
ReturnNode ret = graph.getNodes(ReturnNode.TYPE).first();
assertThat(ret.result(), instanceOf(FloatingReadNode.class));
Block readBlock = schedule.getNodeToBlockMap().get(ret.result());
Assert.assertEquals(0, readBlock.getLoopDepth());
}
use of org.graalvm.compiler.nodes.cfg.Block in project graal by oracle.
the class NestedLoopTest method contains.
private static boolean contains(Loop<Block> loop, Invoke node, ControlFlowGraph cfg) {
Block block = cfg.blockFor((Node) node);
Assert.assertNotNull(block);
return loop.getBlocks().contains(block);
}
use of org.graalvm.compiler.nodes.cfg.Block in project graal by oracle.
the class NestedLoopTest method test.
private void test(String snippet, int rootExits, int nestedExits, int innerExits) {
StructuredGraph graph = parseEager(snippet, AllowAssumptions.YES);
DebugContext debug = graph.getDebug();
debug.dump(DebugContext.BASIC_LEVEL, graph, "Graph");
ControlFlowGraph cfg = ControlFlowGraph.compute(graph, true, true, true, true);
Assert.assertEquals(3, cfg.getLoops().size());
Loop<Block> rootLoop = cfg.getLoops().get(0);
Loop<Block> nestedLoop = cfg.getLoops().get(1);
Loop<Block> innerMostLoop = cfg.getLoops().get(2);
Invoke a = getInvoke("a", graph);
Invoke b = getInvoke("b", graph);
Invoke c = getInvoke("c", graph);
Invoke d = getInvoke("d", graph);
Assert.assertTrue(containsDirect(rootLoop, a, cfg));
Assert.assertTrue(containsDirect(nestedLoop, b, cfg));
Assert.assertTrue(containsDirect(innerMostLoop, c, cfg));
Assert.assertTrue(containsDirect(innerMostLoop, d, cfg));
Assert.assertTrue(contains(rootLoop, d, cfg));
Assert.assertTrue(contains(nestedLoop, d, cfg));
Assert.assertEquals(rootExits, rootLoop.getExits().size());
Assert.assertEquals(nestedExits, nestedLoop.getExits().size());
Assert.assertEquals(innerExits, innerMostLoop.getExits().size());
debug.dump(DebugContext.BASIC_LEVEL, graph, "Graph");
}
use of org.graalvm.compiler.nodes.cfg.Block in project graal by oracle.
the class SchedulingTest method testValueProxyInputs.
@Test
public void testValueProxyInputs() {
StructuredGraph graph = parseEager("testValueProxyInputsSnippet", AllowAssumptions.YES);
for (FrameState fs : graph.getNodes().filter(FrameState.class).snapshot()) {
fs.replaceAtUsages(null);
GraphUtil.killWithUnusedFloatingInputs(fs);
}
SchedulePhase schedulePhase = new SchedulePhase(SchedulingStrategy.LATEST);
schedulePhase.apply(graph);
ScheduleResult schedule = graph.getLastSchedule();
NodeMap<Block> nodeToBlock = schedule.getCFG().getNodeToBlock();
assertTrue(graph.getNodes().filter(LoopExitNode.class).count() == 1);
LoopExitNode loopExit = graph.getNodes().filter(LoopExitNode.class).first();
List<Node> list = schedule.nodesFor(nodeToBlock.get(loopExit));
for (BinaryArithmeticNode<?> node : graph.getNodes().filter(BinaryArithmeticNode.class)) {
if (!(node instanceof AddNode)) {
assertTrue(node.toString(), nodeToBlock.get(node) == nodeToBlock.get(loopExit));
assertTrue(list.indexOf(node) + " < " + list.indexOf(loopExit) + ", " + node + ", " + loopExit, list.indexOf(node) < list.indexOf(loopExit));
}
}
}
Aggregations