Mercurial > hg > graal-compiler
changeset 15269:ad3441f45118
Make a NodeUsageWithModCountIterator subclass of NodeUsageIterator. Throw ConcurrentModificationException from it instead of AssertionErrors
author | Gilles Duboscq <duboscq@ssw.jku.at> |
---|---|
date | Tue, 22 Apr 2014 18:31:01 +0200 |
parents | 9f83343a5a74 |
children | 051935b55555 |
files | graal/com.oracle.graal.graph/src/com/oracle/graal/graph/Node.java |
diffstat | 1 files changed, 26 insertions(+), 1 deletions(-) [+] |
line wrap: on
line diff
--- 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<Node> { public NodeUsageIterator iterator() { - return new NodeUsageIterator(); + if (MODIFICATION_COUNTS_ENABLED) { + return new NodeUsageWithModCountIterator(); + } else { + return new NodeUsageIterator(); + } } @Override