public class GraphUtil extends Object
| Modifier and Type | Class and Description |
|---|---|
static class |
GraphUtil.Options |
| Modifier and Type | Field and Description |
|---|---|
static int |
MAX_FRAMESTATE_SEARCH_DEPTH |
| Constructor and Description |
|---|
GraphUtil() |
| Modifier and Type | Method and Description |
|---|---|
static RuntimeException |
approxSourceException(Node node,
Throwable cause)
Gets an approximate source code location for a node, encoded as an exception, if possible.
|
static String |
approxSourceLocation(Node node)
Gets an approximate source code location for a node if possible.
|
static StackTraceElement[] |
approxSourceStackTraceElement(BytecodePosition bytecodePosition)
Gets approximate stack trace elements for a bytecode position.
|
static StackTraceElement[] |
approxSourceStackTraceElement(FrameState frameState)
Gets an approximate source code location for frame state.
|
static StackTraceElement[] |
approxSourceStackTraceElement(Node node)
Gets an approximate source code location for a node if possible.
|
static ValueNode |
arrayLength(ValueNode value,
ArrayLengthProvider.FindLengthMode mode,
ConstantReflectionProvider constantReflection)
Returns the length of the array described by the value parameter, or null if it is not
available.
|
static boolean |
checkFrameState(FixedNode start,
int maxDepth)
Snippet lowerings may produce patterns without a frame state on the merge.
|
static void |
checkRedundantPhi(PhiNode phiNode) |
static void |
checkRedundantProxy(ProxyNode vpn) |
static BailoutException |
createBailoutException(String message,
Throwable cause,
StackTraceElement[] elements)
Creates a bailout exception with the given stack trace elements and message.
|
static FrameState |
findLastFrameState(FixedNode start)
Find the last, i.e.
|
static Constant |
foldIfConstantAndRemove(ValueNode node,
ValueNode constant) |
static SimplifierTool |
getDefaultSimplifier(CoreProviders providers,
boolean canonicalizeReads,
Assumptions assumptions,
OptionValues options) |
static boolean |
isFloatingNode(Node n) |
static void |
killCFG(FixedNode node) |
static void |
killWithUnusedFloatingInputs(Node node) |
static void |
killWithUnusedFloatingInputs(Node node,
boolean mayKillGuard) |
static boolean |
mayRemoveSplit(IfNode ifNode) |
static void |
normalizeLoops(StructuredGraph graph)
Remove loop header without loop ends.
|
static ValueNode |
originalValue(ValueNode value,
boolean abortOnLoopPhi)
Tries to find an original value of the given node by traversing through proxies and
unambiguous phis.
|
static NodeIterable<FixedNode> |
predecessorIterable(FixedNode start)
Returns an iterator that will return the given node followed by all its predecessors, up
until the point where
Node.predecessor() returns null. |
static void |
removeFixedWithUnusedInputs(FixedWithNextNode fixed) |
static void |
removeNewNodes(Graph graph,
Graph.Mark mark)
Removes all nodes created after the
mark, assuming no "old" nodes point to "new"
nodes. |
static ValueNode |
skipPi(ValueNode node) |
static ValueNode |
skipPiWhileNonNullArray(ValueNode node) |
static String |
toString(Iterable<?> objects)
Returns a string representation of the given collection of objects.
|
static boolean |
tryKillUnused(Node node) |
static LoopEndNode |
tryToTransformToEmptyLoopDiamond(IfNode ifNode,
LoopBeginNode loopBegin)
An if node with an empty body at the end of a loop is represented with a
LoopEndNode
at the end of each path. |
static void |
unlinkAndKillExceptionEdge(WithExceptionNode withException) |
static void |
unlinkFixedNode(FixedWithNextNode fixed) |
static ValueNode |
unproxify(ValueNode value)
Gets the original value by iterating through all
ValueProxies. |
static ValueNode |
unproxify(ValueProxy value)
Gets the original value by iterating through all
ValueProxies. |
static void |
virtualizeArrayCopy(VirtualizerTool tool,
ValueNode source,
ValueNode sourceLength,
ValueNode newLength,
ValueNode from,
ResolvedJavaType newComponentType,
JavaKind elementKind,
StructuredGraph graph,
BiFunction<ResolvedJavaType,Integer,VirtualArrayNode> virtualArrayProvider)
Virtualize an array copy.
|
public static final int MAX_FRAMESTATE_SEARCH_DEPTH
public static void killCFG(FixedNode node)
public static boolean isFloatingNode(Node n)
public static void killWithUnusedFloatingInputs(Node node)
public static void killWithUnusedFloatingInputs(Node node, boolean mayKillGuard)
public static void removeNewNodes(Graph graph, Graph.Mark mark)
mark, assuming no "old" nodes point to "new"
nodes.public static void removeFixedWithUnusedInputs(FixedWithNextNode fixed)
public static void unlinkFixedNode(FixedWithNextNode fixed)
public static void unlinkAndKillExceptionEdge(WithExceptionNode withException)
public static void checkRedundantPhi(PhiNode phiNode)
public static void checkRedundantProxy(ProxyNode vpn)
public static void normalizeLoops(StructuredGraph graph)
for (;;) {
try {
break;
} catch (UnresolvedException iioe) {
}
}
public static StackTraceElement[] approxSourceStackTraceElement(Node node)
public static StackTraceElement[] approxSourceStackTraceElement(FrameState frameState)
public static StackTraceElement[] approxSourceStackTraceElement(BytecodePosition bytecodePosition)
public static RuntimeException approxSourceException(Node node, Throwable cause)
public static BailoutException createBailoutException(String message, Throwable cause, StackTraceElement[] elements)
message - the message of the exceptionelements - the stack trace elementspublic static String approxSourceLocation(Node node)
public static String toString(Iterable<?> objects)
objects - The Iterable that will be used to iterate over the objects.public static ValueNode unproxify(ValueNode value)
ValueProxies.value - the start value.public static ValueNode unproxify(ValueProxy value)
ValueProxies.value - the start value proxy.public static ValueNode arrayLength(ValueNode value, ArrayLengthProvider.FindLengthMode mode, ConstantReflectionProvider constantReflection)
ArrayLengthProvider.FindLengthMode.value - The start value.mode - The mode as documented in ArrayLengthProvider.FindLengthMode.public static ValueNode originalValue(ValueNode value, boolean abortOnLoopPhi)
value - the node whose original value should be determinedabortOnLoopPhi - specifies if the traversal through phis should stop and return
value if it hits a loop phi. This argument
must be true if used during graph building as loop phi nodes may not yet
have all their inputs computed.value itself)public static boolean tryKillUnused(Node node)
public static NodeIterable<FixedNode> predecessorIterable(FixedNode start)
Node.predecessor() returns null.start - the node at which to start iteratingpublic static SimplifierTool getDefaultSimplifier(CoreProviders providers, boolean canonicalizeReads, Assumptions assumptions, OptionValues options)
public static Constant foldIfConstantAndRemove(ValueNode node, ValueNode constant)
public static void virtualizeArrayCopy(VirtualizerTool tool, ValueNode source, ValueNode sourceLength, ValueNode newLength, ValueNode from, ResolvedJavaType newComponentType, JavaKind elementKind, StructuredGraph graph, BiFunction<ResolvedJavaType,Integer,VirtualArrayNode> virtualArrayProvider)
tool - the virtualization toolsource - the source arraysourceLength - the length of the source arraynewLength - the length of the new arrayfrom - the start index in the source arraynewComponentType - the component type of the new arrayelementKind - the kind of the new array elementsgraph - the node graphvirtualArrayProvider - a functional provider that returns a new virtual array given the
component type and lengthpublic static boolean checkFrameState(FixedNode start, int maxDepth)
public static boolean mayRemoveSplit(IfNode ifNode)
public static LoopEndNode tryToTransformToEmptyLoopDiamond(IfNode ifNode, LoopBeginNode loopBegin)
LoopEndNode
at the end of each path. For some optimizations it is more useful to have a representation of
the if statement as a proper diamond with a merge after the two bodies, followed by a
LoopEndNode. This method tries to transform the given ifNode into such a
form, introducing new phi nodes for the diamond and patching up the loop's phis accordingly.
On success, the newly introduced loop end node is returned. If the given ifNode is
not an if statement with empty bodies at the end of the loop, the graph is not modified, and
null is returned.
Note that the diamond representation is not canonical and will be undone by the next
application of AbstractMergeNode.simplify(SimplifierTool) to the merge.public static FrameState findLastFrameState(FixedNode start)
StateSplit node that returns true for
StateSplit.hasSideEffect() and return its StateSplit.stateAfter(). That is
the FrameState node describing the current frame since no side
effect happened in between.
This method will check Graal's invariant relations regarding side-effects and framestates.