changeset 5397:a3d6ea4241e5

made lowering repeat processing of fixed nodes until no new fixed nodes are added before lowering floating nodes
author Doug Simon <doug.simon@oracle.com>
date Mon, 14 May 2012 22:05:15 +0200
parents c3de4d2988c7
children 17cddac1f2da
files graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/phases/LoweringPhase.java
diffstat 1 files changed, 54 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- a/graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/phases/LoweringPhase.java	Mon May 14 21:52:32 2012 +0200
+++ b/graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/phases/LoweringPhase.java	Mon May 14 22:05:15 2012 +0200
@@ -44,9 +44,56 @@
         this.runtime = runtime;
         this.assumptions = assumptions;
     }
-
     @Override
     protected void run(final StructuredGraph graph) {
+        // Step 1: repeatedly lower fixed nodes until no new ones are created
+        NodeBitMap processed = graph.createNodeBitMap();
+        while (true) {
+            int mark = graph.getMark();
+            ControlFlowGraph cfg = ControlFlowGraph.compute(graph, true, false, true, true);
+            processBlock(cfg.getStartBlock(), graph.createNodeBitMap(), processed, null);
+
+            if (graph.getNewNodes(mark).filter(FixedNode.class).isEmpty()) {
+                break;
+            }
+            graph.verify();
+            processed.grow();
+        }
+
+        // Step 2: lower the floating nodes
+        processed.negate();
+        final CiLoweringTool loweringTool = new CiLoweringTool() {
+
+            @Override
+            public Node getGuardAnchor() {
+                throw new UnsupportedOperationException();
+            }
+
+            @Override
+            public GraalRuntime getRuntime() {
+                return runtime;
+            }
+
+            @Override
+            public Node createGuard(Node condition, RiDeoptReason deoptReason, RiDeoptAction action, long leafGraphId) {
+                // TODO (thomaswue): Document why this must not be called on floating nodes.
+                throw new UnsupportedOperationException();
+            }
+
+            @Override
+            public CiAssumptions assumptions() {
+                return assumptions;
+            }
+        };
+        for (Node node : processed) {
+            if (node instanceof Lowerable) {
+                assert !(node instanceof FixedNode) || node.predecessor() == null : node;
+                ((Lowerable) node).lower(loweringTool);
+            }
+        }
+    }
+
+    protected void run0(final StructuredGraph graph) {
         ControlFlowGraph cfg = ControlFlowGraph.compute(graph, true, false, true, true);
 
         NodeBitMap processed = graph.createNodeBitMap();
@@ -138,7 +185,7 @@
                 FixedNode guardAnchor = (FixedNode) getGuardAnchor();
                 if (GraalOptions.OptEliminateGuards) {
                     for (Node usage : condition.usages()) {
-                        if (activeGuards.isMarked(usage)) {
+                        if (!activeGuards.isNew(usage) && activeGuards.isMarked(usage)) {
                             return usage;
                         }
                     }
@@ -157,9 +204,11 @@
 
         // Lower the instructions of this block.
         for (Node node : b.getNodes()) {
-            processed.mark(node);
-            if (node instanceof Lowerable) {
-                ((Lowerable) node).lower(loweringTool);
+            if (!processed.isMarked(node)) {
+                processed.mark(node);
+                if (node instanceof Lowerable) {
+                    ((Lowerable) node).lower(loweringTool);
+                }
             }
         }
     }