# HG changeset patch # User Gilles Duboscq # Date 1398184261 -7200 # Node ID ad3441f45118e498e701f70dc0c7ce42cf0f0b71 # Parent 9f83343a5a743d26e9bce7054327961fec090ea5 Make a NodeUsageWithModCountIterator subclass of NodeUsageIterator. Throw ConcurrentModificationException from it instead of AssertionErrors diff -r 9f83343a5a74 -r ad3441f45118 graal/com.oracle.graal.graph/src/com/oracle/graal/graph/Node.java --- a/graal/com.oracle.graal.graph/src/com/oracle/graal/graph/Node.java Tue Apr 22 17:31:57 2014 +0200 +++ b/graal/com.oracle.graal.graph/src/com/oracle/graal/graph/Node.java Tue Apr 22 18:31:01 2014 +0200 @@ -227,10 +227,35 @@ } } + class NodeUsageWithModCountIterator extends NodeUsageIterator { + + private final int expectedModCount = usageModCount(); + + @Override + public boolean hasNext() { + if (expectedModCount != usageModCount()) { + throw new ConcurrentModificationException(); + } + return super.hasNext(); + } + + @Override + public Node next() { + if (expectedModCount != usageModCount()) { + throw new ConcurrentModificationException(); + } + return super.next(); + } + } + class NodeUsageIterable implements NodeIterable { public NodeUsageIterator iterator() { - return new NodeUsageIterator(); + if (MODIFICATION_COUNTS_ENABLED) { + return new NodeUsageWithModCountIterator(); + } else { + return new NodeUsageIterator(); + } } @Override