# HG changeset patch # User Lukas Stadler # Date 1339578657 -7200 # Node ID 300a1207f2146342ed1f727ce6b78e0317ae4a7e # Parent 9911227e6dd37b0258ab9bfa6c11ec4e6418a738 small cleanup and fixed assertion in FrameStateBuilder diff -r 9911227e6dd3 -r 300a1207f214 graal/com.oracle.graal.java/src/com/oracle/graal/java/FrameStateBuilder.java --- a/graal/com.oracle.graal.java/src/com/oracle/graal/java/FrameStateBuilder.java Wed Jun 13 00:24:28 2012 +0200 +++ b/graal/com.oracle.graal.java/src/com/oracle/graal/java/FrameStateBuilder.java Wed Jun 13 11:10:57 2012 +0200 @@ -30,9 +30,11 @@ import com.oracle.graal.api.meta.*; import com.oracle.graal.debug.*; +import com.oracle.graal.graph.*; import com.oracle.graal.graph.Node.Verbosity; import com.oracle.graal.nodes.*; import com.oracle.graal.nodes.PhiNode.PhiType; +import com.oracle.graal.nodes.calc.*; import com.oracle.graal.nodes.type.*; public class FrameStateBuilder { @@ -155,7 +157,7 @@ } else if (block.isPhiAtMerge(currentValue)) { if (otherValue == null || currentValue.kind() != otherValue.kind()) { - deletePhi((PhiNode) currentValue); + propagateDelete((PhiNode) currentValue); return null; } ((PhiNode) currentValue).addInput(otherValue); @@ -180,45 +182,21 @@ } } - private void deletePhi(PhiNode phi) { - if (phi.isDeleted()) { + private void propagateDelete(FloatingNode node) { + assert node instanceof PhiNode || node instanceof ValueProxyNode; + if (node.isDeleted()) { return; } // Collect all phi functions that use this phi so that we can delete them recursively (after we delete ourselfs to avoid circles). - List phiUsages = phi.usages().filter(PhiNode.class).snapshot(); - List vpnUsages = phi.usages().filter(ValueProxyNode.class).snapshot(); + List propagateUsages = node.usages().filter(FloatingNode.class).filter(isA(PhiNode.class).or(ValueProxyNode.class)).snapshot(); // Remove the phi function from all FrameStates where it is used and then delete it. - assert phi.usages().filter(isNotA(FrameState.class).nor(PhiNode.class).nor(ValueProxyNode.class)).isEmpty() : "phi function that gets deletes must only be used in frame states"; - phi.replaceAtUsages(null); - phi.safeDelete(); - - for (PhiNode phiUsage : phiUsages) { - deletePhi(phiUsage); - } - for (ValueProxyNode proxyUsage : vpnUsages) { - deleteProxy(proxyUsage); - } - } + assert node.usages().filter(isNotA(FrameState.class).nor(PhiNode.class).nor(ValueProxyNode.class)).isEmpty() : "phi function that gets deletes must only be used in frame states"; + node.replaceAtUsages(null); + node.safeDelete(); - private void deleteProxy(ValueProxyNode proxy) { - if (proxy.isDeleted()) { - return; - } - // Collect all phi functions that use this phi so that we can delete them recursively (after we delete ourselfs to avoid circles). - List phiUsages = proxy.usages().filter(PhiNode.class).snapshot(); - List vpnUsages = proxy.usages().filter(ValueProxyNode.class).snapshot(); - - // Remove the proxy function from all FrameStates where it is used and then delete it. - assert proxy.usages().filter(isNotA(FrameState.class).nor(PhiNode.class).nor(ValueProxyNode.class)).isEmpty() : "phi function that gets deletes must only be used in frame states"; - proxy.replaceAtUsages(null); - proxy.safeDelete(); - - for (PhiNode phiUsage : phiUsages) { - deletePhi(phiUsage); - } - for (ValueProxyNode proxyUsage : vpnUsages) { - deleteProxy(proxyUsage); + for (FloatingNode phiUsage : propagateUsages) { + propagateDelete(phiUsage); } } @@ -262,7 +240,7 @@ public void cleanupDeletedPhis() { for (int i = 0; i < localsSize(); i++) { if (localAt(i) != null && localAt(i).isDeleted()) { - assert localAt(i) instanceof PhiNode : "Only phi functions can be deleted during parsing"; + assert localAt(i) instanceof PhiNode || localAt(i) instanceof ValueProxyNode : "Only phi and value proxies can be deleted during parsing: " + localAt(i); storeLocal(i, null); } }