changeset 3200:536b02e3cd2b

Fix for peeling spliting : inner framestates which are attached to nodes after the coloring can not be colored
author Gilles Duboscq <gilles.duboscq@oracle.com>
date Fri, 08 Jul 2011 14:49:01 +0200
parents 494f0ff09b14
children 38792f959479
files graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/util/LoopUtil.java graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/value/FrameState.java
diffstat 2 files changed, 53 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/util/LoopUtil.java	Fri Jul 08 13:38:38 2011 +0200
+++ b/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/util/LoopUtil.java	Fri Jul 08 14:49:01 2011 +0200
@@ -546,14 +546,27 @@
                 System.out.println(" - inputs > 0 : " + (n.inputs().size() > 0));
                 System.out.println(" - !danglingMergeFrameState : " + (!danglingMergeFrameState(n)));*/
                 return (!exitFrameStates.isNew(n) && exitFrameStates.isMarked(n))
-                || (!inOrBefore.isNew(n) && !inOrBefore.isMarked(n) && n.inputs().size() > 0 && !danglingMergeFrameState(n)); //TODO (gd) hum
+                || (!inOrBefore.isNew(n) && !inOrBefore.isMarked(n) && n.inputs().size() > 0 && !afterColoringFramestate(n)); //TODO (gd) hum
             }
-            public boolean danglingMergeFrameState(Node n) {
+            public boolean afterColoringFramestate(Node n) {
                 if (!(n instanceof FrameState)) {
                     return false;
                 }
-                Merge block = ((FrameState) n).block();
-                return block != null && colors.get(block.next()) == null;
+                final FrameState frameState = (FrameState) n;
+                Merge block = frameState.block();
+                if (block != null) {
+                    return colors.get(block.next()) == null;
+                }
+                StateSplit stateSplit = frameState.stateSplit();
+                if (stateSplit != null) {
+                    return colors.get(stateSplit) == null;
+                }
+                for (FrameState inner : frameState.innerFrameStates()) {
+                    if (!afterColoringFramestate(inner)) {
+                        return false;
+                    }
+                }
+                return true;
             }
             @Override
             public void fixNode(Node node, Node color) {
--- a/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/value/FrameState.java	Fri Jul 08 13:38:38 2011 +0200
+++ b/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/value/FrameState.java	Fri Jul 08 14:49:01 2011 +0200
@@ -442,6 +442,42 @@
         return null;
     }
 
+    public Iterable<FrameState> innerFrameStates() {
+        final Iterator<Node> iterator = usages().iterator();
+        return new Iterable<FrameState>() {
+            @Override
+            public Iterator<FrameState> iterator() {
+                return new Iterator<FrameState>() {
+                    private Node next;
+                    @Override
+                    public void remove() {
+                        throw new UnsupportedOperationException();
+                    }
+                    @Override
+                    public FrameState next() {
+                        forward();
+                        if (!hasNext()) {
+                            throw new NoSuchElementException();
+                        }
+                        FrameState res = (FrameState) next;
+                        next = null;
+                        return res;
+                    }
+                    @Override
+                    public boolean hasNext() {
+                        forward();
+                        return next != null;
+                    }
+                    private void forward() {
+                        while (!(next instanceof FrameState) && iterator.hasNext()) {
+                            next = iterator.next();
+                        }
+                    }
+                };
+            }
+        };
+    }
+
     /**
      * The interface implemented by a client of {@link FrameState#forEachPhi(Merge, PhiProcedure)} and
      * {@link FrameState#forEachLivePhi(Merge, PhiProcedure)}.