Mercurial > hg > graal-compiler
changeset 18383:1518c3296cc8
use deterministic iteration order Set and Map data structures when in the scope of a replay compilation context
line wrap: on
line diff
--- a/graal/com.oracle.graal.compiler.common/src/com/oracle/graal/compiler/common/remote/Context.java Sat Nov 15 23:19:58 2014 +0100 +++ b/graal/com.oracle.graal.compiler.common/src/com/oracle/graal/compiler/common/remote/Context.java Sun Nov 16 09:44:04 2014 +0100 @@ -59,6 +59,30 @@ this.mode = mode; } + public static <K, V> HashMap<K, V> newMap() { + return Context.getCurrent() == null ? new HashMap<>() : new LinkedHashMap<>(); + } + + public static <K, V> HashMap<K, V> newMap(Map<K, V> m) { + return Context.getCurrent() == null ? new HashMap<>(m) : new LinkedHashMap<>(m); + } + + public static <K, V> HashMap<K, V> newMap(int initialCapacity) { + return Context.getCurrent() == null ? new HashMap<>(initialCapacity) : new LinkedHashMap<>(initialCapacity); + } + + public static <K, V> Map<K, V> newIdentityMap() { + return Context.getCurrent() == null ? new IdentityHashMap<>() : new LinkedIdentityHashMap<>(); + } + + public static <K, V> Map<K, V> newIdentityMap(int expectedMaxSize) { + return Context.getCurrent() == null ? new IdentityHashMap<>(expectedMaxSize) : new LinkedIdentityHashMap<>(); + } + + public static <K, V> Map<K, V> newIdentityMap(Map<K, V> m) { + return Context.getCurrent() == null ? new IdentityHashMap<>(m) : new LinkedIdentityHashMap<>(m); + } + /** * Gets a descriptor for the fields in a class that can be used for serialization. */
--- a/graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/gen/DebugInfoBuilder.java Sat Nov 15 23:19:58 2014 +0100 +++ b/graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/gen/DebugInfoBuilder.java Sun Nov 16 09:44:04 2014 +0100 @@ -22,8 +22,6 @@ */ package com.oracle.graal.compiler.gen; -import static com.oracle.graal.graph.util.CollectionsAccess.*; - import java.util.*; import java.util.Map.Entry; @@ -49,8 +47,8 @@ this.nodeOperands = nodeOperands; } - protected final Map<VirtualObjectNode, VirtualObject> virtualObjects = new HashMap<>(); - protected final Map<VirtualObjectNode, EscapeObjectState> objectStates = newNodeIdentityMap(); + protected final Map<VirtualObjectNode, VirtualObject> virtualObjects = Node.newMap(); + protected final Map<VirtualObjectNode, EscapeObjectState> objectStates = Node.newIdentityMap(); public LIRFrameState build(FrameState topState, LabelRef exceptionEdge) { assert virtualObjects.size() == 0; @@ -79,7 +77,7 @@ boolean changed; do { changed = false; - Map<VirtualObjectNode, VirtualObject> virtualObjectsCopy = newIdentityMap(virtualObjects); + Map<VirtualObjectNode, VirtualObject> virtualObjectsCopy = Node.newIdentityMap(virtualObjects); for (Entry<VirtualObjectNode, VirtualObject> entry : virtualObjectsCopy.entrySet()) { if (entry.getValue().getValues() == null) { VirtualObjectNode vobj = entry.getKey();
--- a/graal/com.oracle.graal.graph/src/com/oracle/graal/graph/Node.java Sat Nov 15 23:19:58 2014 +0100 +++ b/graal/com.oracle.graal.graph/src/com/oracle/graal/graph/Node.java Sun Nov 16 09:44:04 2014 +0100 @@ -51,8 +51,18 @@ * * <h1>Replay Compilation</h1> * - * To enable deterministic replay compilation, node hash set creation within a compilation scope - * must {@link #newNodeHashSet()} or {@link #newNodeHashSet(Collection)}. + * To enable deterministic replay compilation, node sets and node maps should be instantiated with + * the following methods: + * <ul> + * <li>{@link #newSet()}</li> + * <li>{@link #newSet(Collection)}</li> + * <li>{@link #newMap()}</li> + * <li>{@link #newMap(int)}</li> + * <li>{@link #newMap(Map)}</li> + * <li>{@link #newIdentityMap()}</li> + * <li>{@link #newIdentityMap(int)}</li> + * <li>{@link #newIdentityMap(Map)}</li> + * </ul> * * <h1>Assertions and Verification</h1> * @@ -199,21 +209,58 @@ } /** - * Creates a {@link Node} hash set. The return set will be a {@link LinkedHashSet} if the - * current thread has an active compilation replay scope. This is requires to make replay - * compilations deterministic. + * Creates a {@link Node} set. If the current thread has a non-null + * {@linkplain Context#getCurrent() compilation replay scope}, the returned set will have a + * deterministic iteration order determined by the order in which elements are inserted in the + * map. */ - public static <E extends Node> HashSet<E> newNodeHashSet() { + public static <E extends Node> Set<E> newSet() { return Context.getCurrent() == null ? new HashSet<>() : new LinkedHashSet<>(); } /** - * @see #newNodeHashSet() + * @see #newSet() */ - public static <E extends Node> HashSet<E> newNodeHashSet(Collection<? extends E> c) { + public static <E extends Node> Set<E> newSet(Collection<? extends E> c) { return Context.getCurrent() == null ? new HashSet<>(c) : new LinkedHashSet<>(c); } + public static <K extends Node, V> Map<K, V> newMap() { + // Node.equals() and Node.hashCode() are final and are implemented + // purely in terms of identity so HashMap and IdentityHashMap with + // Node's as keys will behave the same. We choose to use the latter + // due to its lighter memory footprint. + return newIdentityMap(); + } + + public static <K extends Node, V> Map<K, V> newMap(Map<K, V> m) { + // Node.equals() and Node.hashCode() are final and are implemented + // purely in terms of identity so HashMap and IdentityHashMap with + // Node's as keys will behave the same. We choose to use the latter + // due to its lighter memory footprint. + return newIdentityMap(m); + } + + public static <K extends Node, V> Map<K, V> newMap(int expectedMaxSize) { + // Node.equals() and Node.hashCode() are final and are implemented + // purely in terms of identity so HashMap and IdentityHashMap with + // Node's as keys will behave the same. We choose to use the latter + // due to its lighter memory footprint. + return newIdentityMap(expectedMaxSize); + } + + public static <K extends Node, V> Map<K, V> newIdentityMap() { + return Context.newIdentityMap(); + } + + public static <K extends Node, V> Map<K, V> newIdentityMap(Map<K, V> m) { + return Context.newIdentityMap(m); + } + + public static <K extends Node, V> Map<K, V> newIdentityMap(int expectedMaxSize) { + return Context.newIdentityMap(expectedMaxSize); + } + /** * Gets the graph context of this node. */
--- a/graal/com.oracle.graal.graph/src/com/oracle/graal/graph/NodeClass.java Sat Nov 15 23:19:58 2014 +0100 +++ b/graal/com.oracle.graal.graph/src/com/oracle/graal/graph/NodeClass.java Sun Nov 16 09:44:04 2014 +0100 @@ -26,7 +26,6 @@ import static com.oracle.graal.graph.Edges.*; import static com.oracle.graal.graph.InputEdges.*; import static com.oracle.graal.graph.Node.*; -import static com.oracle.graal.graph.util.CollectionsAccess.*; import java.lang.annotation.*; import java.lang.reflect.*;
--- a/graal/com.oracle.graal.loop/src/com/oracle/graal/loop/InductionVariables.java Sat Nov 15 23:19:58 2014 +0100 +++ b/graal/com.oracle.graal.loop/src/com/oracle/graal/loop/InductionVariables.java Sun Nov 16 09:44:04 2014 +0100 @@ -22,7 +22,7 @@ */ package com.oracle.graal.loop; -import static com.oracle.graal.graph.util.CollectionsAccess.*; +import static com.oracle.graal.graph.Node.*; import java.util.*; @@ -38,7 +38,7 @@ public InductionVariables(LoopEx loop) { this.loop = loop; - ivs = newNodeIdentityMap(); + ivs = newIdentityMap(); findDerived(findBasic()); }
--- a/graal/com.oracle.graal.loop/src/com/oracle/graal/loop/LoopFragment.java Sat Nov 15 23:19:58 2014 +0100 +++ b/graal/com.oracle.graal.loop/src/com/oracle/graal/loop/LoopFragment.java Sun Nov 16 09:44:04 2014 +0100 @@ -332,7 +332,7 @@ * VirtualState nodes contained in the old exit's state may be shared by other * dominated VirtualStates. Those dominated virtual states need to see the * proxy->phi update that are applied below. - * + * * We now update the original fragment's nodes accordingly: */ originalExitState.applyToVirtual(node -> original.nodes.clearAndGrow(node));
--- a/graal/com.oracle.graal.loop/src/com/oracle/graal/loop/LoopFragmentInside.java Sat Nov 15 23:19:58 2014 +0100 +++ b/graal/com.oracle.graal.loop/src/com/oracle/graal/loop/LoopFragmentInside.java Sun Nov 16 09:44:04 2014 +0100 @@ -22,16 +22,14 @@ */ package com.oracle.graal.loop; -import static com.oracle.graal.graph.util.CollectionsAccess.*; - import java.util.*; import com.oracle.graal.compiler.common.*; -import com.oracle.graal.graph.Graph.DuplicationReplacement; import com.oracle.graal.graph.*; +import com.oracle.graal.graph.Graph.*; import com.oracle.graal.graph.iterators.*; import com.oracle.graal.nodes.*; -import com.oracle.graal.nodes.VirtualState.NodeClosure; +import com.oracle.graal.nodes.VirtualState.*; import com.oracle.graal.nodes.util.*; public class LoopFragmentInside extends LoopFragment { @@ -145,7 +143,7 @@ final StructuredGraph graph = graph(); return new DuplicationReplacement() { - private HashMap<Node, Node> seenNode = new HashMap<>(); + private Map<Node, Node> seenNode = Node.newMap(); @Override public Node replacement(Node original) { @@ -306,7 +304,7 @@ reverseEnds.put(duplicate, le); } } - mergedInitializers = newNodeIdentityMap(); + mergedInitializers = Node.newIdentityMap(); BeginNode newExit; StructuredGraph graph = graph(); if (endsToMerge.size() == 1) {
--- a/graal/com.oracle.graal.loop/src/com/oracle/graal/loop/LoopsData.java Sat Nov 15 23:19:58 2014 +0100 +++ b/graal/com.oracle.graal.loop/src/com/oracle/graal/loop/LoopsData.java Sun Nov 16 09:44:04 2014 +0100 @@ -22,20 +22,20 @@ */ package com.oracle.graal.loop; -import static com.oracle.graal.graph.util.CollectionsAccess.*; - import java.util.*; import com.oracle.graal.compiler.common.cfg.*; +import com.oracle.graal.compiler.common.remote.*; import com.oracle.graal.debug.*; import com.oracle.graal.debug.Debug.Scope; +import com.oracle.graal.graph.*; import com.oracle.graal.nodes.*; import com.oracle.graal.nodes.cfg.*; public class LoopsData { - private Map<Loop<Block>, LoopEx> loopToEx = newIdentityMap(); - private Map<LoopBeginNode, LoopEx> loopBeginToEx = newNodeIdentityMap(); + private Map<Loop<Block>, LoopEx> loopToEx = Context.newIdentityMap(); + private Map<LoopBeginNode, LoopEx> loopBeginToEx = Node.newIdentityMap(); private ControlFlowGraph cfg; public LoopsData(final StructuredGraph graph) {
--- a/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/LoopBeginNode.java Sat Nov 15 23:19:58 2014 +0100 +++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/LoopBeginNode.java Sun Nov 16 09:44:04 2014 +0100 @@ -219,7 +219,7 @@ */ public void removeDeadPhis() { if (phis().isNotEmpty()) { - Set<PhiNode> alive = new HashSet<>(); + Set<PhiNode> alive = Node.newSet(); for (PhiNode phi : phis()) { NodePredicate isAlive = u -> !isPhiAtMerge(u) || alive.contains(u); if (phi.usages().filter(isAlive).isNotEmpty()) {
--- a/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/StructuredGraph.java Sat Nov 15 23:19:58 2014 +0100 +++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/StructuredGraph.java Sun Nov 16 09:44:04 2014 +0100 @@ -186,7 +186,7 @@ copy.setGuardsStage(getGuardsStage()); copy.isAfterFloatingReadPhase = isAfterFloatingReadPhase; copy.hasValueProxies = hasValueProxies; - HashMap<Node, Node> replacements = new HashMap<>(); + Map<Node, Node> replacements = Node.newMap(); replacements.put(start, copy.start); copy.addDuplicates(getNodes(), this, this.getNodeCount(), replacements); return copy;
--- a/graal/com.oracle.graal.phases.common/src/com/oracle/graal/phases/common/ConditionalEliminationPhase.java Sat Nov 15 23:19:58 2014 +0100 +++ b/graal/com.oracle.graal.phases.common/src/com/oracle/graal/phases/common/ConditionalEliminationPhase.java Sun Nov 16 09:44:04 2014 +0100 @@ -22,8 +22,6 @@ */ package com.oracle.graal.phases.common; -import static com.oracle.graal.graph.util.CollectionsAccess.*; - import java.util.*; import com.oracle.graal.api.meta.*; @@ -104,39 +102,39 @@ public static class State extends MergeableState<State> implements Cloneable { private Map<ValueNode, ResolvedJavaType> knownTypes; - private HashSet<ValueNode> knownNonNull; - private HashSet<ValueNode> knownNull; + private Set<ValueNode> knownNonNull; + private Set<ValueNode> knownNull; private Map<LogicNode, ValueNode> trueConditions; private Map<LogicNode, ValueNode> falseConditions; private Map<ValueNode, GuardedStamp> valueConstraints; public State() { - this.knownTypes = newNodeIdentityMap(); - this.knownNonNull = new HashSet<>(); - this.knownNull = new HashSet<>(); - this.trueConditions = newNodeIdentityMap(); - this.falseConditions = newNodeIdentityMap(); - this.valueConstraints = newNodeIdentityMap(); + this.knownTypes = Node.newIdentityMap(); + this.knownNonNull = Node.newSet(); + this.knownNull = Node.newSet(); + this.trueConditions = Node.newIdentityMap(); + this.falseConditions = Node.newIdentityMap(); + this.valueConstraints = Node.newIdentityMap(); } public State(State other) { - this.knownTypes = newNodeIdentityMap(other.knownTypes); - this.knownNonNull = new HashSet<>(other.knownNonNull); - this.knownNull = new HashSet<>(other.knownNull); - this.trueConditions = newNodeIdentityMap(other.trueConditions); - this.falseConditions = newNodeIdentityMap(other.falseConditions); - this.valueConstraints = newNodeIdentityMap(other.valueConstraints); + this.knownTypes = Node.newIdentityMap(other.knownTypes); + this.knownNonNull = Node.newSet(other.knownNonNull); + this.knownNull = Node.newSet(other.knownNull); + this.trueConditions = Node.newIdentityMap(other.trueConditions); + this.falseConditions = Node.newIdentityMap(other.falseConditions); + this.valueConstraints = Node.newIdentityMap(other.valueConstraints); } @Override public boolean merge(MergeNode merge, List<State> withStates) { - Map<ValueNode, ResolvedJavaType> newKnownTypes = newNodeIdentityMap(); - Map<LogicNode, ValueNode> newTrueConditions = newNodeIdentityMap(); - Map<LogicNode, ValueNode> newFalseConditions = newNodeIdentityMap(); - Map<ValueNode, GuardedStamp> newValueConstraints = newNodeIdentityMap(); + Map<ValueNode, ResolvedJavaType> newKnownTypes = Node.newIdentityMap(); + Map<LogicNode, ValueNode> newTrueConditions = Node.newIdentityMap(); + Map<LogicNode, ValueNode> newFalseConditions = Node.newIdentityMap(); + Map<ValueNode, GuardedStamp> newValueConstraints = Node.newIdentityMap(); - HashSet<ValueNode> newKnownNull = new HashSet<>(knownNull); - HashSet<ValueNode> newKnownNonNull = new HashSet<>(knownNonNull); + Set<ValueNode> newKnownNull = Node.newSet(knownNull); + Set<ValueNode> newKnownNonNull = Node.newSet(knownNonNull); for (State state : withStates) { newKnownNull.retainAll(state.knownNull); newKnownNonNull.retainAll(state.knownNonNull); @@ -678,7 +676,7 @@ } // Collect the guards which have produced conditional stamps. - HashSet<GuardNode> provers = new HashSet<>(); + Set<GuardNode> provers = Node.newSet(); for (Map.Entry<ValueNode, GuardedStamp> e : state.valueConstraints.entrySet()) { provers.add(e.getValue().getGuard()); }
--- a/graal/com.oracle.graal.phases.common/src/com/oracle/graal/phases/common/FloatingReadPhase.java Sat Nov 15 23:19:58 2014 +0100 +++ b/graal/com.oracle.graal.phases.common/src/com/oracle/graal/phases/common/FloatingReadPhase.java Sun Nov 16 09:44:04 2014 +0100 @@ -24,11 +24,10 @@ import static com.oracle.graal.api.meta.LocationIdentity.*; import static com.oracle.graal.graph.Graph.NodeEvent.*; -import static com.oracle.graal.graph.util.CollectionsAccess.*; - import java.util.*; import com.oracle.graal.api.meta.*; +import com.oracle.graal.compiler.common.remote.*; import com.oracle.graal.graph.Graph.NodeEventScope; import com.oracle.graal.graph.*; import com.oracle.graal.nodes.*; @@ -131,7 +130,7 @@ @Override protected void run(StructuredGraph graph) { - Map<LoopBeginNode, Set<LocationIdentity>> modifiedInLoops = newNodeIdentityMap(); + Map<LoopBeginNode, Set<LocationIdentity>> modifiedInLoops = Node.newIdentityMap(); ReentrantNodeIterator.apply(new CollectMemoryCheckpointsClosure(modifiedInLoops), graph.start(), new HashSet<LocationIdentity>()); HashSetNodeEventListener listener = new HashSetNodeEventListener(EnumSet.of(NODE_ADDED, ZERO_USAGES)); try (NodeEventScope nes = graph.trackNodeEvents(listener)) { @@ -163,7 +162,7 @@ if (updateExistingPhis) { for (MemoryPhiNode phi : merge.phis().filter(MemoryPhiNode.class)) { if (existingPhis == null) { - existingPhis = newIdentityMap(); + existingPhis = Context.newIdentityMap(); } phi.values().clear(); existingPhis.put(phi.getLocationIdentity(), phi);
--- a/graal/com.oracle.graal.phases.common/src/com/oracle/graal/phases/common/GuardLoweringPhase.java Sat Nov 15 23:19:58 2014 +0100 +++ b/graal/com.oracle.graal.phases.common/src/com/oracle/graal/phases/common/GuardLoweringPhase.java Sun Nov 16 09:44:04 2014 +0100 @@ -23,7 +23,6 @@ package com.oracle.graal.phases.common; import static com.oracle.graal.compiler.common.GraalOptions.*; -import static com.oracle.graal.graph.util.CollectionsAccess.*; import java.util.*; import java.util.Map.Entry; @@ -62,7 +61,7 @@ private static class UseImplicitNullChecks extends ScheduledNodeIterator { - private final Map<ValueNode, GuardNode> nullGuarded = newIdentityMap(); + private final Map<ValueNode, GuardNode> nullGuarded = Node.newIdentityMap(); private final int implicitNullCheckLimit; UseImplicitNullChecks(int implicitNullCheckLimit) {
--- a/graal/com.oracle.graal.phases.common/src/com/oracle/graal/phases/common/TailDuplicationPhase.java Sat Nov 15 23:19:58 2014 +0100 +++ b/graal/com.oracle.graal.phases.common/src/com/oracle/graal/phases/common/TailDuplicationPhase.java Sun Nov 16 09:44:04 2014 +0100 @@ -219,7 +219,7 @@ private final MergeNode merge; private final StructuredGraph graph; - private final HashMap<ValueNode, PhiNode> bottomPhis = new HashMap<>(); + private final Map<ValueNode, PhiNode> bottomPhis = Node.newMap(); private final List<GuardedValueNode> replacements; private final CanonicalizerPhase canonicalizer; @@ -275,7 +275,7 @@ AbstractEndNode endAfter = createNewMerge(fixed, stateAfter); MergeNode mergeAfter = endAfter.merge(); fixedNodes.add(endAfter); - final HashSet<Node> duplicatedNodes = buildDuplicatedNodeSet(fixedNodes, stateAfter); + final Set<Node> duplicatedNodes = buildDuplicatedNodeSet(fixedNodes, stateAfter); mergeAfter.clearEnds(); expandDuplicated(duplicatedNodes, mergeAfter); @@ -288,7 +288,7 @@ if (replacements == null || replacements.get(endIndex) == null) { duplicates = graph.addDuplicates(duplicatedNodes, graph, duplicatedNodes.size(), (DuplicationReplacement) null); } else { - HashMap<Node, Node> replace = new HashMap<>(); + Map<Node, Node> replace = Node.newMap(); replace.put(replacements.get(endIndex).object(), replacements.get(endIndex)); duplicates = graph.addDuplicates(duplicatedNodes, graph, duplicatedNodes.size(), replace); } @@ -359,7 +359,7 @@ * from within the duplicated set of nodes. * @return The set of nodes that need to be duplicated. */ - private HashSet<Node> buildDuplicatedNodeSet(final ArrayList<FixedNode> fixedNodes, FrameState stateAfter) { + private Set<Node> buildDuplicatedNodeSet(final ArrayList<FixedNode> fixedNodes, FrameState stateAfter) { final NodeBitMap aboveBound = graph.createNodeBitMap(); final NodeBitMap belowBound = graph.createNodeBitMap(); @@ -434,7 +434,7 @@ // build the intersection belowBound.intersect(aboveBound); - HashSet<Node> result = Node.newNodeHashSet(); + Set<Node> result = Node.newSet(); for (Node node : belowBound) { result.add(node); } @@ -480,7 +480,7 @@ * for newly created phis and to as a target for dependencies that pointed into * the duplicated set of nodes. */ - private void expandDuplicated(HashSet<Node> duplicatedNodes, MergeNode newBottomMerge) { + private void expandDuplicated(Set<Node> duplicatedNodes, MergeNode newBottomMerge) { Deque<Node> worklist = new ArrayDeque<>(duplicatedNodes); while (!worklist.isEmpty()) { @@ -490,8 +490,8 @@ } } - private void processUsages(Node duplicated, HashSet<Node> duplicatedNodes, MergeNode newBottomMerge, Deque<Node> worklist) { - HashSet<Node> unique = Node.newNodeHashSet(); + private void processUsages(Node duplicated, Set<Node> duplicatedNodes, MergeNode newBottomMerge, Deque<Node> worklist) { + Set<Node> unique = Node.newSet(); duplicated.usages().snapshotTo(unique); Node newOutsideClone = null; for (Node usage : unique) { @@ -542,7 +542,7 @@ } } - private void processInputs(Node duplicated, HashSet<Node> duplicatedNodes, Deque<Node> worklist) { + private void processInputs(Node duplicated, Set<Node> duplicatedNodes, Deque<Node> worklist) { // check if this node has an input that lies outside and cannot be shared NodePosIterator iter = duplicated.inputs().iterator(); while (iter.hasNext()) {
--- a/graal/com.oracle.graal.phases.common/src/com/oracle/graal/phases/common/ValueAnchorCleanupPhase.java Sat Nov 15 23:19:58 2014 +0100 +++ b/graal/com.oracle.graal.phases.common/src/com/oracle/graal/phases/common/ValueAnchorCleanupPhase.java Sun Nov 16 09:44:04 2014 +0100 @@ -39,14 +39,14 @@ private static class State extends MergeableState<State> implements Cloneable { - private final HashSet<Node> anchoredValues; + private final Set<Node> anchoredValues; public State() { - anchoredValues = Node.newNodeHashSet(); + anchoredValues = Node.newSet(); } public State(State other) { - anchoredValues = Node.newNodeHashSet(other.anchoredValues); + anchoredValues = Node.newSet(other.anchoredValues); } @Override
--- a/graal/com.oracle.graal.phases.common/src/com/oracle/graal/phases/common/cfs/EquationalReasoner.java Sat Nov 15 23:19:58 2014 +0100 +++ b/graal/com.oracle.graal.phases.common/src/com/oracle/graal/phases/common/cfs/EquationalReasoner.java Sun Nov 16 09:44:04 2014 +0100 @@ -22,8 +22,6 @@ */ package com.oracle.graal.phases.common.cfs; -import static com.oracle.graal.graph.util.CollectionsAccess.*; - import java.util.*; import com.oracle.graal.api.meta.*; @@ -81,7 +79,7 @@ * {@link com.oracle.graal.graph.NodeBitMap NodeBitMap} but in this set instead (those nodes are * added after the {@link com.oracle.graal.graph.NodeBitMap} was obtained). */ - final Set<ValueNode> added = newNodeIdentitySet(); + final Set<ValueNode> added = Node.newSet(); /** * The reduction of a FloatingNode performed by {@link EquationalReasoner EquationalReasoner} @@ -91,7 +89,7 @@ * The substitutions tracked in this field become invalid as described in * {@link #updateState(com.oracle.graal.phases.common.cfs.State) updateState(State)} */ - private final Map<ValueNode, ValueNode> substs = newNodeIdentityMap(); + private final Map<ValueNode, ValueNode> substs = Node.newIdentityMap(); public EquationalReasoner(StructuredGraph graph, CanonicalizerTool tool, LogicConstantNode trueConstant, LogicConstantNode falseConstant, ConstantNode nullConstant) { this.graph = graph;
--- a/graal/com.oracle.graal.phases.common/src/com/oracle/graal/phases/common/cfs/State.java Sat Nov 15 23:19:58 2014 +0100 +++ b/graal/com.oracle.graal.phases.common/src/com/oracle/graal/phases/common/cfs/State.java Sun Nov 16 09:44:04 2014 +0100 @@ -22,14 +22,13 @@ */ package com.oracle.graal.phases.common.cfs; -import static com.oracle.graal.graph.util.CollectionsAccess.*; - import java.lang.reflect.*; import java.util.*; import com.oracle.graal.api.meta.*; import com.oracle.graal.compiler.common.type.*; import com.oracle.graal.debug.*; +import com.oracle.graal.graph.*; import com.oracle.graal.nodes.*; import com.oracle.graal.nodes.calc.*; import com.oracle.graal.nodes.extended.*; @@ -116,20 +115,20 @@ Map<LogicNode, GuardingNode> falseFacts; public State() { - this.typeRefinements = newNodeIdentityMap(); - this.trueFacts = newNodeIdentityMap(); - this.falseFacts = newNodeIdentityMap(); + this.typeRefinements = Node.newIdentityMap(); + this.trueFacts = Node.newIdentityMap(); + this.falseFacts = Node.newIdentityMap(); } public State(State other) { this.isUnreachable = other.isUnreachable; this.versionNr = other.versionNr; - this.typeRefinements = newNodeIdentityMap(); + this.typeRefinements = Node.newIdentityMap(); for (Map.Entry<ValueNode, Witness> entry : other.typeRefinements.entrySet()) { this.typeRefinements.put(entry.getKey(), new Witness(entry.getValue())); } - this.trueFacts = newNodeIdentityMap(other.trueFacts); - this.falseFacts = newNodeIdentityMap(other.falseFacts); + this.trueFacts = Node.newIdentityMap(other.trueFacts); + this.falseFacts = Node.newIdentityMap(other.falseFacts); } public boolean repOK() { @@ -155,7 +154,7 @@ } private Map<ValueNode, Witness> mergeKnownTypes(MergeNode merge, ArrayList<State> withReachableStates) { - Map<ValueNode, Witness> newKnownTypes = newNodeIdentityMap(); + Map<ValueNode, Witness> newKnownTypes = Node.newIdentityMap(); for (Map.Entry<ValueNode, Witness> entry : typeRefinements.entrySet()) { ValueNode node = entry.getKey(); @@ -279,7 +278,7 @@ } private Map<LogicNode, GuardingNode> mergeTrueFacts(ArrayList<State> withReachableStates, GuardingNode merge) { - Map<LogicNode, GuardingNode> newTrueConditions = newNodeIdentityMap(); + Map<LogicNode, GuardingNode> newTrueConditions = Node.newIdentityMap(); for (Map.Entry<LogicNode, GuardingNode> entry : trueFacts.entrySet()) { LogicNode check = entry.getKey(); GuardingNode guard = entry.getValue(); @@ -302,7 +301,7 @@ } private Map<LogicNode, GuardingNode> mergeFalseFacts(ArrayList<State> withReachableStates, GuardingNode merge) { - Map<LogicNode, GuardingNode> newFalseConditions = newNodeIdentityMap(); + Map<LogicNode, GuardingNode> newFalseConditions = Node.newIdentityMap(); for (Map.Entry<LogicNode, GuardingNode> entry : falseFacts.entrySet()) { LogicNode check = entry.getKey(); GuardingNode guard = entry.getValue();
--- a/graal/com.oracle.graal.phases.common/src/com/oracle/graal/phases/common/inlining/walker/CallsiteHolderExplorable.java Sat Nov 15 23:19:58 2014 +0100 +++ b/graal/com.oracle.graal.phases.common/src/com/oracle/graal/phases/common/inlining/walker/CallsiteHolderExplorable.java Sun Nov 16 09:44:04 2014 +0100 @@ -23,6 +23,7 @@ package com.oracle.graal.phases.common.inlining.walker; import com.oracle.graal.api.meta.ResolvedJavaMethod; +import com.oracle.graal.graph.*; import com.oracle.graal.nodes.*; import com.oracle.graal.phases.graph.FixedNodeProbabilityCache; @@ -93,7 +94,7 @@ if (freshlyInstantiatedArguments == null || freshlyInstantiatedArguments.isEmpty()) { return Collections.EMPTY_SET; } - Set<ParameterNode> result = new HashSet<>(); + Set<ParameterNode> result = Node.newSet(); for (ParameterNode p : graph.getNodes(ParameterNode.class)) { if (freshlyInstantiatedArguments.get(p.index())) { result.add(p);
--- a/graal/com.oracle.graal.phases.common/src/com/oracle/graal/phases/common/inlining/walker/ComputeInliningRelevance.java Sat Nov 15 23:19:58 2014 +0100 +++ b/graal/com.oracle.graal.phases.common/src/com/oracle/graal/phases/common/inlining/walker/ComputeInliningRelevance.java Sun Nov 16 09:44:04 2014 +0100 @@ -22,8 +22,6 @@ */ package com.oracle.graal.phases.common.inlining.walker; -import static com.oracle.graal.graph.util.CollectionsAccess.*; - import java.util.*; import java.util.function.*; @@ -71,10 +69,10 @@ rootScope = new Scope(graph.start(), null); } else { if (nodeRelevances == null) { - nodeRelevances = newNodeIdentityMap(EXPECTED_MIN_INVOKE_COUNT + graph.getNodeCount() / EXPECTED_INVOKE_RATIO); + nodeRelevances = Node.newIdentityMap(EXPECTED_MIN_INVOKE_COUNT + graph.getNodeCount() / EXPECTED_INVOKE_RATIO); } NodeWorkList workList = graph.createNodeWorkList(); - Map<LoopBeginNode, Scope> loops = newNodeIdentityMap(EXPECTED_LOOP_COUNT); + Map<LoopBeginNode, Scope> loops = Node.newIdentityMap(EXPECTED_LOOP_COUNT); loops.put(null, new Scope(graph.start(), null)); for (LoopBeginNode loopBegin : graph.getNodes(LoopBeginNode.class)) {
--- a/graal/com.oracle.graal.phases.common/src/com/oracle/graal/phases/common/inlining/walker/InliningData.java Sat Nov 15 23:19:58 2014 +0100 +++ b/graal/com.oracle.graal.phases.common/src/com/oracle/graal/phases/common/inlining/walker/InliningData.java Sun Nov 16 09:44:04 2014 +0100 @@ -359,7 +359,7 @@ InlineInfo calleeInfo = calleeInvocation.callee(); try { try (Debug.Scope scope = Debug.scope("doInline", callerGraph)) { - Set<Node> canonicalizedNodes = Node.newNodeHashSet(); + Set<Node> canonicalizedNodes = Node.newSet(); calleeInfo.invoke().asNode().usages().snapshotTo(canonicalizedNodes); Collection<Node> parameterUsages = calleeInfo.inline(new Providers(context), callerAssumptions); canonicalizedNodes.addAll(parameterUsages);
--- a/graal/com.oracle.graal.phases.common/src/com/oracle/graal/phases/common/util/HashSetNodeEventListener.java Sat Nov 15 23:19:58 2014 +0100 +++ b/graal/com.oracle.graal.phases.common/src/com/oracle/graal/phases/common/util/HashSetNodeEventListener.java Sun Nov 16 09:44:04 2014 +0100 @@ -40,7 +40,7 @@ * Creates a {@link NodeEventListener} that collects nodes from all events. */ public HashSetNodeEventListener() { - this.nodes = Node.newNodeHashSet(); + this.nodes = Node.newSet(); this.filter = EnumSet.allOf(NodeEvent.class); }
--- a/graal/com.oracle.graal.phases/src/com/oracle/graal/phases/graph/FixedNodeProbabilityCache.java Sat Nov 15 23:19:58 2014 +0100 +++ b/graal/com.oracle.graal.phases/src/com/oracle/graal/phases/graph/FixedNodeProbabilityCache.java Sun Nov 16 09:44:04 2014 +0100 @@ -22,8 +22,6 @@ */ package com.oracle.graal.phases.graph; -import static com.oracle.graal.graph.util.CollectionsAccess.*; - import java.util.*; import java.util.function.*; @@ -38,7 +36,7 @@ private static final DebugMetric metricComputeNodeProbability = Debug.metric("ComputeNodeProbability"); - private final Map<FixedNode, Double> cache = newIdentityMap(); + private final Map<FixedNode, Double> cache = Node.newIdentityMap(); /** * <p>
--- a/graal/com.oracle.graal.phases/src/com/oracle/graal/phases/graph/PostOrderNodeIterator.java Sat Nov 15 23:19:58 2014 +0100 +++ b/graal/com.oracle.graal.phases/src/com/oracle/graal/phases/graph/PostOrderNodeIterator.java Sun Nov 16 09:44:04 2014 +0100 @@ -25,7 +25,6 @@ import java.util.*; import com.oracle.graal.graph.*; -import com.oracle.graal.graph.util.*; import com.oracle.graal.nodes.*; /** @@ -54,7 +53,7 @@ StructuredGraph graph = start.graph(); visitedEnds = graph.createNodeBitMap(); nodeQueue = new ArrayDeque<>(); - nodeStates = CollectionsAccess.newNodeIdentityMap(); + nodeStates = Node.newIdentityMap(); this.start = start; this.state = initialState; }
--- a/graal/com.oracle.graal.phases/src/com/oracle/graal/phases/graph/ReentrantBlockIterator.java Sat Nov 15 23:19:58 2014 +0100 +++ b/graal/com.oracle.graal.phases/src/com/oracle/graal/phases/graph/ReentrantBlockIterator.java Sun Nov 16 09:44:04 2014 +0100 @@ -22,11 +22,10 @@ */ package com.oracle.graal.phases.graph; -import static com.oracle.graal.graph.util.CollectionsAccess.*; - import java.util.*; import com.oracle.graal.compiler.common.cfg.*; +import com.oracle.graal.graph.*; import com.oracle.graal.nodes.*; import com.oracle.graal.nodes.cfg.*; @@ -89,7 +88,7 @@ /* * States are stored on EndNodes before merges, and on BeginNodes after ControlSplitNodes. */ - Map<FixedNode, StateT> states = newNodeIdentityMap(); + Map<FixedNode, StateT> states = Node.newIdentityMap(); StateT state = initialState; Block current = start;
--- a/graal/com.oracle.graal.phases/src/com/oracle/graal/phases/graph/ReentrantNodeIterator.java Sat Nov 15 23:19:58 2014 +0100 +++ b/graal/com.oracle.graal.phases/src/com/oracle/graal/phases/graph/ReentrantNodeIterator.java Sun Nov 16 09:44:04 2014 +0100 @@ -22,8 +22,6 @@ */ package com.oracle.graal.phases.graph; -import static com.oracle.graal.graph.util.CollectionsAccess.*; - import java.util.*; import com.oracle.graal.graph.*; @@ -37,8 +35,8 @@ public final Map<LoopExitNode, StateT> exitStates; public LoopInfo(int endCount, int exitCount) { - endStates = newNodeIdentityMap(endCount); - exitStates = newNodeIdentityMap(exitCount); + endStates = Node.newIdentityMap(endCount); + exitStates = Node.newIdentityMap(exitCount); } } @@ -90,7 +88,7 @@ private static <StateT> Map<FixedNode, StateT> apply(NodeIteratorClosure<StateT> closure, FixedNode start, StateT initialState, LoopBeginNode boundary) { assert start != null; Deque<BeginNode> nodeQueue = new ArrayDeque<>(); - Map<FixedNode, StateT> blockEndStates = newNodeIdentityMap(); + Map<FixedNode, StateT> blockEndStates = Node.newIdentityMap(); StateT state = initialState; FixedNode current = start;
--- a/graal/com.oracle.graal.phases/src/com/oracle/graal/phases/graph/SinglePassNodeIterator.java Sat Nov 15 23:19:58 2014 +0100 +++ b/graal/com.oracle.graal.phases/src/com/oracle/graal/phases/graph/SinglePassNodeIterator.java Sun Nov 16 09:44:04 2014 +0100 @@ -25,7 +25,6 @@ import java.util.*; import com.oracle.graal.graph.*; -import com.oracle.graal.graph.util.*; import com.oracle.graal.nodes.*; /** @@ -137,7 +136,7 @@ StructuredGraph graph = start.graph(); visitedEnds = graph.createNodeBitMap(); nodeQueue = new ArrayDeque<>(); - nodeStates = CollectionsAccess.newNodeIdentityMap(); + nodeStates = Node.newIdentityMap(); this.start = start; this.state = initialState; }
--- a/graal/com.oracle.graal.phases/src/com/oracle/graal/phases/schedule/SchedulePhase.java Sat Nov 15 23:19:58 2014 +0100 +++ b/graal/com.oracle.graal.phases/src/com/oracle/graal/phases/schedule/SchedulePhase.java Sun Nov 16 09:44:04 2014 +0100 @@ -835,7 +835,7 @@ private boolean noDuplicatedNodesInBlock(Block b) { List<ScheduledNode> list = blockToNodesMap.get(b); - HashSet<ScheduledNode> hashset = new HashSet<>(list); + Set<ScheduledNode> hashset = Node.newSet(list); return list.size() == hashset.size(); }
--- a/graal/com.oracle.graal.phases/src/com/oracle/graal/phases/util/GraphOrder.java Sat Nov 15 23:19:58 2014 +0100 +++ b/graal/com.oracle.graal.phases/src/com/oracle/graal/phases/util/GraphOrder.java Sun Nov 16 09:44:04 2014 +0100 @@ -22,8 +22,6 @@ */ package com.oracle.graal.phases.util; -import static com.oracle.graal.graph.util.CollectionsAccess.*; - import java.util.*; import com.oracle.graal.compiler.common.*; @@ -138,7 +136,7 @@ public static boolean assertSchedulableGraph(final StructuredGraph graph) { try { final SchedulePhase schedule = new SchedulePhase(SchedulingStrategy.LATEST_OUT_OF_LOOPS, MemoryScheduling.NONE); - final Map<LoopBeginNode, NodeBitMap> loopEntryStates = newNodeIdentityMap(); + final Map<LoopBeginNode, NodeBitMap> loopEntryStates = Node.newIdentityMap(); schedule.apply(graph, false); BlockIteratorClosure<NodeBitMap> closure = new BlockIteratorClosure<NodeBitMap>() {
--- a/graal/com.oracle.graal.printer/src/com/oracle/graal/printer/IdealGraphPrinter.java Sat Nov 15 23:19:58 2014 +0100 +++ b/graal/com.oracle.graal.printer/src/com/oracle/graal/printer/IdealGraphPrinter.java Sun Nov 16 09:44:04 2014 +0100 @@ -84,7 +84,7 @@ @Override public void print(Graph graph, String title, SchedulePhase predefinedSchedule) { beginGraph(title); - Set<Node> noBlockNodes = Node.newNodeHashSet(); + Set<Node> noBlockNodes = Node.newSet(); SchedulePhase schedule = predefinedSchedule; if (schedule == null && tryToSchedule) { if (PrintIdealGraphSchedule.getValue()) { @@ -249,7 +249,7 @@ endSuccessors(); beginBlockNodes(); - Set<Node> nodes = Node.newNodeHashSet(); + Set<Node> nodes = Node.newSet(); if (nodeToBlock != null) { for (Node n : graph.getNodes()) { @@ -270,7 +270,7 @@ } } - Set<Node> snapshot = Node.newNodeHashSet(nodes); + Set<Node> snapshot = Node.newSet(nodes); // add all framestates and phis to their blocks for (Node node : snapshot) { if (node instanceof StateSplit && ((StateSplit) node).stateAfter() != null) {
--- a/graal/com.oracle.graal.replacements/src/com/oracle/graal/replacements/SnippetTemplate.java Sat Nov 15 23:19:58 2014 +0100 +++ b/graal/com.oracle.graal.replacements/src/com/oracle/graal/replacements/SnippetTemplate.java Sun Nov 16 09:44:04 2014 +0100 @@ -25,7 +25,6 @@ import static com.oracle.graal.api.meta.LocationIdentity.*; import static com.oracle.graal.compiler.common.GraalOptions.*; import static com.oracle.graal.debug.Debug.*; -import static com.oracle.graal.graph.util.CollectionsAccess.*; import static com.oracle.graal.phases.common.DeadCodeEliminationPhase.Optionality.*; import static com.oracle.graal.replacements.SnippetTemplate.AbstractTemplates.*; import static java.util.FormattableFlags.*; @@ -569,7 +568,7 @@ // Copy snippet graph, replacing constant parameters with given arguments final StructuredGraph snippetCopy = new StructuredGraph(snippetGraph.name, snippetGraph.method()); - Map<Node, Node> nodeReplacements = newNodeIdentityMap(); + Map<Node, Node> nodeReplacements = Node.newIdentityMap(); nodeReplacements.put(snippetGraph.start(), snippetCopy.start()); MetaAccessProvider metaAccess = providers.getMetaAccess(); @@ -863,7 +862,7 @@ * @return the map that will be used to bind arguments to parameters when inlining this template */ private Map<Node, Node> bind(StructuredGraph replaceeGraph, MetaAccessProvider metaAccess, Arguments args) { - Map<Node, Node> replacements = newNodeIdentityMap(); + Map<Node, Node> replacements = Node.newIdentityMap(); assert args.info.getParameterCount() == parameters.length : "number of args (" + args.info.getParameterCount() + ") != number of parameters (" + parameters.length + ")"; for (int i = 0; i < parameters.length; i++) { Object parameter = parameters[i];
--- a/graal/com.oracle.graal.virtual/src/com/oracle/graal/virtual/phases/ea/EffectsClosure.java Sat Nov 15 23:19:58 2014 +0100 +++ b/graal/com.oracle.graal.virtual/src/com/oracle/graal/virtual/phases/ea/EffectsClosure.java Sun Nov 16 09:44:04 2014 +0100 @@ -23,12 +23,11 @@ package com.oracle.graal.virtual.phases.ea; import static com.oracle.graal.compiler.common.GraalOptions.*; -import static com.oracle.graal.graph.util.CollectionsAccess.*; - import java.util.*; import com.oracle.graal.compiler.common.*; import com.oracle.graal.compiler.common.cfg.*; +import com.oracle.graal.compiler.common.remote.*; import com.oracle.graal.debug.*; import com.oracle.graal.graph.*; import com.oracle.graal.nodes.*; @@ -46,8 +45,8 @@ protected final NodeMap<ValueNode> aliases; protected final BlockMap<GraphEffectList> blockEffects; - private final Map<Loop<Block>, GraphEffectList> loopMergeEffects = newIdentityMap(); - private final Map<LoopBeginNode, BlockT> loopEntryStates = newNodeIdentityMap(); + private final Map<Loop<Block>, GraphEffectList> loopMergeEffects = Context.newIdentityMap(); + private final Map<LoopBeginNode, BlockT> loopEntryStates = Node.newIdentityMap(); protected boolean changed;
--- a/graal/com.oracle.graal.virtual/src/com/oracle/graal/virtual/phases/ea/PartialEscapeBlockState.java Sat Nov 15 23:19:58 2014 +0100 +++ b/graal/com.oracle.graal.virtual/src/com/oracle/graal/virtual/phases/ea/PartialEscapeBlockState.java Sun Nov 16 09:44:04 2014 +0100 @@ -22,10 +22,9 @@ */ package com.oracle.graal.virtual.phases.ea; -import static com.oracle.graal.graph.util.CollectionsAccess.*; - import java.util.*; +import com.oracle.graal.graph.*; import com.oracle.graal.nodes.*; import com.oracle.graal.nodes.calc.*; import com.oracle.graal.nodes.java.*; @@ -34,7 +33,7 @@ public abstract class PartialEscapeBlockState<T extends PartialEscapeBlockState<T>> extends EffectsBlockState<T> { - protected final Map<VirtualObjectNode, ObjectState> objectStates = newIdentityMap(); + protected final Map<VirtualObjectNode, ObjectState> objectStates = Node.newIdentityMap(); /** * Final subclass of PartialEscapeBlockState, for performance and to make everything behave
--- a/graal/com.oracle.graal.virtual/src/com/oracle/graal/virtual/phases/ea/PartialEscapeClosure.java Sat Nov 15 23:19:58 2014 +0100 +++ b/graal/com.oracle.graal.virtual/src/com/oracle/graal/virtual/phases/ea/PartialEscapeClosure.java Sun Nov 16 09:44:04 2014 +0100 @@ -22,12 +22,11 @@ */ package com.oracle.graal.virtual.phases.ea; -import static com.oracle.graal.graph.util.CollectionsAccess.*; - import java.util.*; import com.oracle.graal.api.code.*; import com.oracle.graal.api.meta.*; +import com.oracle.graal.compiler.common.remote.*; import com.oracle.graal.compiler.common.type.*; import com.oracle.graal.debug.*; import com.oracle.graal.graph.*; @@ -222,7 +221,7 @@ @Override protected void processLoopExit(LoopExitNode exitNode, BlockT initialState, BlockT exitState, GraphEffectList effects) { - HashMap<VirtualObjectNode, ProxyNode> proxies = new HashMap<>(); + Map<VirtualObjectNode, ProxyNode> proxies = Node.newMap(); for (ProxyNode proxy : exitNode.proxies()) { ObjectState obj = getObjectState(exitState, proxy.value()); @@ -272,9 +271,9 @@ protected class MergeProcessor extends EffectsClosure<BlockT>.MergeProcessor { - private final HashMap<Object, ValuePhiNode> materializedPhis = new HashMap<>(); - private final Map<ValueNode, ValuePhiNode[]> valuePhis = newIdentityMap(); - private final Map<ValuePhiNode, VirtualObjectNode> valueObjectVirtuals = newNodeIdentityMap(); + private final HashMap<Object, ValuePhiNode> materializedPhis = Context.newMap(); + private final Map<ValueNode, ValuePhiNode[]> valuePhis = Node.newIdentityMap(); + private final Map<ValuePhiNode, VirtualObjectNode> valueObjectVirtuals = Node.newIdentityMap(); public MergeProcessor(Block mergeBlock) { super(mergeBlock); @@ -322,7 +321,7 @@ super.merge(states); // calculate the set of virtual objects that exist in all predecessors - HashSet<VirtualObjectNode> virtualObjTemp = new HashSet<>(states.get(0).getVirtualObjects()); + Set<VirtualObjectNode> virtualObjTemp = Node.newSet(states.get(0).getVirtualObjects()); for (int i = 1; i < states.size(); i++) { virtualObjTemp.retainAll(states.get(i).getVirtualObjects()); }
--- a/graal/com.oracle.graal.virtual/src/com/oracle/graal/virtual/phases/ea/VirtualUtil.java Sat Nov 15 23:19:58 2014 +0100 +++ b/graal/com.oracle.graal.virtual/src/com/oracle/graal/virtual/phases/ea/VirtualUtil.java Sun Nov 16 09:44:04 2014 +0100 @@ -23,7 +23,6 @@ package com.oracle.graal.virtual.phases.ea; import static com.oracle.graal.compiler.common.GraalOptions.*; -import static com.oracle.graal.graph.util.CollectionsAccess.*; import java.util.*; @@ -43,7 +42,7 @@ // helper code that determines the paths that keep obsolete nodes alive: NodeFlood flood = graph.createNodeFlood(); - Map<Node, Node> path = newIdentityMap(); + Map<Node, Node> path = Node.newIdentityMap(); flood.add(graph.start()); for (Node current : flood) { if (current instanceof AbstractEndNode) {