public abstract class Node extends Object implements Cloneable, Formattable
Graph
.
Once a node has been added to a graph, it has a graph-unique id()
. Edges in the
subclasses are represented with annotated fields. There are two kind of edges : Node.Input
and
Node.Successor
. If a field, of a type compatible with Node
, annotated with either
Node.Input
and Node.Successor
is not null, then there is an edge from this node to the node
this field points to.
Nodes which are be value numberable should implement the Node.ValueNumberable
interface.
newSet()
newSet(Collection)
newMap()
newMap(int)
newMap(Map)
newIdentityMap()
newIdentityMap(int)
newIdentityMap(Map)
assertTrue(boolean, String, Object...)
and
assertFalse(boolean, String, Object...)
methods, which will check the supplied boolean
and throw a VerificationError if it has the wrong value. Both methods will always either throw an
exception or return true. They can thus be used within an assert statement, so that the check is
only performed if assertions are enabled.Modifier and Type | Class and Description |
---|---|
static interface |
Node.ConstantNodeParameter
Denotes that a parameter of an intrinsic method must be a compile
time constant at all call sites to the intrinsic method.
|
static interface |
Node.InjectedNodeParameter
Denotes an injected parameter in a node intrinsic constructor.
|
static interface |
Node.Input
Denotes a non-optional (non-null) node input.
|
static interface |
Node.NodeIntrinsic
Annotates a method that can be replaced by a compiler intrinsic.
|
static interface |
Node.OptionalInput
Denotes an optional (nullable) node input.
|
static interface |
Node.Successor |
static interface |
Node.ValueNumberable
Marker for a node that can be replaced by another node via global value numbering.
|
Modifier and Type | Field and Description |
---|---|
(package private) static int |
ALIVE_ID_START |
(package private) static int |
DELETED_ID_START |
(package private) Node[] |
extraUsages |
(package private) int |
extraUsagesCount |
private Graph |
graph |
(package private) int |
id |
(package private) static int |
INITIAL_ID |
(package private) static int |
INLINE_USAGE_COUNT |
private static Node[] |
NO_NODES |
static int |
NODE_LIST |
private NodeClass<? extends Node> |
nodeClass |
static int |
NOT_ITERABLE |
private Node |
predecessor |
static NodeClass<?> |
TYPE |
(package private) Node |
typeCacheNext |
(package private) Node |
usage0
Head of usage list.
|
(package private) Node |
usage1 |
static boolean |
USE_UNSAFE_TO_CLONE |
static EnumSet<Edges.Type> |
WithAllEdges |
static EnumSet<Edges.Type> |
WithNoEdges |
static EnumSet<Edges.Type> |
WithOnlyInputEdges |
static EnumSet<Edges.Type> |
WithOnlySucessorEdges |
Modifier and Type | Method and Description |
---|---|
void |
acceptInputs(BiConsumer<Node,Node> consumer)
Applies the given consumer to all inputs of this node.
|
void |
acceptSuccessors(BiConsumer<Node,Node> consumer)
Applies the given consumer to all successors of this node.
|
private void |
addUsage(Node node)
Adds a given node to this node's usages.
|
protected void |
afterClone(Node other) |
boolean |
assertFalse(boolean condition,
String message,
Object... args) |
boolean |
assertTrue(boolean condition,
String message,
Object... args) |
Iterable<? extends Node> |
cfgPredecessors() |
Iterable<? extends Node> |
cfgSuccessors()
Returns an iterator that will provide all control-flow successors of this node.
|
private boolean |
checkDeletion() |
private boolean |
checkReplaceWith(Node other) |
void |
clearInputs() |
void |
clearSuccessors() |
(package private) Node |
clone(Graph into,
EnumSet<Edges.Type> edgesToCopy)
Makes a copy of this node in(to) a given graph.
|
private void |
copyOrClearEdgesForClone(Node newNode,
Edges.Type type,
EnumSet<Edges.Type> edgesToCopy) |
Node |
copyWithInputs() |
Node |
copyWithInputs(boolean insertIntoGraph) |
boolean |
equals(Object obj)
Equality tests must rely solely on identity.
|
protected VerificationError |
fail(String message,
Object... args) |
void |
formatTo(Formatter formatter,
int flags,
int width,
int precision) |
Map<Object,Object> |
getDebugProperties()
Provides a
Map of properties of this node for use in debugging (e.g., to view in the
ideal graph visualizer). |
Map<Object,Object> |
getDebugProperties(Map<Object,Object> map)
Fills a
Map with properties of this node for use in debugging (e.g., to view in the
ideal graph visualizer). |
int |
getId()
Deprecated.
|
NodeClass<? extends Node> |
getNodeClass() |
Node |
getUsageAt(int index) |
int |
getUsageCount()
Gets the maximum number of usages this node has had at any point in time.
|
Graph |
graph()
Gets the graph context of this node.
|
int |
hashCode()
Nodes always use an identity hash code.
|
boolean |
hasNoUsages()
Checks whether this node has no usages.
|
boolean |
hasUsages()
Checks whether this node has usages.
|
(package private) int |
id() |
(package private) void |
incModCount() |
(package private) void |
incUsageModCount() |
(package private) void |
init(NodeClass<? extends Node> c) |
(package private) void |
initialize(Graph newGraph) |
NodeClassIterable |
inputs()
Returns an
iterable which can be used to traverse all non-null
input edges of this node. |
boolean |
isAlive() |
boolean |
isAllowedUsageType(InputType type) |
boolean |
isDeleted() |
void |
markDeleted() |
private void |
maybeNotifyInputChanged(Node node) |
private void |
maybeNotifyZeroUsages(Node node) |
int |
modCount() |
private void |
movUsageFromEndTo(int destIndex) |
static <K extends Node,V> |
newIdentityMap() |
static <K extends Node,V> |
newIdentityMap(int expectedMaxSize) |
static <K extends Node,V> |
newIdentityMap(Map<K,V> m) |
static <K extends Node,V> |
newMap() |
static <K extends Node,V> |
newMap(int expectedMaxSize) |
static <K extends Node,V> |
newMap(Map<K,V> m) |
static <E extends Node> |
newSet() |
static <E extends Node> |
newSet(Collection<? extends E> c) |
Node |
predecessor() |
void |
pushInputs(NodeStack stack) |
private boolean |
removeThisFromUsages(Node n) |
boolean |
removeUsage(Node node)
Removes a given node from this node's usages.
|
void |
replaceAndDelete(Node other) |
void |
replaceAtMatchingUsages(Node other,
NodePredicate usagePredicate) |
void |
replaceAtPredecessor(Node other) |
void |
replaceAtUsages(InputType type,
Node other) |
void |
replaceAtUsages(Node other) |
void |
replaceAtUsages(Node other,
Predicate<Node> filter) |
void |
replaceFirstInput(Node oldInput,
Node newInput) |
void |
replaceFirstSuccessor(Node oldSuccessor,
Node newSuccessor) |
(package private) void |
reverseUsageOrder() |
void |
safeDelete()
Removes this node from its graph.
|
void |
simplify(SimplifierTool tool)
Must be overridden by subclasses that implement
Simplifiable . |
NodeClassIterable |
successors()
Returns an
iterable which can be used to traverse all non-null
successor edges of this node. |
String |
toString()
This method is a shortcut for
toString(Verbosity) with Verbosity.Short . |
String |
toString(Verbosity verbosity)
Creates a String representation for this node with a given
Verbosity . |
private void |
unregisterInputs() |
private void |
unregisterSuccessors() |
protected void |
updatePredecessor(Node oldSuccessor,
Node newSuccessor)
Updates the predecessor of the given nodes after a successor slot is changed from
oldSuccessor to newSuccessor: removes this node from oldSuccessor's predecessors and adds
this node to newSuccessor's predecessors.
|
protected void |
updateUsages(Node oldInput,
Node newInput)
Updates the usages sets of the given nodes after an input slot is changed from
oldInput to newInput by removing this node from oldInput 's usages and
adds this node to newInput 's usages. |
protected void |
updateUsagesInterface(NodeInterface oldInput,
NodeInterface newInput) |
(package private) int |
usageModCount() |
NodeIterable<Node> |
usages()
Gets the list of nodes that use this node (i.e., as an input).
|
boolean |
valueEquals(Node other)
Determines if this node's
data fields are equal to the data
fields of another node of the same type. |
boolean |
verify() |
boolean |
verifyEdges()
Perform expensive verification of inputs, usages, predecessors and successors.
|
boolean |
verifyInputs() |
public static final boolean USE_UNSAFE_TO_CLONE
static final int DELETED_ID_START
static final int INITIAL_ID
static final int ALIVE_ID_START
int id
Node typeCacheNext
static final int INLINE_USAGE_COUNT
Node usage0
usage0
,
usage1
and extraUsages
. The first null entry terminates the list.Node[] extraUsages
int extraUsagesCount
private Node predecessor
public static final int NODE_LIST
public static final int NOT_ITERABLE
public static final EnumSet<Edges.Type> WithNoEdges
public static final EnumSet<Edges.Type> WithAllEdges
public static final EnumSet<Edges.Type> WithOnlyInputEdges
public static final EnumSet<Edges.Type> WithOnlySucessorEdges
int id()
public static <E extends Node> Set<E> newSet()
CollectionsFactory.newSet()
public static <E extends Node> Set<E> newSet(Collection<? extends E> c)
newSet()
public static <K extends Node,V> Map<K,V> newIdentityMap()
public static <K extends Node,V> Map<K,V> newIdentityMap(Map<K,V> m)
public static <K extends Node,V> Map<K,V> newIdentityMap(int expectedMaxSize)
public NodeClassIterable inputs()
iterable
which can be used to traverse all non-null
input edges of this node.iterable
for all non-null input edges.public void acceptInputs(BiConsumer<Node,Node> consumer)
consumer
- the consumer to be applied to the inputspublic NodeClassIterable successors()
iterable
which can be used to traverse all non-null
successor edges of this node.iterable
for all non-null successor edges.public void acceptSuccessors(BiConsumer<Node,Node> consumer)
consumer
- the consumer to be applied to the inputspublic int getUsageCount()
public final NodeIterable<Node> usages()
public final boolean hasNoUsages()
public final boolean hasUsages()
void reverseUsageOrder()
private void addUsage(Node node)
node
- the node to addprivate void movUsageFromEndTo(int destIndex)
public boolean removeUsage(Node node)
node
- the node to removeusage
was in the usage listpublic final Node predecessor()
public final int modCount()
final void incModCount()
final int usageModCount()
final void incUsageModCount()
public boolean isDeleted()
public boolean isAlive()
protected void updateUsages(Node oldInput, Node newInput)
oldInput
to newInput
by removing this node from oldInput
's usages and
adds this node to newInput
's usages.protected void updateUsagesInterface(NodeInterface oldInput, NodeInterface newInput)
protected void updatePredecessor(Node oldSuccessor, Node newSuccessor)
void initialize(Graph newGraph)
public final NodeClass<? extends Node> getNodeClass()
public boolean isAllowedUsageType(InputType type)
private boolean checkReplaceWith(Node other)
public final void replaceAtUsages(Node other)
public final void replaceAtUsages(Node other, Predicate<Node> filter)
public Node getUsageAt(int index)
public void replaceAtMatchingUsages(Node other, NodePredicate usagePredicate)
public void replaceAtUsages(InputType type, Node other)
private void maybeNotifyInputChanged(Node node)
private void maybeNotifyZeroUsages(Node node)
public void replaceAtPredecessor(Node other)
public void replaceAndDelete(Node other)
public void replaceFirstSuccessor(Node oldSuccessor, Node newSuccessor)
public void replaceFirstInput(Node oldInput, Node newInput)
private void unregisterInputs()
public void clearInputs()
private boolean removeThisFromUsages(Node n)
private void unregisterSuccessors()
public void clearSuccessors()
private boolean checkDeletion()
public void safeDelete()
public void markDeleted()
public final Node copyWithInputs()
public final Node copyWithInputs(boolean insertIntoGraph)
public void simplify(SimplifierTool tool)
Simplifiable
. The implementation in
Node
exists to obviate the need to cast a node before invoking
Simplifiable.simplify(SimplifierTool)
.tool
- private void copyOrClearEdgesForClone(Node newNode, Edges.Type type, EnumSet<Edges.Type> edgesToCopy)
newNode
- the result of cloning this node or raw
allocating
a copy of this nodetype
- the type of edges to processedgesToCopy
- if type
is in this set, the edges are copied otherwise they are
clearedfinal Node clone(Graph into, EnumSet<Edges.Type> edgesToCopy)
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 graphedgesToCopy
- specifies the edges to be copied. The edges not specified in this set are
initialized to their default value (i.e., null
for a direct edge, an empty
list for an edge list)protected void afterClone(Node other)
public boolean verifyInputs()
public boolean verify()
public boolean verifyEdges()
public boolean assertTrue(boolean condition, String message, Object... args)
public boolean assertFalse(boolean condition, String message, Object... args)
protected VerificationError fail(String message, Object... args) throws GraalGraphJVMCIError
GraalGraphJVMCIError
public Iterable<? extends Node> cfgPredecessors()
public Iterable<? extends Node> cfgSuccessors()
public final Map<Object,Object> getDebugProperties()
Map
of properties of this node for use in debugging (e.g., to view in the
ideal graph visualizer).public Map<Object,Object> getDebugProperties(Map<Object,Object> map)
Map
with properties of this node for use in debugging (e.g., to view in the
ideal graph visualizer). Subclasses overriding this method should also fill the map using
their superclass.map
- public final String toString()
toString(Verbosity)
with Verbosity.Short
.public String toString(Verbosity verbosity)
Verbosity
.@Deprecated public int getId()
public void formatTo(Formatter formatter, int flags, int width, int precision)
formatTo
in interface Formattable
public boolean valueEquals(Node other)
data
fields are equal to the data
fields of another node of the same type. Primitive fields are compared by value and
non-primitive fields are compared by Objects.equals(Object, Object)
.
The result of this method undefined if other.getClass() != this.getClass()
.other
- a node of exactly the same type as this nodeother
are equalpublic final void pushInputs(NodeStack stack)