# HG changeset patch # User Doug Simon # Date 1349100765 -7200 # Node ID ec22112544197bcdb125bc45ef358444e8b5905a # Parent afe7d46f1311526d0e12c72c6536cb7d6291ebaf# Parent 6f2b35ef59b075200cc927a0fffe6d85701d014c Merge. diff -r afe7d46f1311 -r ec2211254419 graal/com.oracle.graal.compiler.phases/src/com/oracle/graal/compiler/phases/FloatingReadPhase.java --- a/graal/com.oracle.graal.compiler.phases/src/com/oracle/graal/compiler/phases/FloatingReadPhase.java Mon Oct 01 16:12:28 2012 +0200 +++ b/graal/com.oracle.graal.compiler.phases/src/com/oracle/graal/compiler/phases/FloatingReadPhase.java Mon Oct 01 16:12:45 2012 +0200 @@ -102,17 +102,17 @@ keys.add(key); } } + @SuppressWarnings("unchecked") + IdentityHashMap newMemorySnapshot = (IdentityHashMap) lastMemorySnapshot.clone(); for (Object key : keys) { ValueNode merged = lastMemorySnapshot.get(key); if (merged == null) { merged = lastMemorySnapshot.get(LocationNode.ANY_LOCATION); } - Iterator it = withStates.iterator(); - int i = 1; + int mergedStatesCount = 1; boolean isPhi = false; - while (it.hasNext()) { - MemoryMap other = it.next(); + for (MemoryMap other : withStates) { ValueNode otherValue = other.lastMemorySnapshot.get(key); if (otherValue == null) { otherValue = other.lastMemorySnapshot.get(LocationNode.ANY_LOCATION); @@ -121,17 +121,19 @@ ((PhiNode) merged).addInput(otherValue); } else if (merged != otherValue) { PhiNode phi = merge.graph().add(new PhiNode(PhiType.Memory, merge)); - for (int j = 0; j < i; j++) { + for (int j = 0; j < mergedStatesCount; j++) { phi.addInput(merged); } phi.addInput(otherValue); merged = phi; isPhi = true; - lastMemorySnapshot.put(key, phi); + newMemorySnapshot.put(key, phi); } - i++; + mergedStatesCount++; } } + + lastMemorySnapshot = newMemorySnapshot; return true; } diff -r afe7d46f1311 -r ec2211254419 graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/PhiNode.java --- a/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/PhiNode.java Mon Oct 01 16:12:28 2012 +0200 +++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/PhiNode.java Mon Oct 01 16:12:45 2012 +0200 @@ -179,6 +179,7 @@ } public void addInput(ValueNode x) { + assert !(x instanceof PhiNode) || ((PhiNode) x).merge() instanceof LoopBeginNode || ((PhiNode) x).merge() != this.merge(); values.add(x); }