# HG changeset patch # User Doug Simon # Date 1412599754 -7200 # Node ID 63780e37b7b9d5d9d845464e3a955bc39b77f448 # Parent 97198814de417ceeb61e5b3aa4c9314c20211556 re-added support for cloning a node without adding it to a graph diff -r 97198814de41 -r 63780e37b7b9 graal/com.oracle.graal.graph/src/com/oracle/graal/graph/Node.java --- 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 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(); } /**