# HG changeset patch # User Gilles Duboscq # Date 1310129341 -7200 # Node ID 536b02e3cd2b8c5b0c2624f2a4c6ee720acab8b8 # Parent 494f0ff09b14047698ae31225bfc2ed209663a11 Fix for peeling spliting : inner framestates which are attached to nodes after the coloring can not be colored diff -r 494f0ff09b14 -r 536b02e3cd2b graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/util/LoopUtil.java --- 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) { diff -r 494f0ff09b14 -r 536b02e3cd2b graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/value/FrameState.java --- 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 innerFrameStates() { + final Iterator iterator = usages().iterator(); + return new Iterable() { + @Override + public Iterator iterator() { + return new Iterator() { + 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)}.