changeset 5415:79f12805362b

Use iterative lowering instead of manually applying lowering
author Gilles Duboscq <duboscq@ssw.jku.at>
date Fri, 18 May 2012 15:48:38 +0200
parents 098c5eba749d
children bd5624f04067
files graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/phases/LoweringPhase.java graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/ri/HotSpotRuntime.java
diffstat 2 files changed, 14 insertions(+), 12 deletions(-) [+]
line wrap: on
line diff
--- a/graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/phases/LoweringPhase.java	Wed May 16 13:24:39 2012 +0200
+++ b/graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/phases/LoweringPhase.java	Fri May 18 15:48:38 2012 +0200
@@ -24,6 +24,7 @@
 
 import com.oracle.graal.compiler.*;
 import com.oracle.graal.cri.*;
+import com.oracle.graal.debug.*;
 import com.oracle.graal.graph.*;
 import com.oracle.graal.lir.cfg.*;
 import com.oracle.graal.nodes.*;
@@ -48,10 +49,13 @@
     protected void run(final StructuredGraph graph) {
         // Step 1: repeatedly lower fixed nodes until no new ones are created
         NodeBitMap processed = graph.createNodeBitMap();
+        int  i = 0;
         while (true) {
             int mark = graph.getMark();
             ControlFlowGraph cfg = ControlFlowGraph.compute(graph, true, false, true, true);
             processBlock(cfg.getStartBlock(), graph.createNodeBitMap(), processed, null);
+            Debug.dump(graph, "Lowering iteration %d", i++);
+            new CanonicalizerPhase(null, runtime, assumptions, mark, null).apply(graph);
 
             if (graph.getNewNodes(mark).filter(FixedNode.class).isEmpty()) {
                 break;
@@ -159,7 +163,7 @@
             }
         }
 
-        if (parentAnchor == null) {
+        if (parentAnchor == null && GraalOptions.OptEliminateGuards) {
             for (GuardNode guard : anchor.usages().filter(GuardNode.class)) {
                 activeGuards.clear(guard);
             }
@@ -191,8 +195,10 @@
                     }
                 }
                 GuardNode newGuard = guardAnchor.graph().unique(new GuardNode((BooleanNode) condition, guardAnchor, deoptReason, action, leafGraphId));
-                activeGuards.grow();
-                activeGuards.mark(newGuard);
+                if (GraalOptions.OptEliminateGuards) {
+                    activeGuards.grow();
+                    activeGuards.mark(newGuard);
+                }
                 return newGuard;
             }
 
--- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/ri/HotSpotRuntime.java	Wed May 16 13:24:39 2012 +0200
+++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/ri/HotSpotRuntime.java	Fri May 18 15:48:38 2012 +0200
@@ -289,7 +289,6 @@
             ArrayLengthNode arrayLengthNode = (ArrayLengthNode) n;
             SafeReadNode safeReadArrayLength = safeReadArrayLength(arrayLengthNode.array(), StructuredGraph.INVALID_GRAPH_ID);
             graph.replaceFixedWithFixed(arrayLengthNode, safeReadArrayLength);
-            safeReadArrayLength.lower(tool);
         } else if (n instanceof LoadFieldNode) {
             LoadFieldNode field = (LoadFieldNode) n;
             int displacement = ((HotSpotField) field.field()).offset();
@@ -389,9 +388,6 @@
             if (elementKind == CiKind.Object && !value.isNullConstant()) {
                 graph.addAfterFixed(memoryWrite, graph.add(new ArrayWriteBarrier(array, arrayLocation)));
             }
-            if (checkcast != null) {
-                checkcast.lower(tool);
-            }
         } else if (n instanceof UnsafeLoadNode) {
             UnsafeLoadNode load = (UnsafeLoadNode) n;
             assert load.kind() != CiKind.Illegal;
@@ -471,12 +467,12 @@
         return safeRead(array.graph(), CiKind.Int, array, config.arrayLengthOffset, StampFactory.positiveInt(), leafGraphId);
     }
 
-    private Node createBoundsCheck(AccessIndexedNode n, CiLoweringTool tool) {
-        SafeReadNode arrayLength = safeReadArrayLength(n.array(), n.leafGraphId());
-        Node guard = tool.createGuard(n.graph().unique(new CompareNode(n.index(), Condition.BT, arrayLength)), RiDeoptReason.BoundsCheckException, RiDeoptAction.InvalidateReprofile, n.leafGraphId());
+    private static Node createBoundsCheck(AccessIndexedNode n, CiLoweringTool tool) {
+        StructuredGraph graph = (StructuredGraph) n.graph();
+        ArrayLengthNode arrayLength = graph.add(new ArrayLengthNode(n.array()));
+        Node guard = tool.createGuard(graph.unique(new CompareNode(n.index(), Condition.BT, arrayLength)), RiDeoptReason.BoundsCheckException, RiDeoptAction.InvalidateReprofile, n.leafGraphId());
 
-        ((StructuredGraph) n.graph()).addBeforeFixed(n, arrayLength);
-        arrayLength.lower(tool);
+        graph.addBeforeFixed(n, arrayLength);
         return guard;
     }