public class GraphDecoder extends Object
encoded graphs produced by GraphEncoder. Support for
loop explosion during decoding is built into this class, because it requires many interactions
with the decoding process. Subclasses can provide canonicalization and simplification of nodes
during decoding, as well as method inlining during decoding.| Modifier and Type | Class and Description |
|---|---|
protected static class |
GraphDecoder.InvokeData
Additional information encoded for
Invoke nodes to allow method inlining without
decoding the frame state and successors beforehand. |
protected static class |
GraphDecoder.LoopExplosionState |
protected static class |
GraphDecoder.LoopScope
Decoding state maintained for each loop in the encoded graph.
|
static class |
GraphDecoder.LoopScopeTrigger
Marker to distinguish the reasons for the creation of a loop scope during partial evaluation.
|
protected class |
GraphDecoder.MethodScope
Decoding state maintained for each encoded graph.
|
protected static class |
GraphDecoder.ProxyPlaceholder
A node that is created during
loop explosion that can
later be replaced by a ProxyNode if loop detection finds out that the
value is defined in the loop, but used outside the loop. |
| Modifier and Type | Field and Description |
|---|---|
protected Architecture |
architecture |
protected DebugContext |
debug |
static boolean |
DUMP_DURING_FIXED_NODE_PROCESSING |
protected StructuredGraph |
graph
The target graph where decoded nodes are added to.
|
protected OptionValues |
options |
| Constructor and Description |
|---|
GraphDecoder(Architecture architecture,
StructuredGraph graph) |
| Modifier and Type | Method and Description |
|---|---|
protected Node |
addFloatingNode(GraphDecoder.MethodScope methodScope,
Node node) |
protected void |
afterMethodScope(GraphDecoder.MethodScope methodScope) |
protected boolean |
allowLazyPhis() |
protected void |
appendInvoke(GraphDecoder.MethodScope methodScope,
GraphDecoder.LoopScope loopScope,
GraphDecoder.InvokeData invokeData,
CallTargetNode callTarget) |
protected void |
checkLoopExplosionIteration(GraphDecoder.MethodScope methodScope,
GraphDecoder.LoopScope loopScope)
Hook for subclasses.
|
protected void |
cleanupGraph(GraphDecoder.MethodScope methodScope)
Removes unnecessary nodes from the graph after decoding.
|
protected GraphDecoder.LoopScope |
createInitialLoopScope(GraphDecoder.MethodScope methodScope,
FixedWithNextNode startNode) |
void |
decode(EncodedGraph encodedGraph) |
void |
decode(EncodedGraph encodedGraph,
Iterable<EncodedGraph.EncodedNodeReference> nodeReferences) |
protected void |
decode(GraphDecoder.LoopScope initialLoopScope) |
protected Node |
decodeFloatingNode(GraphDecoder.MethodScope methodScope,
GraphDecoder.LoopScope loopScope,
int nodeOrderId)
Decodes a non-fixed node, but does not do any post-processing and does not register it.
|
protected boolean |
earlyCanonicalization(GraphDecoder.MethodScope methodScope,
GraphDecoder.LoopScope loopScope,
int nodeOrderId,
FixedNode node)
Hook for subclasses for early canonicalization of IfNodes and IntegerSwitchNodes.
|
protected Node |
ensureNodeCreated(GraphDecoder.MethodScope methodScope,
GraphDecoder.LoopScope loopScope,
int nodeOrderId) |
protected void |
finishInlining(GraphDecoder.MethodScope inlineScope) |
protected NodeClass<?> |
getNodeClass(GraphDecoder.MethodScope methodScope,
GraphDecoder.LoopScope loopScope,
int nodeOrderId) |
protected void |
handleFixedNode(GraphDecoder.MethodScope methodScope,
GraphDecoder.LoopScope loopScope,
int nodeOrderId,
FixedNode node)
Hook for subclasses.
|
protected Node |
handleFloatingNodeAfterAdd(GraphDecoder.MethodScope methodScope,
GraphDecoder.LoopScope loopScope,
Node node)
Hook for subclasses to process a non-fixed node after it is added to the graph.
|
protected Node |
handleFloatingNodeBeforeAdd(GraphDecoder.MethodScope methodScope,
GraphDecoder.LoopScope loopScope,
Node node)
Hook for subclasses to process a non-fixed node before it is added to the graph.
|
protected GraphDecoder.LoopScope |
handleInvoke(GraphDecoder.MethodScope methodScope,
GraphDecoder.LoopScope loopScope,
GraphDecoder.InvokeData invokeData)
|
protected void |
handleLoopExplosionBegin(GraphDecoder.MethodScope methodScope,
GraphDecoder.LoopScope loopScope,
LoopBeginNode loopBegin) |
protected GraphDecoder.LoopScopeTrigger |
handleLoopExplosionEnd(GraphDecoder.MethodScope methodScope,
GraphDecoder.LoopScope loopScope) |
protected void |
handleLoopExplosionProxyNodes(GraphDecoder.MethodScope methodScope,
GraphDecoder.LoopScope loopScope,
GraphDecoder.LoopScope outerScope,
LoopExitNode loopExit,
int loopExitOrderId) |
protected void |
handleMergeNode(MergeNode merge)
Hook for subclasses to perform simplifications for a non-loop-header control flow merge.
|
protected void |
handlePhiFunctions(GraphDecoder.MethodScope methodScope,
GraphDecoder.LoopScope phiInputScope,
GraphDecoder.LoopScope phiNodeScope,
AbstractEndNode end,
AbstractMergeNode merge) |
protected void |
handleProxyNodes(GraphDecoder.MethodScope methodScope,
GraphDecoder.LoopScope loopScope,
LoopExitNode loopExit) |
protected Node |
lookupNode(GraphDecoder.LoopScope loopScope,
int nodeOrderId) |
protected void |
makeFixedNodeInputs(GraphDecoder.MethodScope methodScope,
GraphDecoder.LoopScope loopScope,
Node node)
Process the input edges of a node.
|
protected void |
makeFloatingNodeInputs(GraphDecoder.MethodScope methodScope,
GraphDecoder.LoopScope loopScope,
Node node) |
protected FixedNode |
makeStubNode(GraphDecoder.MethodScope methodScope,
GraphDecoder.LoopScope loopScope,
int nodeOrderId) |
protected void |
makeSuccessorStubs(GraphDecoder.MethodScope methodScope,
GraphDecoder.LoopScope loopScope,
Node node,
boolean updatePredecessors)
Process successor edges of a node.
|
protected GraphDecoder.LoopScope |
processNextNode(GraphDecoder.MethodScope methodScope,
GraphDecoder.LoopScope loopScope) |
protected GraphDecoder.InvokeData |
readInvokeData(GraphDecoder.MethodScope methodScope,
int invokeOrderId,
Invoke invoke) |
protected Object |
readObject(GraphDecoder.MethodScope methodScope) |
protected int |
readOrderId(GraphDecoder.MethodScope methodScope) |
protected void |
readProperties(GraphDecoder.MethodScope methodScope,
Node node) |
protected void |
registerNode(GraphDecoder.LoopScope loopScope,
int nodeOrderId,
Node node,
boolean allowOverwrite,
boolean allowNull) |
protected static boolean |
skipDirectEdge(Node node,
Edges edges,
int index) |
protected boolean |
verifyEdges() |
protected final Architecture architecture
protected final StructuredGraph graph
protected final OptionValues options
protected final DebugContext debug
public static final boolean DUMP_DURING_FIXED_NODE_PROCESSING
public GraphDecoder(Architecture architecture,
StructuredGraph graph)
public final void decode(EncodedGraph encodedGraph)
public final void decode(EncodedGraph encodedGraph, Iterable<EncodedGraph.EncodedNodeReference> nodeReferences)
protected final GraphDecoder.LoopScope createInitialLoopScope(GraphDecoder.MethodScope methodScope, FixedWithNextNode startNode)
protected final void decode(GraphDecoder.LoopScope initialLoopScope)
protected void afterMethodScope(GraphDecoder.MethodScope methodScope)
protected void finishInlining(GraphDecoder.MethodScope inlineScope)
protected GraphDecoder.LoopScope processNextNode(GraphDecoder.MethodScope methodScope, GraphDecoder.LoopScope loopScope)
protected GraphDecoder.InvokeData readInvokeData(GraphDecoder.MethodScope methodScope, int invokeOrderId, Invoke invoke)
protected GraphDecoder.LoopScope handleInvoke(GraphDecoder.MethodScope methodScope, GraphDecoder.LoopScope loopScope, GraphDecoder.InvokeData invokeData)
Invoke nodes do not have the CallTargetNode, FrameState, and
successors encoded. Instead, this information is provided separately to allow method inlining
without decoding and adding them to the graph upfront. For non-inlined methods, this method
restores the normal state. Subclasses can override it to perform method inlining.
The return value is the loop scope where decoding should continue. When method inlining
should be performed, the returned loop scope must be a new loop scope for the inlined method.
Without inlining, the original loop scope must be returned.protected void appendInvoke(GraphDecoder.MethodScope methodScope, GraphDecoder.LoopScope loopScope, GraphDecoder.InvokeData invokeData, CallTargetNode callTarget)
protected void handleMergeNode(MergeNode merge)
merge - The control flow merge.protected void handleLoopExplosionBegin(GraphDecoder.MethodScope methodScope, GraphDecoder.LoopScope loopScope, LoopBeginNode loopBegin)
protected void checkLoopExplosionIteration(GraphDecoder.MethodScope methodScope, GraphDecoder.LoopScope loopScope)
methodScope - The current method.loopScope - The current loop.protected GraphDecoder.LoopScopeTrigger handleLoopExplosionEnd(GraphDecoder.MethodScope methodScope, GraphDecoder.LoopScope loopScope)
protected void handleFixedNode(GraphDecoder.MethodScope methodScope, GraphDecoder.LoopScope loopScope, int nodeOrderId, FixedNode node)
methodScope - The current method.loopScope - The current loop.nodeOrderId - The orderId of the node.node - The node to be simplified.protected boolean earlyCanonicalization(GraphDecoder.MethodScope methodScope, GraphDecoder.LoopScope loopScope, int nodeOrderId, FixedNode node)
methodScope - The current method.loopScope - The current loop.nodeOrderId - The orderId of the node.node - The node to be simplified.protected void handleProxyNodes(GraphDecoder.MethodScope methodScope, GraphDecoder.LoopScope loopScope, LoopExitNode loopExit)
protected void handleLoopExplosionProxyNodes(GraphDecoder.MethodScope methodScope, GraphDecoder.LoopScope loopScope, GraphDecoder.LoopScope outerScope, LoopExitNode loopExit, int loopExitOrderId)
protected void handlePhiFunctions(GraphDecoder.MethodScope methodScope, GraphDecoder.LoopScope phiInputScope, GraphDecoder.LoopScope phiNodeScope, AbstractEndNode end, AbstractMergeNode merge)
protected boolean allowLazyPhis()
protected void readProperties(GraphDecoder.MethodScope methodScope, Node node)
protected void makeFixedNodeInputs(GraphDecoder.MethodScope methodScope, GraphDecoder.LoopScope loopScope, Node node)
protected void makeFloatingNodeInputs(GraphDecoder.MethodScope methodScope, GraphDecoder.LoopScope loopScope, Node node)
protected Node ensureNodeCreated(GraphDecoder.MethodScope methodScope, GraphDecoder.LoopScope loopScope, int nodeOrderId)
protected Node addFloatingNode(GraphDecoder.MethodScope methodScope, Node node)
protected Node decodeFloatingNode(GraphDecoder.MethodScope methodScope, GraphDecoder.LoopScope loopScope, int nodeOrderId)
protected Node handleFloatingNodeBeforeAdd(GraphDecoder.MethodScope methodScope, GraphDecoder.LoopScope loopScope, Node node)
methodScope - The current method.loopScope - The current loop.node - The node to be canonicalized.protected Node handleFloatingNodeAfterAdd(GraphDecoder.MethodScope methodScope, GraphDecoder.LoopScope loopScope, Node node)
methodScope - The current method.loopScope - The current loop.node - The node to be canonicalized.protected void makeSuccessorStubs(GraphDecoder.MethodScope methodScope, GraphDecoder.LoopScope loopScope, Node node, boolean updatePredecessors)
GraphDecoder.processNextNode(org.graalvm.compiler.nodes.GraphDecoder.MethodScope, org.graalvm.compiler.nodes.GraphDecoder.LoopScope).protected NodeClass<?> getNodeClass(GraphDecoder.MethodScope methodScope, GraphDecoder.LoopScope loopScope, int nodeOrderId)
protected FixedNode makeStubNode(GraphDecoder.MethodScope methodScope, GraphDecoder.LoopScope loopScope, int nodeOrderId)
protected Node lookupNode(GraphDecoder.LoopScope loopScope, int nodeOrderId)
protected void registerNode(GraphDecoder.LoopScope loopScope, int nodeOrderId, Node node, boolean allowOverwrite, boolean allowNull)
protected int readOrderId(GraphDecoder.MethodScope methodScope)
protected Object readObject(GraphDecoder.MethodScope methodScope)
protected void cleanupGraph(GraphDecoder.MethodScope methodScope)
methodScope - The current method.protected boolean verifyEdges()