# HG changeset patch # User Thomas Wuerthinger # Date 1424210929 -3600 # Node ID f13ce59e415053a1f9440790b531c85066afec8d # Parent 5b582897cc4b0c6144709c2873f3fb6dfd116f40 Use atomic integer for iterable IDs to prevent races. diff -r 5b582897cc4b -r f13ce59e4150 graal/com.oracle.graal.graph/src/com/oracle/graal/graph/NodeClass.java --- a/graal/com.oracle.graal.graph/src/com/oracle/graal/graph/NodeClass.java Tue Feb 17 20:38:13 2015 +0100 +++ b/graal/com.oracle.graal.graph/src/com/oracle/graal/graph/NodeClass.java Tue Feb 17 23:08:49 2015 +0100 @@ -30,6 +30,7 @@ import java.lang.annotation.*; import java.lang.reflect.*; import java.util.*; +import java.util.concurrent.atomic.*; import com.oracle.graal.compiler.common.*; import com.oracle.graal.debug.*; @@ -96,7 +97,7 @@ private static final Class INPUT_LIST_CLASS = NodeInputList.class; private static final Class SUCCESSOR_LIST_CLASS = NodeSuccessorList.class; - private static int nextIterableId = 0; + private static AtomicInteger nextIterableId = new AtomicInteger(); private final InputEdges inputs; private final SuccessorEdges successors; @@ -172,7 +173,7 @@ } else if (IterableNodeType.class.isAssignableFrom(clazz)) { ITERABLE_NODE_TYPES.increment(); try (TimerCloseable t1 = Init_IterableIds.start()) { - this.iterableId = nextIterableId++; + this.iterableId = nextIterableId.getAndIncrement(); NodeClass snc = superNodeClass; while (snc != null && IterableNodeType.class.isAssignableFrom(snc.getClazz())) { @@ -245,7 +246,7 @@ } static int allocatedNodeIterabledIds() { - return nextIterableId; + return nextIterableId.get(); } public EnumSet getAllowedUsageTypes() {