changeset 7135:c41a958a3923

Defer lowering to next iteration when the CFG was changed by a previous lowering so that no lastFixedNode is available
author Christian Wimmer <christian.wimmer@oracle.com>
date Tue, 04 Dec 2012 11:05:01 -0800
parents 3de18d9cd04e
children 4f62a7fa7f9f
files graal/com.oracle.graal.phases.common/src/com/oracle/graal/phases/common/LoweringPhase.java
diffstat 1 files changed, 12 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/graal/com.oracle.graal.phases.common/src/com/oracle/graal/phases/common/LoweringPhase.java	Tue Dec 04 11:02:56 2012 -0800
+++ b/graal/com.oracle.graal.phases.common/src/com/oracle/graal/phases/common/LoweringPhase.java	Tue Dec 04 11:05:01 2012 -0800
@@ -104,6 +104,8 @@
     private final GraalCodeCacheProvider runtime;
     private final Assumptions assumptions;
 
+    private boolean deferred;
+
     public LoweringPhase(GraalCodeCacheProvider runtime, Assumptions assumptions) {
         this.runtime = runtime;
         this.assumptions = assumptions;
@@ -127,11 +129,12 @@
             final SchedulePhase schedule = new SchedulePhase();
             schedule.apply(graph, false);
 
+            deferred = false;
             processBlock(schedule.getCFG().getStartBlock(), graph.createNodeBitMap(), null, schedule, processed);
             Debug.dump(graph, "Lowering iteration %d", i++);
             new CanonicalizerPhase(null, runtime, assumptions, mark).apply(graph);
 
-            if (!containsLowerable(graph.getNewNodes(mark))) {
+            if (!deferred && !containsLowerable(graph.getNewNodes(mark))) {
                 // No new lowerable nodes - done!
                 break;
             }
@@ -184,9 +187,14 @@
                 loweringTool.lastFixedNode = fixed;
             }
 
-            if (node.isAlive() && !processed.isMarked(node)) {
-                processed.mark(node);
-                if (node instanceof Lowerable) {
+            if (node.isAlive() && !processed.isMarked(node) && node instanceof Lowerable) {
+                if (loweringTool.lastFixedNode == null) {
+                    // We cannot lower the node now because we don't have a fixed node to anchor the replacements.
+                    // This can happen when previous lowerings in this lowering iteration deleted the BeginNode of this block.
+                    // In the next iteration, we will have the new BeginNode available, and we can lower this node.
+                    deferred = true;
+                } else {
+                    processed.mark(node);
                     ((Lowerable) node).lower(loweringTool);
                 }
             }