public class Graph extends Object
Modifier and Type | Class and Description |
---|---|
private static class |
Graph.CacheEntry
Entry in
cachedLeafNodes . |
private static class |
Graph.ChainedNodeEventListener |
static interface |
Graph.DuplicationReplacement |
private static class |
Graph.MapReplacement |
static class |
Graph.Mark
A snapshot of the live node count in a graph.
|
static class |
Graph.NodeEvent
The type of events sent to a
Graph.NodeEventListener . |
static interface |
Graph.NodeEventListener
Client interested in one or more node related events.
|
class |
Graph.NodeEventScope
Registers a given
Graph.NodeEventListener with the enclosing graph until this object is
closed. |
static class |
Graph.Options |
(package private) static class |
Graph.PlaceHolderNode |
Modifier and Type | Field and Description |
---|---|
private HashMap<Graph.CacheEntry,Node> |
cachedLeafNodes
Used to global value number
Node.ValueNumberable leaf
nodes. |
static int |
COMPRESSION_THRESHOLD
When the percent of live nodes in
nodes fall below this number, a call to
maybeCompress() will actually do compression. |
(package private) int |
compressions
The number of times this graph has been compressed.
|
private static DebugTimer |
DuplicateGraph |
private static DebugMetric |
GraphCompressions |
private static int |
INITIAL_NODES_SIZE |
private boolean |
isFrozen |
private ArrayList<Node> |
iterableNodesFirst |
private ArrayList<Node> |
iterableNodesLast |
static boolean |
MODIFICATION_COUNTS_ENABLED |
String |
name |
(package private) Graph.NodeEventListener |
nodeEventListener |
private int[] |
nodeModCounts
Records the modification count for nodes.
|
(package private) Node[] |
nodes
The set of nodes in the graph, ordered by registration time.
|
private int |
nodesDeletedBeforeLastCompression |
private int |
nodesDeletedSinceLastCompression |
(package private) int |
nodesSize
The number of valid entries in
nodes . |
private int[] |
nodeUsageModCounts
Records the modification count for nodes' usage lists.
|
(package private) static Node |
PLACE_HOLDER |
Constructor and Description |
---|
Graph()
Creates an empty Graph with no name.
|
Graph(String name)
Creates an empty Graph with a given name.
|
Modifier and Type | Method and Description |
---|---|
<T extends Node> |
add(T node)
Adds a new node to the graph.
|
Map<Node,Node> |
addDuplicates(Iterable<? extends Node> newNodes,
Graph oldGraph,
int estimatedNodeCount,
Graph.DuplicationReplacement replacements) |
Map<Node,Node> |
addDuplicates(Iterable<? extends Node> newNodes,
Graph oldGraph,
int estimatedNodeCount,
Map<Node,Node> replacementsMap)
Adds duplicates of the nodes in
nodes to this graph. |
private <T extends Node> |
addHelper(T node) |
private <T extends Node> |
addInputs(T node) |
<T extends Node> |
addOrUnique(T node) |
<T extends Node> |
addOrUniqueWithInputs(T node) |
<T extends Node> |
addWithoutUnique(T node) |
<T extends Node> |
addWithoutUniqueWithInputs(T node) |
private static boolean |
assertionsEnabled()
Determines if assertions are enabled for the
Graph class. |
Graph |
copy()
Creates a copy of this graph.
|
Graph |
copy(Consumer<Map<Node,Node>> duplicationMapCallback)
Creates a copy of this graph.
|
Graph |
copy(String newName)
Creates a copy of this graph.
|
protected Graph |
copy(String newName,
Consumer<Map<Node,Node>> duplicationMapCallback)
Creates a copy of this graph.
|
NodeWorkList |
createIterativeNodeWorkList(boolean fill,
int iterationLimitPerNode) |
NodeBitMap |
createNodeBitMap() |
NodeFlood |
createNodeFlood() |
<T> NodeMap<T> |
createNodeMap() |
NodeWorkList |
createNodeWorkList() |
(package private) int |
extractOriginalNodeId(Node node) |
<T extends Node> |
findDuplicate(T node) |
private Node |
findFirstLiveIterable(int iterableId,
Node node) |
private Node |
findNextLiveiterable(Node start) |
(package private) Node |
findNodeInCache(Node node) |
void |
freeze() |
int |
getCompressions()
Gets the number of times this graph has been compressed.
|
(package private) Node |
getIterableNodeNext(Node node) |
(package private) Node |
getIterableNodeStart(int iterableId) |
Graph.Mark |
getMark()
Gets a mark that can be used with
getNewNodes(com.oracle.graal.graph.Graph.Mark) . |
NodeIterable<Node> |
getNewNodes(Graph.Mark mark)
|
Node |
getNode(int id) |
int |
getNodeCount()
Gets the number of live nodes in this graph.
|
NodeIterable<Node> |
getNodes()
Returns an
Iterable providing all the live nodes. |
<T extends Node & IterableNodeType> |
getNodes(NodeClass<T> nodeClass)
Returns an
Iterable providing all the live nodes whose type is compatible with
type . |
int |
getNodesDeletedSinceLastCompression()
Gets the number of nodes which have been deleted from this graph since it was last
compressed.
|
int |
getTotalNodesDeleted()
Gets the total number of nodes which have been deleted from this graph.
|
<T extends Node & IterableNodeType> |
hasNode(NodeClass<T> type)
Returns whether the graph contains at least one node of the given type.
|
(package private) void |
incModCount(Node node) |
(package private) void |
incUsageModCount(Node node) |
boolean |
isFrozen() |
boolean |
isNew(Graph.Mark mark,
Node node) |
boolean |
maybeCompress()
If the compression threshold is met, the list of nodes is
compressed such that all non-null entries precede all null entries while preserving the
ordering between the nodes within the list.
|
(package private) int |
modCount(Node node) |
(package private) int |
nodeIdCount()
Returns the number of node ids generated so far.
|
private void |
postDeserialization() |
(package private) void |
putNodeIntoCache(Node node) |
private void |
recomputeIterableNodeLists()
Rebuilds the lists used to support
getNodes(NodeClass) . |
(package private) void |
register(Node node) |
void |
reverseUsageOrder()
Reverses the usage orders of all nodes.
|
String |
toString() |
Graph.NodeEventScope |
trackNodeEvents(Graph.NodeEventListener listener)
Registers a given
Graph.NodeEventListener with this graph. |
<T extends Node & Node.ValueNumberable> |
unique(T node)
Looks for a node similar to
node and returns it if found. |
(package private) <T extends Node> |
uniqueHelper(T node,
boolean addIfMissing) |
(package private) void |
unregister(Node node) |
private void |
updateNodeCaches(Node node) |
(package private) int |
usageModCount(Node node) |
boolean |
verify() |
Node[] nodes
private int[] nodeModCounts
private int[] nodeUsageModCounts
private final ArrayList<Node> iterableNodesFirst
private final ArrayList<Node> iterableNodesLast
private int nodesDeletedSinceLastCompression
private int nodesDeletedBeforeLastCompression
int compressions
Graph.NodeEventListener nodeEventListener
private final HashMap<Graph.CacheEntry,Node> cachedLeafNodes
Node.ValueNumberable
leaf
nodes.private boolean isFrozen
public static final boolean MODIFICATION_COUNTS_ENABLED
private static final int INITIAL_NODES_SIZE
static final Node PLACE_HOLDER
public static final int COMPRESSION_THRESHOLD
nodes
fall below this number, a call to
maybeCompress()
will actually do compression.private static final DebugMetric GraphCompressions
private static final DebugTimer DuplicateGraph
public Graph()
private static boolean assertionsEnabled()
Graph
class.int extractOriginalNodeId(Node node)
void incModCount(Node node)
int usageModCount(Node node)
void incUsageModCount(Node node)
public final Graph copy(Consumer<Map<Node,Node>> duplicationMapCallback)
duplicationMapCallback
- consumer of the duplication map created during the copyingpublic final Graph copy(String newName)
newName
- the name of the copy, used for debugging purposes (can be null)protected Graph copy(String newName, Consumer<Map<Node,Node>> duplicationMapCallback)
newName
- the name of the copy, used for debugging purposes (can be null)duplicationMapCallback
- consumer of the duplication map created during the copyingpublic int getNodeCount()
public int getCompressions()
NodeIdAccessor
.public int getNodesDeletedSinceLastCompression()
public int getTotalNodesDeleted()
public <T extends Node> T add(T node)
node
- the node to be addedpublic <T extends Node> T addWithoutUnique(T node)
public <T extends Node> T addOrUnique(T node)
public <T extends Node> void addWithoutUniqueWithInputs(T node)
public <T extends Node> T addOrUniqueWithInputs(T node)
public Graph.NodeEventScope trackNodeEvents(Graph.NodeEventListener listener)
Graph.NodeEventListener
with this graph. This should be used in
conjunction with try-with-resources statement as follows:
try (NodeEventScope nes = graph.trackNodeEvents(listener)) { // make changes to the graph }
public <T extends Node & Node.ValueNumberable> T unique(T node)
node
and returns it if found. Otherwise
node
is added to this graph and returned.node
if one exists, otherwise node
<T extends Node> T uniqueHelper(T node, boolean addIfMissing)
void putNodeIntoCache(Node node)
Node findNodeInCache(Node node)
public <T extends Node> T findDuplicate(T node)
public boolean isNew(Graph.Mark mark, Node node)
public Graph.Mark getMark()
getNewNodes(com.oracle.graal.graph.Graph.Mark)
.public NodeIterable<Node> getNewNodes(Graph.Mark mark)
public NodeIterable<Node> getNodes()
Iterable
providing all the live nodes.Iterable
providing all the live nodes.public boolean maybeCompress()
public <T extends Node & IterableNodeType> NodeIterable<T> getNodes(NodeClass<T> nodeClass)
Iterable
providing all the live nodes whose type is compatible with
type
.nodeClass
- the type of node to returnIterable
providing all the matching nodespublic <T extends Node & IterableNodeType> boolean hasNode(NodeClass<T> type)
type
- the type of node that is checked for occurrenceNode getIterableNodeStart(int iterableId)
iterableId
- private Node findFirstLiveIterable(int iterableId, Node node)
Node getIterableNodeNext(Node node)
node
- node
private Node findNextLiveiterable(Node start)
public NodeBitMap createNodeBitMap()
public <T> NodeMap<T> createNodeMap()
public NodeFlood createNodeFlood()
public NodeWorkList createNodeWorkList()
public NodeWorkList createIterativeNodeWorkList(boolean fill, int iterationLimitPerNode)
private void postDeserialization()
private void recomputeIterableNodeLists()
getNodes(NodeClass)
. This is useful for
serialization where the underlying iterable ids may have
changed.private void updateNodeCaches(Node node)
void unregister(Node node)
public boolean verify()
int nodeIdCount()
public Map<Node,Node> addDuplicates(Iterable<? extends Node> newNodes, Graph oldGraph, int estimatedNodeCount, Map<Node,Node> replacementsMap)
nodes
to this graph. This will recreate any edges
between the duplicate nodes. The replacement
map can be used to replace a node from
the source graph by a given node (which must already be in this graph). Edges between
duplicate and replacement nodes will also be recreated so care should be taken regarding the
matching of node types in the replacement map.newNodes
- the nodes to be duplicatedreplacementsMap
- the replacement map (can be null if no replacement is to be performed)nodes
to their duplicatespublic Map<Node,Node> addDuplicates(Iterable<? extends Node> newNodes, Graph oldGraph, int estimatedNodeCount, Graph.DuplicationReplacement replacements)
public void reverseUsageOrder()
public boolean isFrozen()
public void freeze()