changeset 17347:63780e37b7b9

re-added support for cloning a node without adding it to a graph
author Doug Simon <doug.simon@oracle.com>
date Mon, 06 Oct 2014 14:49:14 +0200
parents 97198814de41
children 0ba1a6745070
files graal/com.oracle.graal.graph/src/com/oracle/graal/graph/Node.java
diffstat 1 files changed, 15 insertions(+), 9 deletions(-) [+]
line wrap: on
line diff
--- a/graal/com.oracle.graal.graph/src/com/oracle/graal/graph/Node.java	Mon Oct 06 13:15:07 2014 +0200
+++ b/graal/com.oracle.graal.graph/src/com/oracle/graal/graph/Node.java	Mon Oct 06 14:49:14 2014 +0200
@@ -765,6 +765,7 @@
      * Makes a copy of this node in(to) a given graph.
      *
      * @param into the graph in which the copy will be registered (which may be this node's graph)
+     *            or null if the copy should not be registered in a graph
      * @param edgesToCopy specifies the edges to be copied. The edges not specified in this set are
      *            initialized to their default value (i.e., {@code null} for a direct edge, an empty
      *            list for an edge list)
@@ -772,11 +773,14 @@
      */
     final Node clone(Graph into, EnumSet<Edges.Type> edgesToCopy) {
         NodeClass nodeClass = getNodeClass();
-        boolean isValueNumberableLeaf = nodeClass.valueNumberable() && nodeClass.isLeafNode();
-        if (isValueNumberableLeaf) {
-            Node otherNode = into.findNodeInCache(this);
-            if (otherNode != null) {
-                return otherNode;
+        boolean useIntoLeafNodeCache = false;
+        if (into != null) {
+            if (nodeClass.valueNumberable() && nodeClass.isLeafNode()) {
+                useIntoLeafNodeCache = true;
+                Node otherNode = into.findNodeInCache(this);
+                if (otherNode != null) {
+                    return otherNode;
+                }
             }
         }
 
@@ -801,10 +805,12 @@
         }
         newNode.graph = into;
         newNode.id = INITIAL_ID;
-        into.register(newNode);
+        if (into != null) {
+            into.register(newNode);
+        }
         newNode.extraUsages = NO_NODES;
 
-        if (isValueNumberableLeaf) {
+        if (into != null && useIntoLeafNodeCache) {
             into.putNodeIntoCache(newNode);
         }
         newNode.afterClone(this);
@@ -1031,7 +1037,7 @@
      *
      * Overridden by a method generated for leaf nodes.
      */
-    protected int valueNumberLeaf() {
+    public int valueNumberLeaf() {
         assert !getNodeClass().isLeafNode();
         return 0;
     }
@@ -1042,7 +1048,7 @@
      * @param other
      */
     protected boolean dataEquals(Node other) {
-        return true;
+        throw GraalInternalError.shouldNotReachHere();
     }
 
     /**