changeset 15551:33cedbce5b23

added CollectionsProvider and NodeCollectionsProvider and replaced (almost) all allocations of IdentityHashMaps to go through these providers
author Doug Simon <doug.simon@oracle.com>
date Thu, 08 May 2014 02:22:10 +0200
parents 3882866b6ff9
children 385df32e0fd6
files graal/com.oracle.graal.api.collections/src/com/oracle/graal/api/collections/CollectionsProvider.java graal/com.oracle.graal.api.collections/src/com/oracle/graal/api/collections/DefaultCollectionsProvider.java graal/com.oracle.graal.api.runtime/src/com/oracle/graal/api/runtime/Graal.java graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/gen/DebugInfoBuilder.java graal/com.oracle.graal.graph/src/com/oracle/graal/graph/DefaultNodeCollectionsProvider.java graal/com.oracle.graal.graph/src/com/oracle/graal/graph/NodeClass.java graal/com.oracle.graal.graph/src/com/oracle/graal/graph/NodeCollectionsProvider.java graal/com.oracle.graal.graph/src/com/oracle/graal/graph/util/CollectionsAccess.java graal/com.oracle.graal.hotspot.server/src/com/oracle/graal/hotspot/server/ReplacingStreams.java graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/HotSpotGraalRuntime.java graal/com.oracle.graal.loop/src/com/oracle/graal/loop/InductionVariables.java graal/com.oracle.graal.loop/src/com/oracle/graal/loop/LoopFragmentInside.java graal/com.oracle.graal.loop/src/com/oracle/graal/loop/LoopsData.java graal/com.oracle.graal.phases.common/src/com/oracle/graal/phases/common/ConditionalEliminationPhase.java graal/com.oracle.graal.phases.common/src/com/oracle/graal/phases/common/FloatingReadPhase.java graal/com.oracle.graal.phases.common/src/com/oracle/graal/phases/common/GuardLoweringPhase.java graal/com.oracle.graal.phases.common/src/com/oracle/graal/phases/common/cfs/EquationalReasoner.java graal/com.oracle.graal.phases.common/src/com/oracle/graal/phases/common/cfs/State.java graal/com.oracle.graal.phases.common/src/com/oracle/graal/phases/common/inlining/ComputeInliningRelevance.java graal/com.oracle.graal.phases/src/com/oracle/graal/phases/graph/FixedNodeProbabilityCache.java graal/com.oracle.graal.phases/src/com/oracle/graal/phases/graph/PostOrderNodeIterator.java graal/com.oracle.graal.phases/src/com/oracle/graal/phases/graph/ReentrantBlockIterator.java graal/com.oracle.graal.phases/src/com/oracle/graal/phases/graph/ReentrantNodeIterator.java graal/com.oracle.graal.phases/src/com/oracle/graal/phases/util/GraphOrder.java graal/com.oracle.graal.replacements/src/com/oracle/graal/replacements/SnippetTemplate.java graal/com.oracle.graal.truffle.hotspot/src/com/oracle/graal/truffle/hotspot/HotSpotTruffleRuntime.java graal/com.oracle.graal.virtual/src/com/oracle/graal/virtual/phases/ea/EffectsClosure.java graal/com.oracle.graal.virtual/src/com/oracle/graal/virtual/phases/ea/PartialEscapeBlockState.java graal/com.oracle.graal.virtual/src/com/oracle/graal/virtual/phases/ea/PartialEscapeClosure.java graal/com.oracle.graal.virtual/src/com/oracle/graal/virtual/phases/ea/VirtualUtil.java mx/projects
diffstat 31 files changed, 484 insertions(+), 145 deletions(-) [+]
line wrap: on
line diff
--- /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.
+     */
+    <E> Set<E> newIdentitySet();
+
+    /**
+     * Creates a map that uses reference-equality in place of object-equality when comparing keys.
+     */
+    <K, V> Map<K, V> 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
+     */
+    <K, V> Map<K, V> 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
+     */
+    <K, V> Map<K, V> newIdentityMap(Map<K, V> initFrom);
+}
--- /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 <E> Set<E> newIdentitySet() {
+        return Collections.newSetFromMap(newIdentityMap());
+    }
+
+    public <K, V> Map<K, V> newIdentityMap() {
+        return new IdentityHashMap<>();
+    }
+
+    public <K, V> Map<K, V> newIdentityMap(int expectedMaxSize) {
+        return new IdentityHashMap<>(expectedMaxSize);
+    }
+
+    public <K, V> Map<K, V> newIdentityMap(Map<K, V> initFrom) {
+        return new IdentityHashMap<>(initFrom);
+    }
+}
--- 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");
     }
 
