changeset 13599:29b1b216d20a

SchedulePhase: use {Queue,Deque}/LinkedList instead of Stack
author Bernhard Urban <bernhard.urban@jku.at>
date Fri, 10 Jan 2014 15:03:22 +0200
parents 82fc603fcc05
children 32ba70c49d27
files graal/com.oracle.graal.phases/src/com/oracle/graal/phases/schedule/SchedulePhase.java
diffstat 1 files changed, 7 insertions(+), 7 deletions(-) [+]
line wrap: on
line diff
--- a/graal/com.oracle.graal.phases/src/com/oracle/graal/phases/schedule/SchedulePhase.java	Sun Jan 12 22:20:27 2014 +0100
+++ b/graal/com.oracle.graal.phases/src/com/oracle/graal/phases/schedule/SchedulePhase.java	Fri Jan 10 15:03:22 2014 +0200
@@ -491,7 +491,7 @@
             return latestBlock;
         }
 
-        Stack<Block> path = computePathInDominatorTree(earliestBlock, latestBlock);
+        Deque<Block> path = computePathInDominatorTree(earliestBlock, latestBlock);
         Debug.printf("|path| is %d: %s\n", path.size(), path);
 
         // follow path, start at earliest schedule
@@ -542,8 +542,8 @@
      * 
      * @return the order of the stack is such as the first element is the earliest schedule.
      */
-    private static Stack<Block> computePathInDominatorTree(Block earliestBlock, Block latestBlock) {
-        Stack<Block> path = new Stack<>();
+    private static Deque<Block> computePathInDominatorTree(Block earliestBlock, Block latestBlock) {
+        Deque<Block> path = new LinkedList<>();
         Block currentBlock = latestBlock;
         while (currentBlock != null && earliestBlock.dominates(currentBlock)) {
             path.push(currentBlock);
@@ -559,17 +559,17 @@
      */
     private static HashSet<Block> computeRegion(Block dominatorBlock, Block dominatedBlock) {
         HashSet<Block> region = new HashSet<>();
-        Stack<Block> workList = new Stack<>();
+        Queue<Block> workList = new LinkedList<>();
 
         region.add(dominatorBlock);
-        workList.addAll(0, dominatorBlock.getSuccessors());
+        workList.addAll(dominatorBlock.getSuccessors());
         while (workList.size() > 0) {
-            Block current = workList.pop();
+            Block current = workList.poll();
             if (current != dominatedBlock) {
                 region.add(current);
                 for (Block b : current.getSuccessors()) {
                     if (!region.contains(b) && !workList.contains(b)) {
-                        workList.add(b);
+                        workList.offer(b);
                     }
                 }
             }