# HG changeset patch # User Doug Simon # Date 1419134191 -36000 # Node ID 220d7f242e579b9744c901ef54ecd5b54e8c8f1a # Parent 5df121664e08b71751d279c44c756e0c44daf09a use deterministic iteration-order data structures diff -r 5df121664e08 -r 220d7f242e57 graal/com.oracle.graal.graph/src/com/oracle/graal/graph/Graph.java --- a/graal/com.oracle.graal.graph/src/com/oracle/graal/graph/Graph.java Sun Dec 21 13:53:15 2014 +1000 +++ b/graal/com.oracle.graal.graph/src/com/oracle/graal/graph/Graph.java Sun Dec 21 13:56:31 2014 +1000 @@ -23,7 +23,6 @@ package com.oracle.graal.graph; import static com.oracle.graal.graph.Edges.Type.*; -import static com.oracle.graal.graph.Node.*; import java.util.*; @@ -85,7 +84,7 @@ * Used to global value number {@link ValueNumberable} {@linkplain NodeClass#isLeafNode() leaf} * nodes. */ - private final HashMap cachedLeafNodes = new HashMap<>(); + private final HashMap cachedLeafNodes = CollectionsFactory.newMap(); /* * Indicates that the graph should no longer be modified. Frozen graphs can be used my multiple diff -r 5df121664e08 -r 220d7f242e57 graal/com.oracle.graal.java/src/com/oracle/graal/java/BciBlockMapping.java --- a/graal/com.oracle.graal.java/src/com/oracle/graal/java/BciBlockMapping.java Sun Dec 21 13:53:15 2014 +1000 +++ b/graal/com.oracle.graal.java/src/com/oracle/graal/java/BciBlockMapping.java Sun Dec 21 13:56:31 2014 +1000 @@ -30,6 +30,7 @@ import com.oracle.graal.api.code.*; import com.oracle.graal.api.meta.*; import com.oracle.graal.bytecode.*; +import com.oracle.graal.compiler.common.*; import com.oracle.graal.compiler.common.cfg.*; import com.oracle.graal.debug.*; import com.oracle.graal.debug.Debug.Scope; @@ -601,7 +602,7 @@ } } - private HashMap initialExceptionDispatch = new HashMap<>(); + private HashMap initialExceptionDispatch = CollectionsFactory.newMap(); private ExceptionDispatchBlock handleExceptions(int bci) { ExceptionDispatchBlock lastHandler = null; diff -r 5df121664e08 -r 220d7f242e57 graal/com.oracle.graal.lir/src/com/oracle/graal/lir/RedundantMoveElimination.java --- a/graal/com.oracle.graal.lir/src/com/oracle/graal/lir/RedundantMoveElimination.java Sun Dec 21 13:53:15 2014 +1000 +++ b/graal/com.oracle.graal.lir/src/com/oracle/graal/lir/RedundantMoveElimination.java Sun Dec 21 13:56:31 2014 +1000 @@ -28,6 +28,7 @@ import com.oracle.graal.api.code.*; import com.oracle.graal.api.meta.*; +import com.oracle.graal.compiler.common.*; import com.oracle.graal.compiler.common.cfg.*; import com.oracle.graal.debug.*; import com.oracle.graal.lir.LIRInstruction.OperandFlag; @@ -81,7 +82,7 @@ int entryValueNum; } - Map, BlockData> blockData = new HashMap<>(); + Map, BlockData> blockData = CollectionsFactory.newMap(); Register[] callerSaveRegs; @@ -90,7 +91,7 @@ */ int[] eligibleRegs; - Map stackIndices = new HashMap<>(); + Map stackIndices = CollectionsFactory.newMap(); int numRegs; diff -r 5df121664e08 -r 220d7f242e57 graal/com.oracle.graal.loop/src/com/oracle/graal/loop/LoopFragmentInside.java --- a/graal/com.oracle.graal.loop/src/com/oracle/graal/loop/LoopFragmentInside.java Sun Dec 21 13:53:15 2014 +1000 +++ b/graal/com.oracle.graal.loop/src/com/oracle/graal/loop/LoopFragmentInside.java Sun Dec 21 13:56:31 2014 +1000 @@ -294,8 +294,8 @@ private BeginNode mergeEnds() { assert isDuplicate(); List endsToMerge = new LinkedList<>(); - Map reverseEnds = new HashMap<>(); // map peel's exit to the - // corresponding loop exits + // map peel exits to the corresponding loop exits + Map reverseEnds = CollectionsFactory.newMap(); LoopBeginNode loopBegin = original().loop().loopBegin(); for (LoopEndNode le : loopBegin.loopEnds()) { AbstractEndNode duplicate = getDuplicatedNode(le); diff -r 5df121664e08 -r 220d7f242e57 graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/IfNode.java --- a/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/IfNode.java Sun Dec 21 13:53:15 2014 +1000 +++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/IfNode.java Sun Dec 21 13:56:31 2014 +1000 @@ -709,7 +709,7 @@ List falseEnds = new ArrayList<>(mergePredecessors.size()); List trueEnds = new ArrayList<>(mergePredecessors.size()); - Map phiValues = new HashMap<>(mergePredecessors.size()); + Map phiValues = CollectionsFactory.newMap(mergePredecessors.size()); BeginNode oldFalseSuccessor = falseSuccessor(); BeginNode oldTrueSuccessor = trueSuccessor(); diff -r 5df121664e08 -r 220d7f242e57 graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/MemoryMapNode.java --- a/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/MemoryMapNode.java Sun Dec 21 13:53:15 2014 +1000 +++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/MemoryMapNode.java Sun Dec 21 13:56:31 2014 +1000 @@ -27,6 +27,7 @@ import java.util.*; import com.oracle.graal.api.meta.*; +import com.oracle.graal.compiler.common.*; import com.oracle.graal.compiler.common.type.*; import com.oracle.graal.graph.*; import com.oracle.graal.nodeinfo.*; @@ -90,7 +91,7 @@ } public Map toMap() { - HashMap res = new HashMap<>(locationIdentities.size()); + HashMap res = CollectionsFactory.newMap(locationIdentities.size()); for (int i = 0; i < nodes.size(); i++) { res.put(locationIdentities.get(i), (MemoryNode) nodes.get(i)); } diff -r 5df121664e08 -r 220d7f242e57 graal/com.oracle.graal.phases.common/src/com/oracle/graal/phases/common/FloatingReadPhase.java --- a/graal/com.oracle.graal.phases.common/src/com/oracle/graal/phases/common/FloatingReadPhase.java Sun Dec 21 13:53:15 2014 +1000 +++ b/graal/com.oracle.graal.phases.common/src/com/oracle/graal/phases/common/FloatingReadPhase.java Sun Dec 21 13:56:31 2014 +1000 @@ -52,16 +52,16 @@ private final Map lastMemorySnapshot; public MemoryMapImpl(MemoryMapImpl memoryMap) { - lastMemorySnapshot = new HashMap<>(memoryMap.lastMemorySnapshot); + lastMemorySnapshot = CollectionsFactory.newMap(memoryMap.lastMemorySnapshot); } public MemoryMapImpl(StartNode start) { - lastMemorySnapshot = new HashMap<>(); + lastMemorySnapshot = CollectionsFactory.newMap(); lastMemorySnapshot.put(ANY_LOCATION, start); } public MemoryMapImpl() { - lastMemorySnapshot = new HashMap<>(); + lastMemorySnapshot = CollectionsFactory.newMap(); } @Override @@ -132,7 +132,7 @@ @Override protected void run(StructuredGraph graph) { Map> modifiedInLoops = Node.newIdentityMap(); - ReentrantNodeIterator.apply(new CollectMemoryCheckpointsClosure(modifiedInLoops), graph.start(), new HashSet()); + ReentrantNodeIterator.apply(new CollectMemoryCheckpointsClosure(modifiedInLoops), graph.start(), CollectionsFactory.newSet()); HashSetNodeEventListener listener = new HashSetNodeEventListener(EnumSet.of(NODE_ADDED, ZERO_USAGES)); try (NodeEventScope nes = graph.trackNodeEvents(listener)) { ReentrantNodeIterator.apply(new FloatingReadClosure(modifiedInLoops, createFloatingReads, createMemoryMapNodes, updateExistingPhis), graph.start(), new MemoryMapImpl(graph.start())); @@ -153,7 +153,7 @@ public static MemoryMapImpl mergeMemoryMaps(MergeNode merge, List states, boolean updateExistingPhis) { MemoryMapImpl newState = new MemoryMapImpl(); - Set keys = new HashSet<>(); + Set keys = CollectionsFactory.newSet(); for (MemoryMap other : states) { keys.addAll(other.getLocations()); } @@ -238,7 +238,7 @@ @Override protected Set merge(MergeNode merge, List> states) { - Set result = new HashSet<>(); + Set result = CollectionsFactory.newSet(); for (Set other : states) { result.addAll(other); } @@ -247,13 +247,13 @@ @Override protected Set afterSplit(BeginNode node, Set oldState) { - return new HashSet<>(oldState); + return CollectionsFactory.newSet(oldState); } @Override protected Map> processLoop(LoopBeginNode loop, Set initialState) { - LoopInfo> loopInfo = ReentrantNodeIterator.processLoop(this, loop, new HashSet()); - Set modifiedLocations = new HashSet<>(); + LoopInfo> loopInfo = ReentrantNodeIterator.processLoop(this, loop, CollectionsFactory.newSet()); + Set modifiedLocations = CollectionsFactory.newSet(); for (Set end : loopInfo.endStates.values()) { modifiedLocations.addAll(end); } @@ -372,11 +372,11 @@ Set modifiedLocations = modifiedInLoops.get(loop); if (modifiedLocations.contains(ANY_LOCATION)) { // create phis for all locations if ANY is modified in the loop - modifiedLocations = new HashSet<>(modifiedLocations); + modifiedLocations = CollectionsFactory.newSet(modifiedLocations); modifiedLocations.addAll(initialState.lastMemorySnapshot.keySet()); } - Map phis = new HashMap<>(); + Map phis = CollectionsFactory.newMap(); if (updateExistingPhis) { for (MemoryPhiNode phi : loop.phis().filter(MemoryPhiNode.class).snapshot()) { diff -r 5df121664e08 -r 220d7f242e57 graal/com.oracle.graal.phases.common/src/com/oracle/graal/phases/common/util/HashSetNodeEventListener.java --- a/graal/com.oracle.graal.phases.common/src/com/oracle/graal/phases/common/util/HashSetNodeEventListener.java Sun Dec 21 13:53:15 2014 +1000 +++ b/graal/com.oracle.graal.phases.common/src/com/oracle/graal/phases/common/util/HashSetNodeEventListener.java Sun Dec 21 13:56:31 2014 +1000 @@ -49,7 +49,7 @@ * filter. */ public HashSetNodeEventListener(Set filter) { - this.nodes = new HashSet<>(); + this.nodes = Node.newSet(); this.filter = filter; } diff -r 5df121664e08 -r 220d7f242e57 graal/com.oracle.graal.phases/src/com/oracle/graal/phases/graph/ReentrantBlockIterator.java --- a/graal/com.oracle.graal.phases/src/com/oracle/graal/phases/graph/ReentrantBlockIterator.java Sun Dec 21 13:53:15 2014 +1000 +++ b/graal/com.oracle.graal.phases/src/com/oracle/graal/phases/graph/ReentrantBlockIterator.java Sun Dec 21 13:56:31 2014 +1000 @@ -24,6 +24,7 @@ import java.util.*; +import com.oracle.graal.compiler.common.*; import com.oracle.graal.compiler.common.cfg.*; import com.oracle.graal.graph.*; import com.oracle.graal.nodes.*; @@ -60,7 +61,7 @@ } public static LoopInfo processLoop(BlockIteratorClosure closure, Loop loop, StateT initialState) { - Map blockEndStates = apply(closure, loop.getHeader(), initialState, new HashSet<>(loop.getBlocks())); + Map blockEndStates = apply(closure, loop.getHeader(), initialState, CollectionsFactory.newSet(loop.getBlocks())); List predecessors = loop.getHeader().getPredecessors(); LoopInfo info = new LoopInfo<>(predecessors.size() - 1, loop.getExits().size()); diff -r 5df121664e08 -r 220d7f242e57 graal/com.oracle.graal.replacements/src/com/oracle/graal/replacements/ReplacementsImpl.java --- a/graal/com.oracle.graal.replacements/src/com/oracle/graal/replacements/ReplacementsImpl.java Sun Dec 21 13:53:15 2014 +1000 +++ b/graal/com.oracle.graal.replacements/src/com/oracle/graal/replacements/ReplacementsImpl.java Sun Dec 21 13:56:31 2014 +1000 @@ -75,8 +75,8 @@ * Encapsulates method and macro substitutions for a single class. */ protected class ClassReplacements { - public final Map methodSubstitutions = new HashMap<>(); - public final Map> macroSubstitutions = new HashMap<>(); + public final Map methodSubstitutions = CollectionsFactory.newMap(); + public final Map> macroSubstitutions = CollectionsFactory.newMap(); public final Set forcedSubstitutions = new HashSet<>(); public ClassReplacements(Class[] substitutionClasses, AtomicReference ref) { @@ -201,13 +201,13 @@ public ReplacementsImpl(Providers providers, SnippetReflectionProvider snippetReflection, Assumptions assumptions, TargetDescription target) { this.providers = providers.copyWith(this); - this.classReplacements = new HashMap<>(); - this.internalNameToSubstitutionClasses = new HashMap<>(); + this.classReplacements = CollectionsFactory.newMap(); + this.internalNameToSubstitutionClasses = CollectionsFactory.newMap(); this.snippetReflection = snippetReflection; this.target = target; this.assumptions = assumptions; this.graphs = new ConcurrentHashMap<>(); - this.snippetTemplateCache = new HashMap<>(); + this.snippetTemplateCache = CollectionsFactory.newMap(); } private static final boolean UseSnippetGraphCache = Boolean.parseBoolean(System.getProperty("graal.useSnippetGraphCache", "true")); diff -r 5df121664e08 -r 220d7f242e57 graal/com.oracle.graal.virtual/src/com/oracle/graal/virtual/phases/ea/PEReadEliminationBlockState.java --- a/graal/com.oracle.graal.virtual/src/com/oracle/graal/virtual/phases/ea/PEReadEliminationBlockState.java Sun Dec 21 13:53:15 2014 +1000 +++ b/graal/com.oracle.graal.virtual/src/com/oracle/graal/virtual/phases/ea/PEReadEliminationBlockState.java Sun Dec 21 13:56:31 2014 +1000 @@ -25,6 +25,7 @@ import java.util.*; import com.oracle.graal.api.meta.*; +import com.oracle.graal.compiler.common.*; import com.oracle.graal.nodes.*; import com.oracle.graal.nodes.virtual.*; @@ -64,12 +65,12 @@ } public PEReadEliminationBlockState() { - readCache = new HashMap<>(); + readCache = CollectionsFactory.newMap(); } public PEReadEliminationBlockState(PEReadEliminationBlockState other) { super(other); - readCache = new HashMap<>(other.readCache); + readCache = CollectionsFactory.newMap(other.readCache); } @Override diff -r 5df121664e08 -r 220d7f242e57 graal/com.oracle.graal.virtual/src/com/oracle/graal/virtual/phases/ea/PartialEscapePhase.java --- a/graal/com.oracle.graal.virtual/src/com/oracle/graal/virtual/phases/ea/PartialEscapePhase.java Sun Dec 21 13:53:15 2014 +1000 +++ b/graal/com.oracle.graal.virtual/src/com/oracle/graal/virtual/phases/ea/PartialEscapePhase.java Sun Dec 21 13:56:31 2014 +1000 @@ -28,6 +28,7 @@ import java.util.*; import java.util.function.*; +import com.oracle.graal.compiler.common.*; import com.oracle.graal.graph.*; import com.oracle.graal.nodes.*; import com.oracle.graal.nodes.cfg.*; @@ -122,7 +123,7 @@ for (Node usage : commitUsage.usages()) { if (usage instanceof MethodCallTargetNode) { if (hints == null) { - hints = new HashMap<>(); + hints = CollectionsFactory.newMap(); } Invoke invoke = ((MethodCallTargetNode) usage).invoke(); hints.put(invoke, sum / invokeSum); diff -r 5df121664e08 -r 220d7f242e57 graal/com.oracle.graal.virtual/src/com/oracle/graal/virtual/phases/ea/ReadEliminationBlockState.java --- a/graal/com.oracle.graal.virtual/src/com/oracle/graal/virtual/phases/ea/ReadEliminationBlockState.java Sun Dec 21 13:53:15 2014 +1000 +++ b/graal/com.oracle.graal.virtual/src/com/oracle/graal/virtual/phases/ea/ReadEliminationBlockState.java Sun Dec 21 13:56:31 2014 +1000 @@ -25,6 +25,7 @@ import java.util.*; import com.oracle.graal.api.meta.*; +import com.oracle.graal.compiler.common.*; import com.oracle.graal.nodes.*; import com.oracle.graal.nodes.extended.*; @@ -128,11 +129,11 @@ } public ReadEliminationBlockState() { - readCache = new HashMap<>(); + readCache = CollectionsFactory.newMap(); } public ReadEliminationBlockState(ReadEliminationBlockState other) { - readCache = new HashMap<>(other.readCache); + readCache = CollectionsFactory.newMap(other.readCache); } @Override diff -r 5df121664e08 -r 220d7f242e57 graal/com.oracle.graal.virtual/src/com/oracle/graal/virtual/phases/ea/ReadEliminationClosure.java --- a/graal/com.oracle.graal.virtual/src/com/oracle/graal/virtual/phases/ea/ReadEliminationClosure.java Sun Dec 21 13:53:15 2014 +1000 +++ b/graal/com.oracle.graal.virtual/src/com/oracle/graal/virtual/phases/ea/ReadEliminationClosure.java Sun Dec 21 13:56:31 2014 +1000 @@ -27,6 +27,7 @@ import java.util.*; import com.oracle.graal.api.meta.*; +import com.oracle.graal.compiler.common.*; import com.oracle.graal.compiler.common.type.*; import com.oracle.graal.graph.*; import com.oracle.graal.nodes.*; @@ -193,7 +194,7 @@ private class ReadEliminationMergeProcessor extends EffectsClosure.MergeProcessor { - private final HashMap materializedPhis = new HashMap<>(); + private final HashMap materializedPhis = CollectionsFactory.newMap(); public ReadEliminationMergeProcessor(Block mergeBlock) { super(mergeBlock);