use of org.graalvm.compiler.nodes.StructuredGraph.ScheduleResult in project graal by oracle.
the class MemoryScheduleTest method testProxy.
@Test
public void testProxy() {
ScheduleResult schedule = getFinalSchedule("testProxySnippet", TestMode.WITHOUT_FRAMESTATES);
assertReadWithinStartBlock(schedule, false);
assertReadWithinAllReturnBlocks(schedule, false);
}
use of org.graalvm.compiler.nodes.StructuredGraph.ScheduleResult in project graal by oracle.
the class MemoryScheduleTest method testIfRead5.
@Test
public void testIfRead5() {
ScheduleResult schedule = getFinalSchedule("testIfRead5Snippet", TestMode.WITHOUT_FRAMESTATES);
assertDeepEquals(4, schedule.getCFG().getBlocks().length);
assertReadWithinStartBlock(schedule, false);
assertReadWithinAllReturnBlocks(schedule, true);
assertReadAndWriteInSameBlock(schedule, false);
}
use of org.graalvm.compiler.nodes.StructuredGraph.ScheduleResult in project graal by oracle.
the class MemoryScheduleTest method testLoop4.
@Test
public void testLoop4() {
ScheduleResult schedule = getFinalSchedule("testLoop4Snippet", TestMode.WITHOUT_FRAMESTATES);
assertReadWithinStartBlock(schedule, false);
assertReadWithinAllReturnBlocks(schedule, false);
}
use of org.graalvm.compiler.nodes.StructuredGraph.ScheduleResult 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));
}
}
}
use of org.graalvm.compiler.nodes.StructuredGraph.ScheduleResult in project graal by oracle.
the class SchedulingTest2 method testValueProxyInputs.
@Test
public void testValueProxyInputs() {
StructuredGraph graph = parseEager("testSnippet", AllowAssumptions.YES);
DebugContext debug = graph.getDebug();
ReturnNode returnNode = graph.getNodes(ReturnNode.TYPE).first();
BeginNode beginNode = graph.add(new BeginNode());
returnNode.replaceAtPredecessor(beginNode);
beginNode.setNext(returnNode);
debug.dump(DebugContext.BASIC_LEVEL, graph, "Graph");
SchedulePhase schedulePhase = new SchedulePhase(SchedulingStrategy.EARLIEST_WITH_GUARD_ORDER);
schedulePhase.apply(graph);
ScheduleResult schedule = graph.getLastSchedule();
BlockMap<List<Node>> blockToNodesMap = schedule.getBlockToNodesMap();
NodeMap<Block> nodeToBlock = schedule.getNodeToBlockMap();
assertDeepEquals(2, schedule.getCFG().getBlocks().length);
for (BinaryArithmeticNode<?> node : graph.getNodes().filter(BinaryArithmeticNode.class)) {
if (node instanceof AddNode) {
assertTrue(node.toString() + " expected: " + nodeToBlock.get(beginNode) + " but was: " + nodeToBlock.get(node), nodeToBlock.get(node) != nodeToBlock.get(beginNode));
}
}
for (FrameState fs : graph.getNodes(FrameState.TYPE)) {
Block block = nodeToBlock.get(fs);
assertTrue(fs.toString(), block == schedule.getCFG().getStartBlock());
for (Node usage : fs.usages()) {
if (usage instanceof StateSplit && ((StateSplit) usage).stateAfter() == fs) {
assertTrue(usage.toString(), nodeToBlock.get(usage) == block);
if (usage != block.getBeginNode()) {
List<Node> map = blockToNodesMap.get(block);
assertTrue(map.indexOf(fs) + " < " + map.indexOf(usage), map.indexOf(fs) < map.indexOf(usage));
}
}
}
}
PhaseContext context = new PhaseContext(getProviders());
new LoweringPhase(new CanonicalizerPhase(), LoweringTool.StandardLoweringStage.HIGH_TIER).apply(graph, context);
new LoweringPhase(new CanonicalizerPhase(), LoweringTool.StandardLoweringStage.MID_TIER).apply(graph, context);
MidTierContext midContext = new MidTierContext(getProviders(), getTargetProvider(), OptimisticOptimizations.ALL, graph.getProfilingInfo());
new GuardLoweringPhase().apply(graph, midContext);
FrameStateAssignmentPhase phase = new FrameStateAssignmentPhase();
phase.apply(graph);
schedulePhase.apply(graph);
schedule = graph.getLastSchedule();
blockToNodesMap = schedule.getBlockToNodesMap();
nodeToBlock = schedule.getNodeToBlockMap();
for (FrameState fs : graph.getNodes(FrameState.TYPE)) {
Block block = nodeToBlock.get(fs);
assertTrue(fs.toString(), block == schedule.getCFG().getStartBlock());
for (Node usage : fs.usages()) {
if ((usage instanceof StateSplit && ((StateSplit) usage).stateAfter() == fs) || (usage instanceof DeoptDuring && ((DeoptDuring) usage).stateDuring() == fs)) {
assertTrue(usage.toString(), nodeToBlock.get(usage) == block);
if (usage != block.getBeginNode()) {
List<Node> map = blockToNodesMap.get(block);
assertTrue(map.indexOf(fs) + " < " + map.indexOf(usage), map.indexOf(fs) < map.indexOf(usage));
}
}
}
}
}
Aggregations