Mercurial > hg > truffle
changeset 18743:220d7f242e57
use deterministic iteration-order data structures
line wrap: on
line diff
--- 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<CacheEntry, Node> cachedLeafNodes = new HashMap<>(); + private final HashMap<CacheEntry, Node> cachedLeafNodes = CollectionsFactory.newMap(); /* * Indicates that the graph should no longer be modified. Frozen graphs can be used my multiple
--- 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<ExceptionHandler, ExceptionDispatchBlock> initialExceptionDispatch = new HashMap<>(); + private HashMap<ExceptionHandler, ExceptionDispatchBlock> initialExceptionDispatch = CollectionsFactory.newMap(); private ExceptionDispatchBlock handleExceptions(int bci) { ExceptionDispatchBlock lastHandler = null;
--- 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<AbstractBlock<?>, BlockData> blockData = new HashMap<>(); + Map<AbstractBlock<?>, BlockData> blockData = CollectionsFactory.newMap(); Register[] callerSaveRegs; @@ -90,7 +91,7 @@ */ int[] eligibleRegs; - Map<StackSlot, Integer> stackIndices = new HashMap<>(); + Map<StackSlot, Integer> stackIndices = CollectionsFactory.newMap(); int numRegs;
--- 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<AbstractEndNode> endsToMerge = new LinkedList<>(); - Map<AbstractEndNode, LoopEndNode> reverseEnds = new HashMap<>(); // map peel's exit to the - // corresponding loop exits + // map peel exits to the corresponding loop exits + Map<AbstractEndNode, LoopEndNode> reverseEnds = CollectionsFactory.newMap(); LoopBeginNode loopBegin = original().loop().loopBegin(); for (LoopEndNode le : loopBegin.loopEnds()) { AbstractEndNode duplicate = getDuplicatedNode(le);
--- 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<AbstractEndNode> falseEnds = new ArrayList<>(mergePredecessors.size()); List<AbstractEndNode> trueEnds = new ArrayList<>(mergePredecessors.size()); - Map<AbstractEndNode, ValueNode> phiValues = new HashMap<>(mergePredecessors.size()); + Map<AbstractEndNode, ValueNode> phiValues = CollectionsFactory.newMap(mergePredecessors.size()); BeginNode oldFalseSuccessor = falseSuccessor(); BeginNode oldTrueSuccessor = trueSuccessor();
--- 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<LocationIdentity, MemoryNode> toMap() { - HashMap<LocationIdentity, MemoryNode> res = new HashMap<>(locationIdentities.size()); + HashMap<LocationIdentity, MemoryNode> res = CollectionsFactory.newMap(locationIdentities.size()); for (int i = 0; i < nodes.size(); i++) { res.put(locationIdentities.get(i), (MemoryNode) nodes.get(i)); }
--- 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<LocationIdentity, MemoryNode> 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<LoopBeginNode, Set<LocationIdentity>> modifiedInLoops = Node.newIdentityMap(); - ReentrantNodeIterator.apply(new CollectMemoryCheckpointsClosure(modifiedInLoops), graph.start(), new HashSet<LocationIdentity>()); + 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<? extends MemoryMap> states, boolean updateExistingPhis) { MemoryMapImpl newState = new MemoryMapImpl(); - Set<LocationIdentity> keys = new HashSet<>(); + Set<LocationIdentity> keys = CollectionsFactory.newSet(); for (MemoryMap other : states) { keys.addAll(other.getLocations()); } @@ -238,7 +238,7 @@ @Override protected Set<LocationIdentity> merge(MergeNode merge, List<Set<LocationIdentity>> states) { - Set<LocationIdentity> result = new HashSet<>(); + Set<LocationIdentity> result = CollectionsFactory.newSet(); for (Set<LocationIdentity> other : states) { result.addAll(other); } @@ -247,13 +247,13 @@ @Override protected Set<LocationIdentity> afterSplit(BeginNode node, Set<LocationIdentity> oldState) { - return new HashSet<>(oldState); + return CollectionsFactory.newSet(oldState); } @Override protected Map<LoopExitNode, Set<LocationIdentity>> processLoop(LoopBeginNode loop, Set<LocationIdentity> initialState) { - LoopInfo<Set<LocationIdentity>> loopInfo = ReentrantNodeIterator.processLoop(this, loop, new HashSet<LocationIdentity>()); - Set<LocationIdentity> modifiedLocations = new HashSet<>(); + LoopInfo<Set<LocationIdentity>> loopInfo = ReentrantNodeIterator.processLoop(this, loop, CollectionsFactory.newSet()); + Set<LocationIdentity> modifiedLocations = CollectionsFactory.newSet(); for (Set<LocationIdentity> end : loopInfo.endStates.values()) { modifiedLocations.addAll(end); } @@ -372,11 +372,11 @@ Set<LocationIdentity> 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<LocationIdentity, MemoryPhiNode> phis = new HashMap<>(); + Map<LocationIdentity, MemoryPhiNode> phis = CollectionsFactory.newMap(); if (updateExistingPhis) { for (MemoryPhiNode phi : loop.phis().filter(MemoryPhiNode.class).snapshot()) {
--- 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<NodeEvent> filter) { - this.nodes = new HashSet<>(); + this.nodes = Node.newSet(); this.filter = filter; }
--- 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 <StateT> LoopInfo<StateT> processLoop(BlockIteratorClosure<StateT> closure, Loop<Block> loop, StateT initialState) { - Map<FixedNode, StateT> blockEndStates = apply(closure, loop.getHeader(), initialState, new HashSet<>(loop.getBlocks())); + Map<FixedNode, StateT> blockEndStates = apply(closure, loop.getHeader(), initialState, CollectionsFactory.newSet(loop.getBlocks())); List<Block> predecessors = loop.getHeader().getPredecessors(); LoopInfo<StateT> info = new LoopInfo<>(predecessors.size() - 1, loop.getExits().size());
--- 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<ResolvedJavaMethod, ResolvedJavaMethod> methodSubstitutions = new HashMap<>(); - public final Map<ResolvedJavaMethod, Class<? extends FixedWithNextNode>> macroSubstitutions = new HashMap<>(); + public final Map<ResolvedJavaMethod, ResolvedJavaMethod> methodSubstitutions = CollectionsFactory.newMap(); + public final Map<ResolvedJavaMethod, Class<? extends FixedWithNextNode>> macroSubstitutions = CollectionsFactory.newMap(); public final Set<ResolvedJavaMethod> forcedSubstitutions = new HashSet<>(); public ClassReplacements(Class<?>[] substitutionClasses, AtomicReference<ClassReplacements> 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"));
--- 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
--- 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);
--- 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
--- 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<ReadEliminationBlockState>.MergeProcessor { - private final HashMap<Object, ValuePhiNode> materializedPhis = new HashMap<>(); + private final HashMap<Object, ValuePhiNode> materializedPhis = CollectionsFactory.newMap(); public ReadEliminationMergeProcessor(Block mergeBlock) { super(mergeBlock);