Class ControlFlowGraph
BlockContainer at the start of block transforms
(before loop detection)
Created by covers1624 on 19/4/21.
-
Field Summary
FieldsModifier and TypeFieldDescriptionfinal ControlFlowNode[]Nodes array, indexed by original block index.final BlockContainerThe container for which theControlFlowGraphwas created.final BitSetdirectExits.get(i) == trueifcfg[i]directly contains a branch/leave instruction leavingcontainer.final Map<Block, ControlFlowNode> A map ofBlocktoControlFlowNode.final BitSetreachableExits.get(i) == trueif there is a path fromcfg[i]to a node not dominated bycfg[i], or if there is a path fromcfg[i]to a branch/leave instruction leaving thecontainer. -
Constructor Summary
ConstructorsConstructorDescriptionControlFlowGraph(BlockContainer container) Constructs a control flow graph for the blocks in the given block container. -
Method Summary
Modifier and TypeMethodDescriptionGets the control flow node for the block.booleanhasDirectExit(ControlFlowNode node) Gets whether the control flow node directly contains a branch/leave instruction exiting the container.booleanReturns true if there is a control flow path fromnodeto one of the following: - Branch or leave instruction leavingthis.container.voidResets allControlFlowNode.visitedflags for all nodes in this graph.
-
Field Details
-
container
The container for which theControlFlowGraphwas created.This may differ from the container currently holding a block, because a transform could have moved the block since the CFG was created.
-
cfg
Nodes array, indexed by original block index.Originally
cfg[i].block == container.blocks.get(i)but may have since been moved/reordered by transforms. -
nodes
A map ofBlocktoControlFlowNode.Unlike the cfg array, this can be used to discover control flow nodes even after blocks were moved/reordered by transforms.
-
directExits
directExits.get(i) == trueifcfg[i]directly contains a branch/leave instruction leavingcontainer. -
reachableExits
reachableExits.get(i) == trueif there is a path fromcfg[i]to a node not dominated bycfg[i], or if there is a path fromcfg[i]to a branch/leave instruction leaving thecontainer.
-
-
Constructor Details
-
ControlFlowGraph
Constructs a control flow graph for the blocks in the given block container.Return statements, exceptions, or branches leaving the block container are not modeled by the control flow graph.
- Parameters:
container- The container.
-
-
Method Details
-
getNode
Gets the control flow node for the block.Precondition: the block belonged to the
containerat the start of the block transforms (where the control flow graph was created).- Parameters:
block- The block to get theControlFlowNodefor.- Returns:
- The ControlFlowNode.
-
hasReachableExit
Returns true if there is a control flow path fromnodeto one of the following: - Branch or leave instruction leavingthis.container. - Branch instruction within this container to another node that is not dominated bynode.If this function returns
false, the only way control flow can leave the set of nodes dominated bynodeis by executing areturn;orthrow;instruction.- Parameters:
node- The node to check.- Returns:
- If the node has a reachable exit.
-
hasDirectExit
Gets whether the control flow node directly contains a branch/leave instruction exiting the container.- Parameters:
node- The node to check.- Returns:
- If the node has a direct exit.
-
resetVisited
public void resetVisited()Resets allControlFlowNode.visitedflags for all nodes in this graph.
-