--- 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<VirtualObjectNode, VirtualObject> virtualObjects = new HashMap<>();
-    protected final IdentityHashMap<VirtualObjectNode, EscapeObjectState> objectStates = new IdentityHashMap<>();
+    protected final Map<VirtualObjectNode, VirtualObject> virtualObjects = new HashMap<>();
+    protected final Map<VirtualObjectNode, EscapeObjectState> objectStates = newNodeIdentityMap();
 
     public LIRFrameState build(FrameState topState, LabelRef exceptionEdge) {
         assert virtualObjects.size() == 0;
@@ -76,7 +78,7 @@
             boolean changed;
             do {
                 changed = false;
-                IdentityHashMap<VirtualObjectNode, VirtualObject> virtualObjectsCopy = new IdentityHashMap<>(virtualObjects);
+                Map<VirtualObjectNode, VirtualObject> virtualObjectsCopy = newIdentityMap(virtualObjects);
                 for (Entry<VirtualObjectNode, VirtualObject> entry : virtualObjectsCopy.entrySet()) {
                     if (entry.getValue().getValues() == null) {
                         VirtualObjectNode vobj = entry.getKey();
--- /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 <E extends Node> Set<E> newNodeIdentitySet() {
+        return Collections.newSetFromMap(newNodeIdentityMap());
+    }
+
+    public <K extends Node, V> Map<K, V> newNodeIdentityMap() {
+        return new IdentityHashMap<>();
+    }
+
+    public <K extends Node, V> Map<K, V> newNodeIdentityMap(int expectedMaxSize) {
+        return new IdentityHashMap<>(expectedMaxSize);
+    }
+
+    public <K extends Node, V> Map<K, V> newNodeIdentityMap(Map<K, V> initFrom) {
+        return new IdentityHashMap<>(initFrom);
+    }
+}
--- 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<Node, Node> addGraphDuplicate(final Graph graph, final Graph oldGraph, int estimatedNodeCount, Iterable<Node> nodes, final DuplicationReplacement replacements) {
         final Map<Node, Node> 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);
 
--- /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.
+     */
+    <E extends Node> Set<E> 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.
+     */
+    <K extends Node, V> Map<K, V> 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.
+     */
+    <K extends Node, V> Map<K, V> 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
+     */
+    <K extends Node, V> Map<K, V> newNodeIdentityMap(Map<K, V> initFrom);
+}
--- /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 <K, V> Map<K, V> newIdentityMap() {
+        return provider.newIdentityMap();
+    }
+
+    /**
+     * @see CollectionsProvider#newIdentityMap()
+     */
+    public static <K, V> Map<K, V> newIdentityMap(int expectedMaxSize) {
+        return provider.newIdentityMap(expectedMaxSize);
+    }
+
+    /**
+     * @see CollectionsProvider#newIdentityMap(Map)
+     */
+    public static <K, V> Map<K, V> newIdentityMap(Map<K, V> initFrom) {
+        return provider.newIdentityMap(initFrom);
+    }
+
+    /**
+     * @see NodeCollectionsProvider#newNodeIdentitySet()
+     */
+    public static <E extends Node> Set<E> newNodeIdentitySet() {
+        return provider.newNodeIdentitySet();
+    }
+
+    /**
+     * @see NodeCollectionsProvider#newNodeIdentityMap()
+     */
+    public static <K extends Node, V> Map<K, V> newNodeIdentityMap() {
+        return provider.newNodeIdentityMap();
+    }
+
+    /**
+     * @see NodeCollectionsProvider#newNodeIdentityMap(int)
+     */
+    public static <K extends Node, V> Map<K, V> newNodeIdentityMap(int expectedMaxSize) {
+        return provider.newNodeIdentityMap(expectedMaxSize);
+    }
+
+    /**
+     * @see NodeCollectionsProvider#newNodeIdentityMap(Map)
+     */
+    public static <K extends Node, V> Map<K, V> newNodeIdentityMap(Map<K, V> initFrom) {
+        return provider.newNodeIdentityMap(initFrom);
+    }
+
+    /**
+     * Creates an identity set.
+     */
+    public static <E> Set<E> newIdentitySet() {
+        return provider.newIdentitySet();
+    }
+}
--- 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<Object, Placeholder> objectMap = new IdentityHashMap<>();
+    private Map<Object, Placeholder> objectMap = newIdentityMap();
     private ArrayList<Object> objectList = new ArrayList<>();
 
     private ReplacingOutputStream output;
--- 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> T getCapability(Class<T> 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) {
--- 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());
     }
 
