# HG changeset patch # User Doug Simon # Date 1399508530 -7200 # Node ID 33cedbce5b23e888f79c6f369e25e582a0ee48c1 # Parent 3882866b6ff9af6414c136e8a4c13e16ad242632 added CollectionsProvider and NodeCollectionsProvider and replaced (almost) all allocations of IdentityHashMaps to go through these providers diff -r 3882866b6ff9 -r 33cedbce5b23 graal/com.oracle.graal.api.collections/src/com/oracle/graal/api/collections/CollectionsProvider.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/graal/com.oracle.graal.api.collections/src/com/oracle/graal/api/collections/CollectionsProvider.java Thu May 08 02:22:10 2014 +0200 @@ -0,0 +1,56 @@ +/* + * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ +package com.oracle.graal.api.collections; + +import java.util.*; + +/** + * A factory for creating collections. + */ +public interface CollectionsProvider { + + /** + * Creates a set that uses reference-equality in place of object-equality when comparing + * entries. + */ + Set newIdentitySet(); + + /** + * Creates a map that uses reference-equality in place of object-equality when comparing keys. + */ + Map newIdentityMap(); + + /** + * Creates a map that uses reference-equality in place of object-equality when comparing keys. + * + * @param expectedMaxSize the expected maximum size of the map + */ + Map newIdentityMap(int expectedMaxSize); + + /** + * Creates a map that uses reference-equality in place of object-equality when comparing keys. + * + * @param initFrom the returned map is populated with the entries in this map + */ + Map newIdentityMap(Map initFrom); +} diff -r 3882866b6ff9 -r 33cedbce5b23 graal/com.oracle.graal.api.collections/src/com/oracle/graal/api/collections/DefaultCollectionsProvider.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/graal/com.oracle.graal.api.collections/src/com/oracle/graal/api/collections/DefaultCollectionsProvider.java Thu May 08 02:22:10 2014 +0200 @@ -0,0 +1,48 @@ +/* + * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ +package com.oracle.graal.api.collections; + +import java.util.*; + +/** + * A default implementation of {@link CollectionsProvider} that creates standard JDK collection + * class objects. + */ +public class DefaultCollectionsProvider implements CollectionsProvider { + + public Set newIdentitySet() { + return Collections.newSetFromMap(newIdentityMap()); + } + + public Map newIdentityMap() { + return new IdentityHashMap<>(); + } + + public Map newIdentityMap(int expectedMaxSize) { + return new IdentityHashMap<>(expectedMaxSize); + } + + public Map newIdentityMap(Map initFrom) { + return new IdentityHashMap<>(initFrom); + } +} diff -r 3882866b6ff9 -r 33cedbce5b23 graal/com.oracle.graal.api.runtime/src/com/oracle/graal/api/runtime/Graal.java --- a/graal/com.oracle.graal.api.runtime/src/com/oracle/graal/api/runtime/Graal.java Wed May 07 23:58:56 2014 +0200 +++ b/graal/com.oracle.graal.api.runtime/src/com/oracle/graal/api/runtime/Graal.java Thu May 08 02:22:10 2014 +0200 @@ -28,7 +28,7 @@ public class Graal { - private static GraalRuntime runtime; + private static final GraalRuntime runtime; private static native GraalRuntime initializeRuntime(); @@ -47,12 +47,13 @@ } static { + GraalRuntime rt; try { - runtime = initializeRuntime(); + rt = initializeRuntime(); } catch (UnsatisfiedLinkError e) { - runtime = new InvalidGraalRuntime(); + rt = new InvalidGraalRuntime(); } - + runtime = rt; Reflection.registerFieldsToFilter(Graal.class, "runtime"); } diff -r 3882866b6ff9 -r 33cedbce5b23 graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/gen/DebugInfoBuilder.java --- a/graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/gen/DebugInfoBuilder.java Wed May 07 23:58:56 2014 +0200 +++ b/graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/gen/DebugInfoBuilder.java Thu May 08 02:22:10 2014 +0200 @@ -22,6 +22,8 @@ */ package com.oracle.graal.compiler.gen; +import static com.oracle.graal.graph.util.CollectionsAccess.*; + import java.util.*; import java.util.Map.Entry; @@ -46,8 +48,8 @@ this.nodeOperands = nodeOperands; } - protected final HashMap virtualObjects = new HashMap<>(); - protected final IdentityHashMap objectStates = new IdentityHashMap<>(); + protected final Map virtualObjects = new HashMap<>(); + protected final Map objectStates = newNodeIdentityMap(); public LIRFrameState build(FrameState topState, LabelRef exceptionEdge) { assert virtualObjects.size() == 0; @@ -76,7 +78,7 @@ boolean changed; do { changed = false; - IdentityHashMap virtualObjectsCopy = new IdentityHashMap<>(virtualObjects); + Map virtualObjectsCopy = newIdentityMap(virtualObjects); for (Entry entry : virtualObjectsCopy.entrySet()) { if (entry.getValue().getValues() == null) { VirtualObjectNode vobj = entry.getKey(); diff -r 3882866b6ff9 -r 33cedbce5b23 graal/com.oracle.graal.graph/src/com/oracle/graal/graph/DefaultNodeCollectionsProvider.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/graal/com.oracle.graal.graph/src/com/oracle/graal/graph/DefaultNodeCollectionsProvider.java Thu May 08 02:22:10 2014 +0200 @@ -0,0 +1,50 @@ +/* + * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ +package com.oracle.graal.graph; + +import java.util.*; + +import com.oracle.graal.api.collections.*; + +/** + * A default implementation of {@link NodeCollectionsProvider} that creates standard JDK collection + * class objects. + */ +public class DefaultNodeCollectionsProvider extends DefaultCollectionsProvider implements NodeCollectionsProvider { + + public Set newNodeIdentitySet() { + return Collections.newSetFromMap(newNodeIdentityMap()); + } + + public Map newNodeIdentityMap() { + return new IdentityHashMap<>(); + } + + public Map newNodeIdentityMap(int expectedMaxSize) { + return new IdentityHashMap<>(expectedMaxSize); + } + + public Map newNodeIdentityMap(Map initFrom) { + return new IdentityHashMap<>(initFrom); + } +} diff -r 3882866b6ff9 -r 33cedbce5b23 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 Wed May 07 23:58:56 2014 +0200 +++ b/graal/com.oracle.graal.graph/src/com/oracle/graal/graph/NodeClass.java Thu May 08 02:22:10 2014 +0200 @@ -23,6 +23,7 @@ package com.oracle.graal.graph; import static com.oracle.graal.graph.Graph.*; +import static com.oracle.graal.graph.util.CollectionsAccess.*; import java.lang.reflect.*; import java.util.*; @@ -1371,12 +1372,13 @@ static Map addGraphDuplicate(final Graph graph, final Graph oldGraph, int estimatedNodeCount, Iterable nodes, final DuplicationReplacement replacements) { final Map newNodes; - if (estimatedNodeCount > (oldGraph.getNodeCount() + oldGraph.getNodesDeletedSinceLastCompression() >> 4)) { + int denseThreshold = oldGraph.getNodeCount() + oldGraph.getNodesDeletedSinceLastCompression() >> 4; + if (estimatedNodeCount > denseThreshold) { // Use dense map newNodes = new NodeNodeMap(oldGraph); } else { // Use sparse map - newNodes = new IdentityHashMap<>(); + newNodes = newIdentityMap(); } createNodeDuplicates(graph, nodes, replacements, newNodes); diff -r 3882866b6ff9 -r 33cedbce5b23 graal/com.oracle.graal.graph/src/com/oracle/graal/graph/NodeCollectionsProvider.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/graal/com.oracle.graal.graph/src/com/oracle/graal/graph/NodeCollectionsProvider.java Thu May 08 02:22:10 2014 +0200 @@ -0,0 +1,59 @@ +/* + * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ +package com.oracle.graal.graph; + +import java.util.*; + +import com.oracle.graal.api.collections.*; + +/** + * Extends {@link CollectionsProvider} with support for creating {@link Node} based collections. + */ +public interface NodeCollectionsProvider extends CollectionsProvider { + + /** + * Creates a set of {@link Node}s that uses reference-equality in place of object-equality when + * comparing entries. + */ + Set newNodeIdentitySet(); + + /** + * Creates a map whose keys are {@link Node}s that uses reference-equality in place of + * object-equality when comparing keys. All {@link Node} keys must be in the same graph. + */ + Map newNodeIdentityMap(); + + /** + * Creates a map whose keys are {@link Node}s that uses reference-equality in place of + * object-equality when comparing keys. All {@link Node} keys must be in the same graph. + */ + Map newNodeIdentityMap(int expectedMaxSize); + + /** + * Creates a map whose keys are {@link Node}s that uses reference-equality in place of + * object-equality when comparing keys. All {@link Node} keys must be in the same graph. + * + * @param initFrom the returned map is populated with the entries in this map + */ + Map newNodeIdentityMap(Map initFrom); +} diff -r 3882866b6ff9 -r 33cedbce5b23 graal/com.oracle.graal.graph/src/com/oracle/graal/graph/util/CollectionsAccess.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/graal/com.oracle.graal.graph/src/com/oracle/graal/graph/util/CollectionsAccess.java Thu May 08 02:22:10 2014 +0200 @@ -0,0 +1,94 @@ +/* + * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ +package com.oracle.graal.graph.util; + +import java.util.*; + +import com.oracle.graal.api.collections.*; +import com.oracle.graal.api.runtime.*; +import com.oracle.graal.graph.*; + +/** + * Static methods for accessing the methods in the installed {@link GraalRuntime}'s + * {@link CollectionsProvider} and {@link NodeCollectionsProvider}. + */ +public class CollectionsAccess { + + private static final NodeCollectionsProvider provider = Graal.getRequiredCapability(NodeCollectionsProvider.class); + + /** + * @see CollectionsProvider#newIdentityMap() + */ + public static Map newIdentityMap() { + return provider.newIdentityMap(); + } + + /** + * @see CollectionsProvider#newIdentityMap() + */ + public static Map newIdentityMap(int expectedMaxSize) { + return provider.newIdentityMap(expectedMaxSize); + } + + /** + * @see CollectionsProvider#newIdentityMap(Map) + */ + public static Map newIdentityMap(Map initFrom) { + return provider.newIdentityMap(initFrom); + } + + /** + * @see NodeCollectionsProvider#newNodeIdentitySet() + */ + public static Set newNodeIdentitySet() { + return provider.newNodeIdentitySet(); + } + + /** + * @see NodeCollectionsProvider#newNodeIdentityMap() + */ + public static Map newNodeIdentityMap() { + return provider.newNodeIdentityMap(); + } + + /** + * @see NodeCollectionsProvider#newNodeIdentityMap(int) + */ + public static Map newNodeIdentityMap(int expectedMaxSize) { + return provider.newNodeIdentityMap(expectedMaxSize); + } + + /** + * @see NodeCollectionsProvider#newNodeIdentityMap(Map) + */ + public static Map newNodeIdentityMap(Map initFrom) { + return provider.newNodeIdentityMap(initFrom); + } + + /** + * Creates an identity set. + */ + public static Set newIdentitySet() { + return provider.newIdentitySet(); + } +} diff -r 3882866b6ff9 -r 33cedbce5b23 graal/com.oracle.graal.hotspot.server/src/com/oracle/graal/hotspot/server/ReplacingStreams.java --- a/graal/com.oracle.graal.hotspot.server/src/com/oracle/graal/hotspot/server/ReplacingStreams.java Wed May 07 23:58:56 2014 +0200 +++ b/graal/com.oracle.graal.hotspot.server/src/com/oracle/graal/hotspot/server/ReplacingStreams.java Thu May 08 02:22:10 2014 +0200 @@ -22,6 +22,8 @@ */ package com.oracle.graal.hotspot.server; +import static com.oracle.graal.graph.util.CollectionsAccess.*; + import java.io.*; import java.lang.reflect.*; import java.util.*; @@ -32,7 +34,7 @@ public class ReplacingStreams { - private IdentityHashMap objectMap = new IdentityHashMap<>(); + private Map objectMap = newIdentityMap(); private ArrayList objectList = new ArrayList<>(); private ReplacingOutputStream output; diff -r 3882866b6ff9 -r 33cedbce5b23 graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/HotSpotGraalRuntime.java --- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/HotSpotGraalRuntime.java Wed May 07 23:58:56 2014 +0200 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/HotSpotGraalRuntime.java Thu May 08 02:22:10 2014 +0200 @@ -34,11 +34,13 @@ import com.oracle.graal.api.code.*; import com.oracle.graal.api.code.stack.*; +import com.oracle.graal.api.collections.*; import com.oracle.graal.api.meta.*; import com.oracle.graal.api.replacements.*; import com.oracle.graal.api.runtime.*; import com.oracle.graal.compiler.common.*; import com.oracle.graal.compiler.target.*; +import com.oracle.graal.graph.*; import com.oracle.graal.hotspot.bridge.*; import com.oracle.graal.hotspot.logging.*; import com.oracle.graal.hotspot.meta.*; @@ -359,11 +361,15 @@ return getClass().getSimpleName(); } + private final NodeCollectionsProvider nodeCollectionsProvider = new DefaultNodeCollectionsProvider(); + @SuppressWarnings("unchecked") @Override public T getCapability(Class clazz) { if (clazz == RuntimeProvider.class) { return (T) this; + } else if (clazz == CollectionsProvider.class || clazz == NodeCollectionsProvider.class) { + return (T) nodeCollectionsProvider; } else if (clazz == StackIntrospection.class) { return (T) this; } else if (clazz == SnippetReflectionProvider.class) { diff -r 3882866b6ff9 -r 33cedbce5b23 graal/com.oracle.graal.loop/src/com/oracle/graal/loop/InductionVariables.java --- a/graal/com.oracle.graal.loop/src/com/oracle/graal/loop/InductionVariables.java Wed May 07 23:58:56 2014 +0200 +++ b/graal/com.oracle.graal.loop/src/com/oracle/graal/loop/InductionVariables.java Thu May 08 02:22:10 2014 +0200 @@ -22,6 +22,8 @@ */ package com.oracle.graal.loop; +import static com.oracle.graal.graph.util.CollectionsAccess.*; + import java.util.*; import com.oracle.graal.graph.*; @@ -35,7 +37,7 @@ public InductionVariables(LoopEx loop) { this.loop = loop; - ivs = new IdentityHashMap<>(); + ivs = newNodeIdentityMap(); findDerived(findBasic()); } diff -r 3882866b6ff9 -r 33cedbce5b23 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 Wed May 07 23:58:56 2014 +0200 +++ b/graal/com.oracle.graal.loop/src/com/oracle/graal/loop/LoopFragmentInside.java Thu May 08 02:22:10 2014 +0200 @@ -22,11 +22,13 @@ */ 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.DuplicationReplacement; import com.oracle.graal.graph.iterators.*; import com.oracle.graal.nodes.*; import com.oracle.graal.nodes.VirtualState.NodeClosure; @@ -287,7 +289,7 @@ reverseEnds.put(duplicate, le); } } - mergedInitializers = new IdentityHashMap<>(); + mergedInitializers = newNodeIdentityMap(); BeginNode newExit; StructuredGraph graph = graph(); if (endsToMerge.size() == 1) { diff -r 3882866b6ff9 -r 33cedbce5b23 graal/com.oracle.graal.loop/src/com/oracle/graal/loop/LoopsData.java --- a/graal/com.oracle.graal.loop/src/com/oracle/graal/loop/LoopsData.java Wed May 07 23:58:56 2014 +0200 +++ b/graal/com.oracle.graal.loop/src/com/oracle/graal/loop/LoopsData.java Thu May 08 02:22:10 2014 +0200 @@ -22,6 +22,8 @@ */ package com.oracle.graal.loop; +import static com.oracle.graal.graph.util.CollectionsAccess.*; + import java.util.*; import com.oracle.graal.compiler.common.cfg.*; @@ -32,8 +34,8 @@ public class LoopsData { - private Map, LoopEx> lirLoopToEx = new IdentityHashMap<>(); - private Map loopBeginToEx = new IdentityHashMap<>(); + private Map, LoopEx> lirLoopToEx = newIdentityMap(); + private Map loopBeginToEx = newNodeIdentityMap(); private ControlFlowGraph cfg; public LoopsData(final StructuredGraph graph) { diff -r 3882866b6ff9 -r 33cedbce5b23 graal/com.oracle.graal.phases.common/src/com/oracle/graal/phases/common/ConditionalEliminationPhase.java --- a/graal/com.oracle.graal.phases.common/src/com/oracle/graal/phases/common/ConditionalEliminationPhase.java Wed May 07 23:58:56 2014 +0200 +++ b/graal/com.oracle.graal.phases.common/src/com/oracle/graal/phases/common/ConditionalEliminationPhase.java Thu May 08 02:22:10 2014 +0200 @@ -22,6 +22,8 @@ */ package com.oracle.graal.phases.common; +import static com.oracle.graal.graph.util.CollectionsAccess.*; + import java.util.*; import com.oracle.graal.api.meta.*; @@ -101,37 +103,37 @@ public static class State extends MergeableState implements Cloneable { - private IdentityHashMap knownTypes; + private Map knownTypes; private HashSet knownNonNull; private HashSet knownNull; - private IdentityHashMap trueConditions; - private IdentityHashMap falseConditions; - private IdentityHashMap valueConstraints; + private Map trueConditions; + private Map falseConditions; + private Map valueConstraints; public State() { - this.knownTypes = new IdentityHashMap<>(); + this.knownTypes = newNodeIdentityMap(); this.knownNonNull = new HashSet<>(); this.knownNull = new HashSet<>(); - this.trueConditions = new IdentityHashMap<>(); - this.falseConditions = new IdentityHashMap<>(); - this.valueConstraints = new IdentityHashMap<>(); + this.trueConditions = newNodeIdentityMap(); + this.falseConditions = newNodeIdentityMap(); + this.valueConstraints = newNodeIdentityMap(); } public State(State other) { - this.knownTypes = new IdentityHashMap<>(other.knownTypes); + this.knownTypes = newNodeIdentityMap(other.knownTypes); this.knownNonNull = new HashSet<>(other.knownNonNull); this.knownNull = new HashSet<>(other.knownNull); - this.trueConditions = new IdentityHashMap<>(other.trueConditions); - this.falseConditions = new IdentityHashMap<>(other.falseConditions); - this.valueConstraints = new IdentityHashMap<>(other.valueConstraints); + this.trueConditions = newNodeIdentityMap(other.trueConditions); + this.falseConditions = newNodeIdentityMap(other.falseConditions); + this.valueConstraints = newNodeIdentityMap(other.valueConstraints); } @Override public boolean merge(MergeNode merge, List withStates) { - IdentityHashMap newKnownTypes = new IdentityHashMap<>(); - IdentityHashMap newTrueConditions = new IdentityHashMap<>(); - IdentityHashMap newFalseConditions = new IdentityHashMap<>(); - IdentityHashMap newValueConstraints = new IdentityHashMap<>(); + Map newKnownTypes = newNodeIdentityMap(); + Map newTrueConditions = newNodeIdentityMap(); + Map newFalseConditions = newNodeIdentityMap(); + Map newValueConstraints = newNodeIdentityMap(); HashSet newKnownNull = new HashSet<>(knownNull); HashSet newKnownNonNull = new HashSet<>(knownNonNull); diff -r 3882866b6ff9 -r 33cedbce5b23 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 Wed May 07 23:58:56 2014 +0200 +++ b/graal/com.oracle.graal.phases.common/src/com/oracle/graal/phases/common/FloatingReadPhase.java Thu May 08 02:22:10 2014 +0200 @@ -23,6 +23,7 @@ package com.oracle.graal.phases.common; import static com.oracle.graal.api.meta.LocationIdentity.*; +import static com.oracle.graal.graph.util.CollectionsAccess.*; import java.util.*; @@ -43,19 +44,19 @@ public static class MemoryMapImpl extends MemoryMapNode { - private IdentityHashMap lastMemorySnapshot; + private final Map lastMemorySnapshot; public MemoryMapImpl(MemoryMapImpl memoryMap) { - lastMemorySnapshot = new IdentityHashMap<>(memoryMap.lastMemorySnapshot); + lastMemorySnapshot = newIdentityMap(memoryMap.lastMemorySnapshot); } public MemoryMapImpl(StartNode start) { - this(); + lastMemorySnapshot = newIdentityMap(); lastMemorySnapshot.put(ANY_LOCATION, start); } public MemoryMapImpl() { - lastMemorySnapshot = new IdentityHashMap<>(); + lastMemorySnapshot = newIdentityMap(); } @Override @@ -112,7 +113,7 @@ @Override protected void run(StructuredGraph graph) { - Map> modifiedInLoops = new IdentityHashMap<>(); + Map> modifiedInLoops = newNodeIdentityMap(); ReentrantNodeIterator.apply(new CollectMemoryCheckpointsClosure(modifiedInLoops), graph.start(), new HashSet()); ReentrantNodeIterator.apply(new FloatingReadClosure(modifiedInLoops, execmode), graph.start(), new MemoryMapImpl(graph.start())); if (execmode == ExecutionMode.CREATE_FLOATING_READS) { diff -r 3882866b6ff9 -r 33cedbce5b23 graal/com.oracle.graal.phases.common/src/com/oracle/graal/phases/common/GuardLoweringPhase.java --- a/graal/com.oracle.graal.phases.common/src/com/oracle/graal/phases/common/GuardLoweringPhase.java Wed May 07 23:58:56 2014 +0200 +++ b/graal/com.oracle.graal.phases.common/src/com/oracle/graal/phases/common/GuardLoweringPhase.java Thu May 08 02:22:10 2014 +0200 @@ -23,6 +23,7 @@ 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; @@ -61,7 +62,7 @@ private static class UseImplicitNullChecks extends ScheduledNodeIterator { - private final IdentityHashMap nullGuarded = new IdentityHashMap<>(); + private final Map nullGuarded = newIdentityMap(); private final int implicitNullCheckLimit; UseImplicitNullChecks(int implicitNullCheckLimit) { diff -r 3882866b6ff9 -r 33cedbce5b23 graal/com.oracle.graal.phases.common/src/com/oracle/graal/phases/common/cfs/EquationalReasoner.java --- a/graal/com.oracle.graal.phases.common/src/com/oracle/graal/phases/common/cfs/EquationalReasoner.java Wed May 07 23:58:56 2014 +0200 +++ b/graal/com.oracle.graal.phases.common/src/com/oracle/graal/phases/common/cfs/EquationalReasoner.java Thu May 08 02:22:10 2014 +0200 @@ -22,29 +22,22 @@ */ package com.oracle.graal.phases.common.cfs; -import com.oracle.graal.api.meta.ResolvedJavaType; -import com.oracle.graal.debug.Debug; -import com.oracle.graal.debug.DebugMetric; -import com.oracle.graal.graph.Node; -import com.oracle.graal.graph.NodeBitMap; -import com.oracle.graal.graph.spi.CanonicalizerTool; +import static com.oracle.graal.graph.util.CollectionsAccess.*; + +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.graph.spi.*; import com.oracle.graal.nodes.*; -import com.oracle.graal.nodes.calc.FloatingNode; -import com.oracle.graal.nodes.calc.IsNullNode; -import com.oracle.graal.nodes.calc.ObjectEqualsNode; -import com.oracle.graal.nodes.extended.GuardedNode; -import com.oracle.graal.nodes.extended.GuardingNode; -import com.oracle.graal.nodes.java.CheckCastNode; -import com.oracle.graal.nodes.java.InstanceOfNode; -import com.oracle.graal.nodes.spi.ValueProxy; -import com.oracle.graal.compiler.common.type.IllegalStamp; -import com.oracle.graal.compiler.common.type.ObjectStamp; -import com.oracle.graal.compiler.common.type.StampFactory; -import com.oracle.graal.nodes.type.StampTool; -import com.oracle.graal.nodes.util.GraphUtil; - -import java.util.IdentityHashMap; -import java.util.Set; +import com.oracle.graal.nodes.calc.*; +import com.oracle.graal.nodes.extended.*; +import com.oracle.graal.nodes.java.*; +import com.oracle.graal.nodes.spi.*; +import com.oracle.graal.nodes.type.*; +import com.oracle.graal.nodes.util.*; /** *

