Mercurial > hg > graal-jvmci-8
changeset 21423:fdf9166e575f
Add ability to receive the duplication map via a callback when copying a graph.
author | Thomas Wuerthinger <thomas.wuerthinger@oracle.com> |
---|---|
date | Tue, 19 May 2015 14:24:47 +0200 |
parents | 17bbd7cd6e29 |
children | fe76bf3867f3 |
files | graal/com.oracle.graal.graph/src/com/oracle/graal/graph/CachedGraph.java graal/com.oracle.graal.graph/src/com/oracle/graal/graph/Graph.java |
diffstat | 2 files changed, 30 insertions(+), 4 deletions(-) [+] |
line wrap: on
line diff
--- a/graal/com.oracle.graal.graph/src/com/oracle/graal/graph/CachedGraph.java Tue May 19 14:00:11 2015 +0200 +++ b/graal/com.oracle.graal.graph/src/com/oracle/graal/graph/CachedGraph.java Tue May 19 14:24:47 2015 +0200 @@ -22,6 +22,9 @@ */ package com.oracle.graal.graph; +import java.util.*; +import java.util.function.*; + /** * This class is a container of a graph that needs to be readonly and optionally a lazily created * mutable copy of the graph. @@ -39,9 +42,9 @@ return readonlyCopy; } - public Graph getMutableCopy() { + public Graph getMutableCopy(Consumer<Map<Node, Node>> duplicationMapCallback) { if (mutableCopy == null) { - mutableCopy = readonlyCopy.copy(); + mutableCopy = readonlyCopy.copy(duplicationMapCallback); } return mutableCopy; }
--- a/graal/com.oracle.graal.graph/src/com/oracle/graal/graph/Graph.java Tue May 19 14:00:11 2015 +0200 +++ b/graal/com.oracle.graal.graph/src/com/oracle/graal/graph/Graph.java Tue May 19 14:24:47 2015 +0200 @@ -25,6 +25,7 @@ import static com.oracle.graal.graph.Edges.Type.*; import java.util.*; +import java.util.function.*; import com.oracle.graal.compiler.common.*; import com.oracle.graal.debug.*; @@ -220,7 +221,16 @@ * Creates a copy of this graph. */ public Graph copy() { - return copy(name); + return copy(name, null); + } + + /** + * Creates a copy of this graph. + * + * @param duplicationMapCallback consumer of the duplication map created during the copying + */ + public Graph copy(Consumer<Map<Node, Node>> duplicationMapCallback) { + return copy(name, duplicationMapCallback); } /** @@ -229,8 +239,21 @@ * @param newName the name of the copy, used for debugging purposes (can be null) */ public Graph copy(String newName) { + return copy(newName, null); + } + + /** + * Creates a copy of this graph. + * + * @param newName the name of the copy, used for debugging purposes (can be null) + * @param duplicationMapCallback consumer of the duplication map created during the copying + */ + public Graph copy(String newName, Consumer<Map<Node, Node>> duplicationMapCallback) { Graph copy = new Graph(newName); - copy.addDuplicates(getNodes(), this, this.getNodeCount(), (Map<Node, Node>) null); + Map<Node, Node> duplicates = copy.addDuplicates(getNodes(), this, this.getNodeCount(), (Map<Node, Node>) null); + if (duplicationMapCallback != null) { + duplicationMapCallback.accept(duplicates); + } return copy; }