# HG changeset patch # User Thomas Wuerthinger # Date 1452878878 -3600 # Node ID 00a2a20e81093db08e847755d020f2aec1c30000 # Parent 0ca595288320b6d5fa4a125ff7ec70ede5ca4433 Simplification of unreachable node tracking in SchedulePhase: Unreachable node bitset is invert of visited bitset. diff -r 0ca595288320 -r 00a2a20e8109 graal/com.oracle.graal.phases/src/com/oracle/graal/phases/schedule/SchedulePhase.java --- a/graal/com.oracle.graal.phases/src/com/oracle/graal/phases/schedule/SchedulePhase.java Fri Jan 15 18:20:21 2016 +0100 +++ b/graal/com.oracle.graal.phases/src/com/oracle/graal/phases/schedule/SchedulePhase.java Fri Jan 15 18:27:58 2016 +0100 @@ -146,20 +146,16 @@ this.nodeToBlockMap = currentNodeMap; this.blockToNodesMap = earliestBlockToNodesMap; - if (selectedStrategy == SchedulingStrategy.EARLIEST) { - // Assign early so we are getting a context in case of an exception. - scheduleEarliestIterative(earliestBlockToNodesMap, currentNodeMap, visited, graph, null, immutableGraph); - } else { - NodeBitMap unreachableNodes = immutableGraph ? graph.createNodeBitMap() : null; - scheduleEarliestIterative(earliestBlockToNodesMap, currentNodeMap, visited, graph, unreachableNodes, immutableGraph); + scheduleEarliestIterative(earliestBlockToNodesMap, currentNodeMap, visited, graph, immutableGraph); + if (selectedStrategy != SchedulingStrategy.EARLIEST) { + // For non-earliest schedules, we need to do a second pass. BlockMap> latestBlockToNodesMap = new BlockMap<>(cfg); for (Block b : cfg.getBlocks()) { latestBlockToNodesMap.put(b, new ArrayList()); } - BlockMap> watchListMap = calcLatestBlocks(selectedStrategy, currentNodeMap, earliestBlockToNodesMap, visited, latestBlockToNodesMap, unreachableNodes, - immutableGraph); + BlockMap> watchListMap = calcLatestBlocks(selectedStrategy, currentNodeMap, earliestBlockToNodesMap, visited, latestBlockToNodesMap, immutableGraph); sortNodesLatestWithinBlock(cfg, earliestBlockToNodesMap, latestBlockToNodesMap, currentNodeMap, watchListMap, visited); assert verifySchedule(cfg, latestBlockToNodesMap, currentNodeMap); @@ -175,7 +171,7 @@ @SuppressFBWarnings(value = "RCN_REDUNDANT_NULLCHECK_WOULD_HAVE_BEEN_A_NPE", justification = "false positive found by findbugs") private BlockMap> calcLatestBlocks(SchedulingStrategy strategy, NodeMap currentNodeMap, BlockMap> earliestBlockToNodesMap, NodeBitMap visited, - BlockMap> latestBlockToNodesMap, NodeBitMap unreachableNodes, boolean immutableGraph) { + BlockMap> latestBlockToNodesMap, boolean immutableGraph) { BlockMap> watchListMap = new BlockMap<>(cfg); for (Block currentBlock : cfg.postOrder()) { List blockToNodes = earliestBlockToNodesMap.get(currentBlock); @@ -218,7 +214,7 @@ if (latestBlock == null) { // We are not constraint within earliest block => calculate optimized // schedule. - calcLatestBlock(currentBlock, strategy, currentNode, currentNodeMap, unreachableNodes, constrainingLocation, watchListMap, latestBlockToNodesMap, visited, immutableGraph); + calcLatestBlock(currentBlock, strategy, currentNode, currentNodeMap, constrainingLocation, watchListMap, latestBlockToNodesMap, visited, immutableGraph); } else { selectLatestBlock(currentNode, currentBlock, latestBlock, currentNodeMap, watchListMap, constrainingLocation, latestBlockToNodesMap); } @@ -467,20 +463,17 @@ } - @SuppressWarnings("unused") - protected void calcLatestBlock(Block earliestBlock, SchedulingStrategy strategy, Node currentNode, NodeMap currentNodeMap, NodeBitMap unreachableNodes, - LocationIdentity constrainingLocation, BlockMap> watchListMap, BlockMap> latestBlockToNodesMap, NodeBitMap visited, - boolean immutableGraph) { + protected void calcLatestBlock(Block earliestBlock, SchedulingStrategy strategy, Node currentNode, NodeMap currentNodeMap, LocationIdentity constrainingLocation, + BlockMap> watchListMap, BlockMap> latestBlockToNodesMap, NodeBitMap visited, boolean immutableGraph) { Block latestBlock = null; assert currentNode.hasUsages(); for (Node usage : currentNode.usages()) { - if (unreachableNodes != null && unreachableNodes.contains(usage)) { + if (immutableGraph && !visited.contains(usage)) { /* * Normally, dead nodes are deleted by the scheduler before we reach this point. * Only when the scheduler is asked to not modify a graph, we can see dead nodes * here. */ - assert immutableGraph; continue; } latestBlock = calcBlockForUsage(currentNode, usage, latestBlock, currentNodeMap); @@ -530,8 +523,7 @@ return currentBlock; } - private void scheduleEarliestIterative(BlockMap> blockToNodes, NodeMap nodeToBlock, NodeBitMap visited, StructuredGraph graph, NodeBitMap unreachableNodes, - boolean immutableGraph) { + private void scheduleEarliestIterative(BlockMap> blockToNodes, NodeMap nodeToBlock, NodeBitMap visited, StructuredGraph graph, boolean immutableGraph) { BitSet floatingReads = new BitSet(cfg.getBlocks().size()); @@ -599,19 +591,11 @@ } while (unmarkedPhi && changed); // Check for dead nodes. - if (visited.getCounter() < graph.getNodeCount()) { + if (!immutableGraph && visited.getCounter() < graph.getNodeCount()) { for (Node n : graph.getNodes()) { if (!visited.isMarked(n)) { - if (!immutableGraph) { - n.clearInputs(); - n.markDeleted(); - } else if (unreachableNodes != null) { - /* - * We are not allowed to modify the graph, so remember that node is - * dead. - */ - unreachableNodes.mark(n); - } + n.clearInputs(); + n.markDeleted(); } } }