@@ -88,7 +81,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 added = java.util.Collections.newSetFromMap(new IdentityHashMap()); + final Set added = newNodeIdentitySet(); /** * The reduction of a FloatingNode performed by {@link EquationalReasoner EquationalReasoner} @@ -98,7 +91,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 IdentityHashMap substs = new IdentityHashMap<>(); + private final Map substs = newNodeIdentityMap(); public EquationalReasoner(StructuredGraph graph, CanonicalizerTool tool, LogicConstantNode trueConstant, LogicConstantNode falseConstant, ConstantNode nullConstant) { this.graph = graph; diff -r 3882866b6ff9 -r 33cedbce5b23 graal/com.oracle.graal.phases.common/src/com/oracle/graal/phases/common/cfs/State.java --- a/graal/com.oracle.graal.phases.common/src/com/oracle/graal/phases/common/cfs/State.java Wed May 07 23:58:56 2014 +0200 +++ b/graal/com.oracle.graal.phases.common/src/com/oracle/graal/phases/common/cfs/State.java Thu May 08 02:22:10 2014 +0200 @@ -22,24 +22,22 @@ */ package com.oracle.graal.phases.common.cfs; -import com.oracle.graal.api.meta.Kind; -import com.oracle.graal.api.meta.ResolvedJavaType; -import com.oracle.graal.debug.Debug; -import com.oracle.graal.debug.DebugMetric; +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.nodes.*; -import com.oracle.graal.nodes.calc.IsNullNode; -import com.oracle.graal.nodes.calc.ObjectEqualsNode; -import com.oracle.graal.nodes.extended.GuardedNode; -import com.oracle.graal.nodes.extended.GuardingNode; -import com.oracle.graal.nodes.java.InstanceOfNode; -import com.oracle.graal.nodes.spi.ValueProxy; -import com.oracle.graal.compiler.common.type.ObjectStamp; -import com.oracle.graal.nodes.type.StampTool; -import com.oracle.graal.nodes.util.GraphUtil; -import com.oracle.graal.phases.graph.MergeableState; - -import java.lang.reflect.Modifier; -import java.util.*; +import com.oracle.graal.nodes.calc.*; +import com.oracle.graal.nodes.extended.*; +import com.oracle.graal.nodes.java.*; +import com.oracle.graal.nodes.spi.*; +import com.oracle.graal.nodes.type.*; +import com.oracle.graal.nodes.util.*; +import com.oracle.graal.phases.graph.*; /** * A State instance is mutated in place as each FixedNode is visited in a basic block of @@ -116,29 +114,29 @@ *

* */ - private IdentityHashMap typeRefinements; + private Map typeRefinements; - IdentityHashMap knownNull; - IdentityHashMap trueFacts; - IdentityHashMap falseFacts; + Map knownNull; + Map trueFacts; + Map falseFacts; public State() { - this.typeRefinements = new IdentityHashMap<>(); - this.knownNull = new IdentityHashMap<>(); - this.trueFacts = new IdentityHashMap<>(); - this.falseFacts = new IdentityHashMap<>(); + this.typeRefinements = newNodeIdentityMap(); + this.knownNull = newNodeIdentityMap(); + this.trueFacts = newNodeIdentityMap(); + this.falseFacts = newNodeIdentityMap(); } public State(State other) { this.isUnreachable = other.isUnreachable; this.versionNr = other.versionNr; - this.typeRefinements = new IdentityHashMap<>(); + this.typeRefinements = newNodeIdentityMap(); for (Map.Entry entry : other.typeRefinements.entrySet()) { this.typeRefinements.put(entry.getKey(), new Witness(entry.getValue())); } - this.knownNull = new IdentityHashMap<>(other.knownNull); - this.trueFacts = new IdentityHashMap<>(other.trueFacts); - this.falseFacts = new IdentityHashMap<>(other.falseFacts); + this.knownNull = newNodeIdentityMap(other.knownNull); + this.trueFacts = newNodeIdentityMap(other.trueFacts); + this.falseFacts = newNodeIdentityMap(other.falseFacts); } public boolean repOK() { @@ -167,8 +165,8 @@ return result; } - private IdentityHashMap mergeKnownTypes(MergeNode merge, ArrayList withReachableStates) { - IdentityHashMap newKnownTypes = new IdentityHashMap<>(); + private Map mergeKnownTypes(MergeNode merge, ArrayList withReachableStates) { + Map newKnownTypes = newNodeIdentityMap(); for (Map.Entry entry : typeRefinements.entrySet()) { ValueNode node = entry.getKey(); @@ -191,9 +189,9 @@ return newKnownTypes; } - private IdentityHashMap mergeKnownNull(MergeNode merge, ArrayList withReachableStates) { + private Map mergeKnownNull(MergeNode merge, ArrayList withReachableStates) { // newKnownNull starts empty - IdentityHashMap newKnownNull = new IdentityHashMap<>(); + Map newKnownNull = newNodeIdentityMap(); for (Map.Entry entry : knownNull.entrySet()) { ValueNode key = entry.getKey(); GuardingNode newGN = entry.getValue(); @@ -233,7 +231,7 @@ * when merging type-witnesses and known-null maps. *

*/ - private void mergePhis(MergeNode merge, List withStates, IdentityHashMap newKnownPhiTypes, IdentityHashMap newKnownNullPhis) { + private void mergePhis(MergeNode merge, List withStates, Map newKnownPhiTypes, Map newKnownNullPhis) { if (merge instanceof LoopBeginNode) { return; @@ -303,9 +301,9 @@ } // may also get updated in a moment, during processing of phi nodes. - IdentityHashMap newKnownTypes = mergeKnownTypes(merge, withReachableStates); + Map newKnownTypes = mergeKnownTypes(merge, withReachableStates); // may also get updated in a moment, during processing of phi nodes. - IdentityHashMap newKnownNull = mergeKnownNull(merge, withReachableStates); + Map newKnownNull = mergeKnownNull(merge, withReachableStates); mergePhis(merge, withStates, newKnownTypes, newKnownNull); this.typeRefinements = newKnownTypes; this.knownNull = newKnownNull; @@ -318,8 +316,8 @@ return true; } - private IdentityHashMap mergeTrueFacts(ArrayList withReachableStates, GuardingNode merge) { - IdentityHashMap newTrueConditions = new IdentityHashMap<>(); + private Map mergeTrueFacts(ArrayList withReachableStates, GuardingNode merge) { + Map newTrueConditions = newNodeIdentityMap(); for (Map.Entry entry : trueFacts.entrySet()) { LogicNode check = entry.getKey(); GuardingNode guard = entry.getValue(); @@ -341,8 +339,8 @@ return newTrueConditions; } - private IdentityHashMap mergeFalseFacts(ArrayList withReachableStates, GuardingNode merge) { - IdentityHashMap newFalseConditions = new IdentityHashMap<>(); + private Map mergeFalseFacts(ArrayList withReachableStates, GuardingNode merge) { + Map newFalseConditions = newNodeIdentityMap(); for (Map.Entry entry : falseFacts.entrySet()) { LogicNode check = entry.getKey(); GuardingNode guard = entry.getValue(); @@ -653,7 +651,7 @@ *

* */ - private void addFactPrimordial(LogicNode condition, IdentityHashMap to, GuardingNode anchor) { + private void addFactPrimordial(LogicNode condition, Map to, GuardingNode anchor) { assert condition != null; if (!to.containsKey(condition)) { versionNr++; diff -r 3882866b6ff9 -r 33cedbce5b23 graal/com.oracle.graal.phases.common/src/com/oracle/graal/phases/common/inlining/ComputeInliningRelevance.java --- a/graal/com.oracle.graal.phases.common/src/com/oracle/graal/phases/common/inlining/ComputeInliningRelevance.java Wed May 07 23:58:56 2014 +0200 +++ b/graal/com.oracle.graal.phases.common/src/com/oracle/graal/phases/common/inlining/ComputeInliningRelevance.java Thu May 08 02:22:10 2014 +0200 @@ -22,6 +22,8 @@ */ package com.oracle.graal.phases.common.inlining; +import static com.oracle.graal.graph.util.CollectionsAccess.*; + import java.util.*; import java.util.function.*; @@ -46,7 +48,7 @@ * Node relevances are pre-computed for all invokes if the graph contains loops. If there are no * loops, the computation happens lazily based on {@link #rootScope}. */ - private IdentityHashMap nodeRelevances; + private Map nodeRelevances; /** * This scope is non-null if (and only if) there are no loops in the graph. In this case, the * root scope is used to compute invoke relevances on the fly. @@ -69,10 +71,10 @@ rootScope = new Scope(graph.start(), null); } else { if (nodeRelevances == null) { - nodeRelevances = new IdentityHashMap<>(EXPECTED_MIN_INVOKE_COUNT + graph.getNodeCount() / EXPECTED_INVOKE_RATIO); + nodeRelevances = newNodeIdentityMap(EXPECTED_MIN_INVOKE_COUNT + graph.getNodeCount() / EXPECTED_INVOKE_RATIO); } NodeWorkList workList = graph.createNodeWorkList(); - IdentityHashMap loops = new IdentityHashMap<>(EXPECTED_LOOP_COUNT); + Map loops = newNodeIdentityMap(EXPECTED_LOOP_COUNT); loops.put(null, new Scope(graph.start(), null)); for (LoopBeginNode loopBegin : graph.getNodes(LoopBeginNode.class)) { @@ -97,7 +99,7 @@ * Determines the parent of the given loop and creates a {@link Scope} object for each one. This * method will call itself recursively if no {@link Scope} for the parent loop exists. */ - private Scope createLoopScope(LoopBeginNode loopBegin, IdentityHashMap loops) { + private Scope createLoopScope(LoopBeginNode loopBegin, Map loops) { Scope scope = loops.get(loopBegin); if (scope == null) { final Scope parent; diff -r 3882866b6ff9 -r 33cedbce5b23 graal/com.oracle.graal.phases/src/com/oracle/graal/phases/graph/FixedNodeProbabilityCache.java --- a/graal/com.oracle.graal.phases/src/com/oracle/graal/phases/graph/FixedNodeProbabilityCache.java Wed May 07 23:58:56 2014 +0200 +++ b/graal/com.oracle.graal.phases/src/com/oracle/graal/phases/graph/FixedNodeProbabilityCache.java Thu May 08 02:22:10 2014 +0200 @@ -22,6 +22,8 @@ */ package com.oracle.graal.phases.graph; +import static com.oracle.graal.graph.util.CollectionsAccess.*; + import java.util.*; import java.util.function.*; @@ -37,7 +39,7 @@ private static final DebugMetric metricComputeNodeProbability = Debug.metric("ComputeNodeProbability"); - private final IdentityHashMap cache = new IdentityHashMap<>(); + private final Map cache = newIdentityMap(); public double applyAsDouble(FixedNode node) { metricComputeNodeProbability.increment(); diff -r 3882866b6ff9 -r 33cedbce5b23 graal/com.oracle.graal.phases/src/com/oracle/graal/phases/graph/PostOrderNodeIterator.java --- a/graal/com.oracle.graal.phases/src/com/oracle/graal/phases/graph/PostOrderNodeIterator.java Wed May 07 23:58:56 2014 +0200 +++ b/graal/com.oracle.graal.phases/src/com/oracle/graal/phases/graph/PostOrderNodeIterator.java Thu May 08 02:22:10 2014 +0200 @@ -25,6 +25,7 @@ import java.util.*; import com.oracle.graal.graph.*; +import com.oracle.graal.graph.util.*; import com.oracle.graal.nodes.*; /** @@ -37,22 +38,23 @@ *

* While iterating it maintains a user-defined state by calling the methods available in * {@link MergeableState}. - * + * * @param the type of {@link MergeableState} handled by this PostOrderNodeIterator */ public abstract class PostOrderNodeIterator> { private final NodeBitMap visitedEnds; private final Deque nodeQueue; - private final IdentityHashMap nodeStates; + private final Map nodeStates; private final FixedNode start; protected T state; public PostOrderNodeIterator(FixedNode start, T initialState) { - visitedEnds = start.graph().createNodeBitMap(); + StructuredGraph graph = start.graph(); + visitedEnds = graph.createNodeBitMap(); nodeQueue = new ArrayDeque<>(); - nodeStates = new IdentityHashMap<>(); + nodeStates = CollectionsAccess.newNodeIdentityMap(); this.start = start; this.state = initialState; } diff -r 3882866b6ff9 -r 33cedbce5b23 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 Wed May 07 23:58:56 2014 +0200 +++ b/graal/com.oracle.graal.phases/src/com/oracle/graal/phases/graph/ReentrantBlockIterator.java Thu May 08 02:22:10 2014 +0200 @@ -22,6 +22,8 @@ */ package com.oracle.graal.phases.graph; +import static com.oracle.graal.graph.util.CollectionsAccess.*; + import java.util.*; import com.oracle.graal.compiler.common.cfg.*; @@ -54,7 +56,7 @@ } public static LoopInfo processLoop(BlockIteratorClosure closure, Loop loop, StateT initialState) { - IdentityHashMap blockEndStates = apply(closure, loop.getHeader(), initialState, new HashSet<>(loop.getBlocks())); + Map blockEndStates = apply(closure, loop.getHeader(), initialState, new HashSet<>(loop.getBlocks())); LoopInfo info = new LoopInfo<>(); List predecessors = loop.getHeader().getPredecessors(); @@ -77,12 +79,12 @@ apply(closure, start, closure.getInitialState(), null); } - public static IdentityHashMap apply(BlockIteratorClosure closure, Block start, StateT initialState, Set boundary) { + public static Map apply(BlockIteratorClosure closure, Block start, StateT initialState, Set boundary) { Deque blockQueue = new ArrayDeque<>(); /* * States are stored on EndNodes before merges, and on BeginNodes after ControlSplitNodes. */ - IdentityHashMap states = new IdentityHashMap<>(); + Map states = newNodeIdentityMap(); StateT state = initialState; Block current = start; diff -r 3882866b6ff9 -r 33cedbce5b23 graal/com.oracle.graal.phases/src/com/oracle/graal/phases/graph/ReentrantNodeIterator.java --- a/graal/com.oracle.graal.phases/src/com/oracle/graal/phases/graph/ReentrantNodeIterator.java Wed May 07 23:58:56 2014 +0200 +++ b/graal/com.oracle.graal.phases/src/com/oracle/graal/phases/graph/ReentrantNodeIterator.java Thu May 08 02:22:10 2014 +0200 @@ -22,6 +22,8 @@ */ package com.oracle.graal.phases.graph; +import static com.oracle.graal.graph.util.CollectionsAccess.*; + import java.util.*; import com.oracle.graal.graph.NodeClass.NodeClassIterator; @@ -31,8 +33,8 @@ public static class LoopInfo { - public final Map endStates = new IdentityHashMap<>(4); - public final Map exitStates = new IdentityHashMap<>(2); + public final Map endStates = newNodeIdentityMap(4); + public final Map exitStates = newNodeIdentityMap(2); } public abstract static class NodeIteratorClosure { @@ -76,13 +78,14 @@ return info; } - public static Map apply(NodeIteratorClosure closure, FixedNode start, StateT initialState) { - return apply(closure, start, initialState, null); + public static void apply(NodeIteratorClosure closure, FixedNode start, StateT initialState) { + apply(closure, start, initialState, null); } private static Map apply(NodeIteratorClosure closure, FixedNode start, StateT initialState, LoopBeginNode boundary) { + assert start != null; Deque nodeQueue = new ArrayDeque<>(); - IdentityHashMap blockEndStates = new IdentityHashMap<>(); + Map blockEndStates = newNodeIdentityMap(); StateT state = initialState; FixedNode current = start; diff -r 3882866b6ff9 -r 33cedbce5b23 graal/com.oracle.graal.phases/src/com/oracle/graal/phases/util/GraphOrder.java --- a/graal/com.oracle.graal.phases/src/com/oracle/graal/phases/util/GraphOrder.java Wed May 07 23:58:56 2014 +0200 +++ b/graal/com.oracle.graal.phases/src/com/oracle/graal/phases/util/GraphOrder.java Thu May 08 02:22:10 2014 +0200 @@ -22,6 +22,8 @@ */ package com.oracle.graal.phases.util; +import static com.oracle.graal.graph.util.CollectionsAccess.*; + import java.util.*; import com.oracle.graal.compiler.common.*; @@ -136,7 +138,7 @@ public static boolean assertSchedulableGraph(final StructuredGraph graph) { try { final SchedulePhase schedule = new SchedulePhase(SchedulingStrategy.LATEST_OUT_OF_LOOPS, MemoryScheduling.NONE); - final IdentityHashMap loopEntryStates = new IdentityHashMap<>(); + final Map loopEntryStates = newNodeIdentityMap(); schedule.apply(graph, false); BlockIteratorClosure closure = new BlockIteratorClosure() { diff -r 3882866b6ff9 -r 33cedbce5b23 graal/com.oracle.graal.replacements/src/com/oracle/graal/replacements/SnippetTemplate.java --- a/graal/com.oracle.graal.replacements/src/com/oracle/graal/replacements/SnippetTemplate.java Wed May 07 23:58:56 2014 +0200 +++ b/graal/com.oracle.graal.replacements/src/com/oracle/graal/replacements/SnippetTemplate.java Thu May 08 02:22:10 2014 +0200 @@ -24,9 +24,10 @@ import static com.oracle.graal.api.meta.LocationIdentity.*; import static com.oracle.graal.api.meta.MetaUtil.*; +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 java.util.FormattableFlags.*; -import static com.oracle.graal.compiler.common.GraalOptions.*; import java.io.*; import java.lang.reflect.*; @@ -494,7 +495,7 @@ // Copy snippet graph, replacing constant parameters with given arguments final StructuredGraph snippetCopy = new StructuredGraph(snippetGraph.name, snippetGraph.method()); - IdentityHashMap nodeReplacements = new IdentityHashMap<>(); + Map nodeReplacements = newNodeIdentityMap(); nodeReplacements.put(snippetGraph.start(), snippetCopy.start()); MetaAccessProvider metaAccess = providers.getMetaAccess(); @@ -790,8 +791,8 @@ * * @return the map that will be used to bind arguments to parameters when inlining this template */ - private IdentityHashMap bind(StructuredGraph replaceeGraph, MetaAccessProvider metaAccess, Arguments args) { - IdentityHashMap replacements = new IdentityHashMap<>(); + private Map bind(StructuredGraph replaceeGraph, MetaAccessProvider metaAccess, Arguments args) { + Map replacements = newNodeIdentityMap(); 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]; @@ -1031,7 +1032,7 @@ StartNode entryPointNode = snippet.start(); FixedNode firstCFGNode = entryPointNode.next(); StructuredGraph replaceeGraph = replacee.graph(); - IdentityHashMap replacements = bind(replaceeGraph, metaAccess, args); + Map replacements = bind(replaceeGraph, metaAccess, args); replacements.put(entryPointNode, BeginNode.prevBegin(replacee)); Map duplicates = replaceeGraph.addDuplicates(nodes, snippet, snippet.getNodeCount(), replacements); Debug.dump(replaceeGraph, "After inlining snippet %s", snippet.method()); @@ -1184,7 +1185,7 @@ StartNode entryPointNode = snippet.start(); FixedNode firstCFGNode = entryPointNode.next(); StructuredGraph replaceeGraph = replacee.graph(); - IdentityHashMap replacements = bind(replaceeGraph, metaAccess, args); + Map replacements = bind(replaceeGraph, metaAccess, args); replacements.put(entryPointNode, tool.getCurrentGuardAnchor().asNode()); Map duplicates = replaceeGraph.addDuplicates(nodes, snippet, snippet.getNodeCount(), replacements); Debug.dump(replaceeGraph, "After inlining snippet %s", snippetCopy.method()); diff -r 3882866b6ff9 -r 33cedbce5b23 graal/com.oracle.graal.truffle.hotspot/src/com/oracle/graal/truffle/hotspot/HotSpotTruffleRuntime.java --- a/graal/com.oracle.graal.truffle.hotspot/src/com/oracle/graal/truffle/hotspot/HotSpotTruffleRuntime.java Wed May 07 23:58:56 2014 +0200 +++ b/graal/com.oracle.graal.truffle.hotspot/src/com/oracle/graal/truffle/hotspot/HotSpotTruffleRuntime.java Thu May 08 02:22:10 2014 +0200 @@ -24,6 +24,7 @@ import static com.oracle.graal.api.code.CodeUtil.*; import static com.oracle.graal.compiler.GraalCompiler.*; +import static com.oracle.graal.graph.util.CollectionsAccess.*; import static com.oracle.graal.truffle.TruffleCompilerOptions.*; import java.util.*; @@ -71,7 +72,7 @@ private StackIntrospection stackIntrospection; private ArrayList includes; private ArrayList excludes; - private Map> compilations = new IdentityHashMap<>(); + private Map> compilations = newIdentityMap(); private final ThreadPoolExecutor compileQueue; private final ResolvedJavaMethod[] callNodeMethod; diff -r 3882866b6ff9 -r 33cedbce5b23 graal/com.oracle.graal.virtual/src/com/oracle/graal/virtual/phases/ea/EffectsClosure.java --- a/graal/com.oracle.graal.virtual/src/com/oracle/graal/virtual/phases/ea/EffectsClosure.java Wed May 07 23:58:56 2014 +0200 +++ b/graal/com.oracle.graal.virtual/src/com/oracle/graal/virtual/phases/ea/EffectsClosure.java Thu May 08 02:22:10 2014 +0200 @@ -23,6 +23,7 @@ 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.*; @@ -45,8 +46,8 @@ protected final NodeMap aliases; protected final BlockMap blockEffects; - private final IdentityHashMap, GraphEffectList> loopMergeEffects = new IdentityHashMap<>(); - private final IdentityHashMap loopEntryStates = new IdentityHashMap<>(); + private final Map, GraphEffectList> loopMergeEffects = newIdentityMap(); + private final Map loopEntryStates = newNodeIdentityMap(); private boolean changed; diff -r 3882866b6ff9 -r 33cedbce5b23 graal/com.oracle.graal.virtual/src/com/oracle/graal/virtual/phases/ea/PartialEscapeBlockState.java --- a/graal/com.oracle.graal.virtual/src/com/oracle/graal/virtual/phases/ea/PartialEscapeBlockState.java Wed May 07 23:58:56 2014 +0200 +++ b/graal/com.oracle.graal.virtual/src/com/oracle/graal/virtual/phases/ea/PartialEscapeBlockState.java Thu May 08 02:22:10 2014 +0200 @@ -22,6 +22,8 @@ */ package com.oracle.graal.virtual.phases.ea; +import static com.oracle.graal.graph.util.CollectionsAccess.*; + import java.util.*; import com.oracle.graal.nodes.*; @@ -31,7 +33,7 @@ public abstract class PartialEscapeBlockState> extends EffectsBlockState { - protected final IdentityHashMap objectStates = new IdentityHashMap<>(); + protected final Map objectStates = newIdentityMap(); /** * Final subclass of PartialEscapeBlockState, for performance and to make everything behave diff -r 3882866b6ff9 -r 33cedbce5b23 graal/com.oracle.graal.virtual/src/com/oracle/graal/virtual/phases/ea/PartialEscapeClosure.java --- a/graal/com.oracle.graal.virtual/src/com/oracle/graal/virtual/phases/ea/PartialEscapeClosure.java Wed May 07 23:58:56 2014 +0200 +++ b/graal/com.oracle.graal.virtual/src/com/oracle/graal/virtual/phases/ea/PartialEscapeClosure.java Thu May 08 02:22:10 2014 +0200 @@ -22,6 +22,8 @@ */ package com.oracle.graal.virtual.phases.ea; +import static com.oracle.graal.graph.util.CollectionsAccess.*; + import java.util.*; import com.oracle.graal.api.code.*; @@ -33,7 +35,6 @@ import com.oracle.graal.nodes.VirtualState.NodeClosure; import com.oracle.graal.nodes.cfg.*; import com.oracle.graal.nodes.extended.*; -import com.oracle.graal.nodes.java.*; import com.oracle.graal.nodes.spi.*; import com.oracle.graal.nodes.spi.Virtualizable.EscapeState; import com.oracle.graal.nodes.virtual.*; @@ -55,7 +56,6 @@ private final NodeBitMap usages; private final VirtualizerToolImpl tool; - private final Map hints = new IdentityHashMap<>(); /** * Final subclass of PartialEscapeClosure, for performance and to make everything behave nicely @@ -84,10 +84,6 @@ this.tool = new VirtualizerToolImpl(metaAccess, constantReflection, assumptions, this); } - public Map getHints() { - return hints; - } - /** * @return true if the node was deleted, false otherwise */ @@ -116,10 +112,6 @@ for (ValueNode input : node.inputs().filter(ValueNode.class)) { ObjectState obj = getObjectState(state, input); if (obj != null) { - if (obj.isVirtual() && node instanceof MethodCallTargetNode) { - Invoke invoke = ((MethodCallTargetNode) node).invoke(); - hints.put(invoke, 5d); - } VirtualUtil.trace("replacing input %s at %s: %s", input, node, obj); replaceWithMaterialized(input, node, insertBefore, state, obj, effects, METRIC_MATERIALIZATIONS_UNHANDLED); } @@ -278,8 +270,8 @@ protected class MergeProcessor extends EffectsClosure.MergeProcessor { private final HashMap materializedPhis = new HashMap<>(); - private final IdentityHashMap valuePhis = new IdentityHashMap<>(); - private final IdentityHashMap valueObjectVirtuals = new IdentityHashMap<>(); + private final Map valuePhis = newIdentityMap(); + private final Map valueObjectVirtuals = newNodeIdentityMap(); public MergeProcessor(Block mergeBlock) { super(mergeBlock); diff -r 3882866b6ff9 -r 33cedbce5b23 graal/com.oracle.graal.virtual/src/com/oracle/graal/virtual/phases/ea/VirtualUtil.java --- a/graal/com.oracle.graal.virtual/src/com/oracle/graal/virtual/phases/ea/VirtualUtil.java Wed May 07 23:58:56 2014 +0200 +++ b/graal/com.oracle.graal.virtual/src/com/oracle/graal/virtual/phases/ea/VirtualUtil.java Thu May 08 02:22:10 2014 +0200 @@ -23,6 +23,7 @@ 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.*; @@ -42,7 +43,7 @@ // helper code that determines the paths that keep obsolete nodes alive: NodeFlood flood = graph.createNodeFlood(); - IdentityHashMap path = new IdentityHashMap<>(); + Map path = newIdentityMap(); flood.add(graph.start()); for (Node current : flood) { if (current instanceof AbstractEndNode) { diff -r 3882866b6ff9 -r 33cedbce5b23 mx/projects --- a/mx/projects Wed May 07 23:58:56 2014 +0200 +++ b/mx/projects Thu May 08 02:22:10 2014 +0200 @@ -78,6 +78,13 @@ com.oracle.graal.hotspot.hsail distribution@GRAAL@excludeLibs=FINDBUGS +# graal.api.collections +project@com.oracle.graal.api.collections@subDir=graal +project@com.oracle.graal.api.collections@sourceDirs=src +project@com.oracle.graal.api.collections@checkstyle=com.oracle.graal.graph +project@com.oracle.graal.api.collections@javaCompliance=1.8 +project@com.oracle.graal.api.collections@workingSets=API,Graal + # graal.api.runtime project@com.oracle.graal.api.runtime@subDir=graal project@com.oracle.graal.api.runtime@sourceDirs=src @@ -260,7 +267,7 @@ # graal.graph project@com.oracle.graal.graph@subDir=graal project@com.oracle.graal.graph@sourceDirs=src -project@com.oracle.graal.graph@dependencies=com.oracle.graal.debug,com.oracle.graal.compiler.common,FINDBUGS +project@com.oracle.graal.graph@dependencies=com.oracle.graal.debug,com.oracle.graal.compiler.common,com.oracle.graal.api.collections,com.oracle.graal.api.runtime,FINDBUGS project@com.oracle.graal.graph@javaCompliance=1.8 project@com.oracle.graal.graph@workingSets=Graal,Graph @@ -429,7 +436,7 @@ # graal.compiler project@com.oracle.graal.compiler@subDir=graal project@com.oracle.graal.compiler@sourceDirs=src -project@com.oracle.graal.compiler@dependencies=com.oracle.graal.api.runtime,com.oracle.graal.virtual,com.oracle.graal.loop,com.oracle.graal.alloc +project@com.oracle.graal.compiler@dependencies=com.oracle.graal.virtual,com.oracle.graal.loop,com.oracle.graal.alloc project@com.oracle.graal.compiler@checkstyle=com.oracle.graal.graph project@com.oracle.graal.compiler@javaCompliance=1.8 project@com.oracle.graal.compiler@annotationProcessors=com.oracle.graal.service.processor