--- 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) {
--- 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<Loop<Block>, LoopEx> lirLoopToEx = new IdentityHashMap<>();
-    private Map<LoopBeginNode, LoopEx> loopBeginToEx = new IdentityHashMap<>();
+    private Map<Loop<Block>, LoopEx> lirLoopToEx = newIdentityMap();
+    private Map<LoopBeginNode, LoopEx> loopBeginToEx = newNodeIdentityMap();
     private ControlFlowGraph cfg;
 
     public LoopsData(final StructuredGraph graph) {
--- 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<State> implements Cloneable {
 
-        private IdentityHashMap<ValueNode, ResolvedJavaType> knownTypes;
+        private Map<ValueNode, ResolvedJavaType> knownTypes;
         private HashSet<ValueNode> knownNonNull;
         private HashSet<ValueNode> knownNull;
-        private IdentityHashMap<LogicNode, ValueNode> trueConditions;
-        private IdentityHashMap<LogicNode, ValueNode> falseConditions;
-        private IdentityHashMap<ValueNode, GuardedStamp> valueConstraints;
+        private Map<LogicNode, ValueNode> trueConditions;
+        private Map<LogicNode, ValueNode> falseConditions;
+        private Map<ValueNode, GuardedStamp> 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<State> withStates) {
-            IdentityHashMap<ValueNode, ResolvedJavaType> newKnownTypes = new IdentityHashMap<>();
-            IdentityHashMap<LogicNode, ValueNode> newTrueConditions = new IdentityHashMap<>();
-            IdentityHashMap<LogicNode, ValueNode> newFalseConditions = new IdentityHashMap<>();
-            IdentityHashMap<ValueNode, GuardedStamp> newValueConstraints = new IdentityHashMap<>();
+            Map<ValueNode, ResolvedJavaType> newKnownTypes = newNodeIdentityMap();
+            Map<LogicNode, ValueNode> newTrueConditions = newNodeIdentityMap();
+            Map<LogicNode, ValueNode> newFalseConditions = newNodeIdentityMap();
+            Map<ValueNode, GuardedStamp> newValueConstraints = newNodeIdentityMap();
 
             HashSet<ValueNode> newKnownNull = new HashSet<>(knownNull);
             HashSet<ValueNode> newKnownNonNull = new HashSet<>(knownNonNull);
--- 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<LocationIdentity, MemoryNode> lastMemorySnapshot;
+        private final Map<LocationIdentity, MemoryNode> 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<LoopBeginNode, Set<LocationIdentity>> modifiedInLoops = new IdentityHashMap<>();
+        Map<LoopBeginNode, Set<LocationIdentity>> modifiedInLoops = newNodeIdentityMap();
         ReentrantNodeIterator.apply(new CollectMemoryCheckpointsClosure(modifiedInLoops), graph.start(), new HashSet<LocationIdentity>());
         ReentrantNodeIterator.apply(new FloatingReadClosure(modifiedInLoops, execmode), graph.start(), new MemoryMapImpl(graph.start()));
         if (execmode == ExecutionMode.CREATE_FLOATING_READS) {
--- 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<ValueNode, GuardNode> nullGuarded = new IdentityHashMap<>();
+        private final Map<ValueNode, GuardNode> nullGuarded = newIdentityMap();
         private final int implicitNullCheckLimit;
 
         UseImplicitNullChecks(int implicitNullCheckLimit) {
--- 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.*;
 
 /**
  * <p>
@@ -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<ValueNode> added = java.util.Collections.newSetFromMap(new IdentityHashMap<ValueNode, Boolean>());
+    final Set<ValueNode> 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<ValueNode, ValueNode> substs = new IdentityHashMap<>();
+    private final Map<ValueNode, ValueNode> substs = newNodeIdentityMap();
 
     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	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 @@
      * </p>
      *
      */
-    private IdentityHashMap<ValueNode, Witness> typeRefinements;
+    private Map<ValueNode, Witness> typeRefinements;
 
-    IdentityHashMap<ValueNode, GuardingNode> knownNull;
-    IdentityHashMap<LogicNode, GuardingNode> trueFacts;
-    IdentityHashMap<LogicNode, GuardingNode> falseFacts;
+    Map<ValueNode, GuardingNode> knownNull;
+    Map<LogicNode, GuardingNode> trueFacts;
+    Map<LogicNode, GuardingNode> 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<ValueNode, Witness> 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<ValueNode, Witness> mergeKnownTypes(MergeNode merge, ArrayList<State> withReachableStates) {
-        IdentityHashMap<ValueNode, Witness> newKnownTypes = new IdentityHashMap<>();
+    private Map<ValueNode, Witness> mergeKnownTypes(MergeNode merge, ArrayList<State> withReachableStates) {
+        Map<ValueNode, Witness> newKnownTypes = newNodeIdentityMap();
 
         for (Map.Entry<ValueNode, Witness> entry : typeRefinements.entrySet()) {
             ValueNode node = entry.getKey();
@@ -191,9 +189,9 @@
         return newKnownTypes;
     }
 
-    private IdentityHashMap<ValueNode, GuardingNode> mergeKnownNull(MergeNode merge, ArrayList<State> withReachableStates) {
+    private Map<ValueNode, GuardingNode> mergeKnownNull(MergeNode merge, ArrayList<State> withReachableStates) {
         // newKnownNull starts empty
-        IdentityHashMap<ValueNode, GuardingNode> newKnownNull = new IdentityHashMap<>();
+        Map<ValueNode, GuardingNode> newKnownNull = newNodeIdentityMap();
         for (Map.Entry<ValueNode, GuardingNode> entry : knownNull.entrySet()) {
             ValueNode key = entry.getKey();
             GuardingNode newGN = entry.getValue();
@@ -233,7 +231,7 @@
      * when merging type-witnesses and known-null maps.
      * </p>
      */
-    private void mergePhis(MergeNode merge, List<State> withStates, IdentityHashMap<ValueNode, Witness> newKnownPhiTypes, IdentityHashMap<ValueNode, GuardingNode> newKnownNullPhis) {
+    private void mergePhis(MergeNode merge, List<State> withStates, Map<ValueNode, Witness> newKnownPhiTypes, Map<ValueNode, GuardingNode> newKnownNullPhis) {
 
         if (merge instanceof LoopBeginNode) {
             return;
@@ -303,9 +301,9 @@
         }
 
         // may also get updated in a moment, during processing of phi nodes.
-        IdentityHashMap<ValueNode, Witness> newKnownTypes = mergeKnownTypes(merge, withReachableStates);
+        Map<ValueNode, Witness> newKnownTypes = mergeKnownTypes(merge, withReachableStates);
         // may also get updated in a moment, during processing of phi nodes.
-        IdentityHashMap<ValueNode, GuardingNode> newKnownNull = mergeKnownNull(merge, withReachableStates);
+        Map<ValueNode, GuardingNode> newKnownNull = mergeKnownNull(merge, withReachableStates);
         mergePhis(merge, withStates, newKnownTypes, newKnownNull);
         this.typeRefinements = newKnownTypes;
         this.knownNull = newKnownNull;
@@ -318,8 +316,8 @@
         return true;
     }
 
-    private IdentityHashMap<LogicNode, GuardingNode> mergeTrueFacts(ArrayList<State> withReachableStates, GuardingNode merge) {
-        IdentityHashMap<LogicNode, GuardingNode> newTrueConditions = new IdentityHashMap<>();
+    private Map<LogicNode, GuardingNode> mergeTrueFacts(ArrayList<State> withReachableStates, GuardingNode merge) {
+        Map<LogicNode, GuardingNode> newTrueConditions = newNodeIdentityMap();
         for (Map.Entry<LogicNode, GuardingNode> entry : trueFacts.entrySet()) {
             LogicNode check = entry.getKey();
             GuardingNode guard = entry.getValue();
@@ -341,8 +339,8 @@
         return newTrueConditions;
     }
 
-    private IdentityHashMap<LogicNode, GuardingNode> mergeFalseFacts(ArrayList<State> withReachableStates, GuardingNode merge) {
-        IdentityHashMap<LogicNode, GuardingNode> newFalseConditions = new IdentityHashMap<>();
+    private Map<LogicNode, GuardingNode> mergeFalseFacts(ArrayList<State> withReachableStates, GuardingNode merge) {
+        Map<LogicNode, GuardingNode> newFalseConditions = newNodeIdentityMap();
         for (Map.Entry<LogicNode, GuardingNode> entry : falseFacts.entrySet()) {
             LogicNode check = entry.getKey();
             GuardingNode guard = entry.getValue();
@@ -653,7 +651,7 @@
      * </p>
      *
      */
-    private void addFactPrimordial(LogicNode condition, IdentityHashMap<LogicNode, GuardingNode> to, GuardingNode anchor) {
+    private void addFactPrimordial(LogicNode condition, Map<LogicNode, GuardingNode> to, GuardingNode anchor) {
         assert condition != null;
         if (!to.containsKey(condition)) {
             versionNr++;
--- 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<FixedNode, Double> nodeRelevances;
+    private Map<FixedNode, Double> 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<LoopBeginNode, Scope> loops = new IdentityHashMap<>(EXPECTED_LOOP_COUNT);
+            Map<LoopBeginNode, Scope> 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<LoopBeginNode, Scope> loops) {
+    private Scope createLoopScope(LoopBeginNode loopBegin, Map<LoopBeginNode, Scope> loops) {
         Scope scope = loops.get(loopBegin);
         if (scope == null) {
             final Scope parent;
--- 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<FixedNode, Double> cache = new IdentityHashMap<>();
+    private final Map<FixedNode, Double> cache = newIdentityMap();
 
     public double applyAsDouble(FixedNode node) {
         metricComputeNodeProbability.increment();
--- 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 @@
  * <p>
  * While iterating it maintains a user-defined state by calling the methods available in
  * {@link MergeableState}.
- * 
+ *
  * @param <T> the type of {@link MergeableState} handled by this PostOrderNodeIterator
  */
 public abstract class PostOrderNodeIterator<T extends MergeableState<T>> {
 
     private final NodeBitMap visitedEnds;
     private final Deque<BeginNode> nodeQueue;
-    private final IdentityHashMap<FixedNode, T> nodeStates;
+    private final Map<FixedNode, T> 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;
     }
--- 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 <StateT> LoopInfo<StateT> processLoop(BlockIteratorClosure<StateT> closure, Loop<Block> loop, StateT initialState) {
-        IdentityHashMap<FixedNode, StateT> blockEndStates = apply(closure, loop.getHeader(), initialState, new HashSet<>(loop.getBlocks()));
+        Map<FixedNode, StateT> blockEndStates = apply(closure, loop.getHeader(), initialState, new HashSet<>(loop.getBlocks()));
 
         LoopInfo<StateT> info = new LoopInfo<>();
         List<Block> predecessors = loop.getHeader().getPredecessors();
@@ -77,12 +79,12 @@
         apply(closure, start, closure.getInitialState(), null);
     }
 
-    public static <StateT> IdentityHashMap<FixedNode, StateT> apply(BlockIteratorClosure<StateT> closure, Block start, StateT initialState, Set<Block> boundary) {
+    public static <StateT> Map<FixedNode, StateT> apply(BlockIteratorClosure<StateT> closure, Block start, StateT initialState, Set<Block> boundary) {
         Deque<Block> blockQueue = new ArrayDeque<>();
         /*
          * States are stored on EndNodes before merges, and on BeginNodes after ControlSplitNodes.
          */
-        IdentityHashMap<FixedNode, StateT> states = new IdentityHashMap<>();
+        Map<FixedNode, StateT> states = newNodeIdentityMap();
 
         StateT state = initialState;
         Block current = start;
--- 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<StateT> {
 
-        public final Map<LoopEndNode, StateT> endStates = new IdentityHashMap<>(4);
-        public final Map<LoopExitNode, StateT> exitStates = new IdentityHashMap<>(2);
+        public final Map<LoopEndNode, StateT> endStates = newNodeIdentityMap(4);
+        public final Map<LoopExitNode, StateT> exitStates = newNodeIdentityMap(2);
     }
 
     public abstract static class NodeIteratorClosure<StateT> {
@@ -76,13 +78,14 @@
         return info;
     }
 
-    public static <StateT> Map<FixedNode, StateT> apply(NodeIteratorClosure<StateT> closure, FixedNode start, StateT initialState) {
-        return apply(closure, start, initialState, null);
+    public static <StateT> void apply(NodeIteratorClosure<StateT> closure, FixedNode start, StateT initialState) {
+        apply(closure, start, initialState, null);
     }
 
     private static <StateT> Map<FixedNode, StateT> apply(NodeIteratorClosure<StateT> closure, FixedNode start, StateT initialState, LoopBeginNode boundary) {
+        assert start != null;
         Deque<BeginNode> nodeQueue = new ArrayDeque<>();
-        IdentityHashMap<FixedNode, StateT> blockEndStates = new IdentityHashMap<>();
+        Map<FixedNode, StateT> blockEndStates = newNodeIdentityMap();
 
         StateT state = initialState;
         FixedNode current = start;
--- 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<LoopBeginNode, NodeBitMap> loopEntryStates = new IdentityHashMap<>();
+            final Map<LoopBeginNode, NodeBitMap> loopEntryStates = newNodeIdentityMap();
             schedule.apply(graph, false);
 
             BlockIteratorClosure<NodeBitMap> closure = new BlockIteratorClosure<NodeBitMap>() {
--- 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<Node, Node> nodeReplacements = new IdentityHashMap<>();
+        Map<Node, Node> 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<Node, Node> bind(StructuredGraph replaceeGraph, MetaAccessProvider metaAccess, Arguments args) {
-        IdentityHashMap<Node, Node> replacements = new IdentityHashMap<>();
+    private Map<Node, Node> bind(StructuredGraph replaceeGraph, MetaAccessProvider metaAccess, Arguments args) {
+        Map<Node, Node> 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<Node, Node> replacements = bind(replaceeGraph, metaAccess, args);
+            Map<Node, Node> replacements = bind(replaceeGraph, metaAccess, args);
             replacements.put(entryPointNode, BeginNode.prevBegin(replacee));
             Map<Node, Node> 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<Node, Node> replacements = bind(replaceeGraph, metaAccess, args);
+            Map<Node, Node> replacements = bind(replaceeGraph, metaAccess, args);
             replacements.put(entryPointNode, tool.getCurrentGuardAnchor().asNode());
             Map<Node, Node> duplicates = replaceeGraph.addDuplicates(nodes, snippet, snippet.getNodeCount(), replacements);
             Debug.dump(replaceeGraph, "After inlining snippet %s", snippetCopy.method());
--- 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<String> includes;
     private ArrayList<String> excludes;
-    private Map<OptimizedCallTarget, Future<?>> compilations = new IdentityHashMap<>();
+    private Map<OptimizedCallTarget, Future<?>> compilations = newIdentityMap();
     private final ThreadPoolExecutor compileQueue;
 
     private final ResolvedJavaMethod[] callNodeMethod;
--- 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<ValueNode> aliases;
     protected final BlockMap<GraphEffectList> blockEffects;
-    private final IdentityHashMap<Loop<Block>, GraphEffectList> loopMergeEffects = new IdentityHashMap<>();
-    private final IdentityHashMap<LoopBeginNode, BlockT> loopEntryStates = new IdentityHashMap<>();
+    private final Map<Loop<Block>, GraphEffectList> loopMergeEffects = newIdentityMap();
+    private final Map<LoopBeginNode, BlockT> loopEntryStates = newNodeIdentityMap();
 
     private boolean changed;
 
--- 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<T extends PartialEscapeBlockState<T>> extends EffectsBlockState<T> {
 
-    protected final IdentityHashMap<VirtualObjectNode, ObjectState> objectStates = new IdentityHashMap<>();
+    protected final Map<VirtualObjectNode, ObjectState> objectStates = 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	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<Invoke, Double> 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<Invoke, Double> 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<BlockT>.MergeProcessor {
 
         private final HashMap<Object, ValuePhiNode> materializedPhis = new HashMap<>();
-        private final IdentityHashMap<ValueNode, ValuePhiNode[]> valuePhis = new IdentityHashMap<>();
-        private final IdentityHashMap<ValuePhiNode, VirtualObjectNode> valueObjectVirtuals = new IdentityHashMap<>();
+        private final Map<ValueNode, ValuePhiNode[]> valuePhis = newIdentityMap();
+        private final Map<ValuePhiNode, VirtualObjectNode> valueObjectVirtuals = newNodeIdentityMap();
 
         public MergeProcessor(Block mergeBlock) {
             super(mergeBlock);
--- 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<Node, Node> path = new IdentityHashMap<>();
+        Map<Node, Node> path = newIdentityMap();
         flood.add(graph.start());
         for (Node current : flood) {
             if (current instanceof AbstractEndNode) {
--- 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