Package org.jruby.ir.representations
Class CFG
java.lang.Object
org.jruby.ir.representations.CFG
Represents the base build of a CFG. All information here is accessed via
delegation from the CFG itself so this is meant as an internal
organizational structure for a build.
-
Nested Class Summary
Nested Classes -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final Map<Label,BasicBlock> private BasicBlockEntry BBprivate BasicBlockExit BBprivate BasicBlockBB that traps all exception-edges out of the cfg where we could add any cleanup/ensure code (ex: pop frames, etc.)private final org.jruby.dirgra.DirectedGraph<BasicBlock>The graph itselfprivate static final Loggerprivate int(package private) LinkedList<BasicBlock>private final Map<BasicBlock,BasicBlock> (package private) List<BasicBlock>List of bbs that have a 'return' instructionprivate final IRScope -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidprivate voidaddEdge(BasicBlock src, Label targetLabel, Map<Label, List<BasicBlock>> forwardRefs) voidaddEdge(BasicBlock source, BasicBlock destination, Object type) voidbooleanorg.jruby.dirgra.DirectedGraph<BasicBlock>Build the Control Flow Graphprivate BasicBlockbuildExitBasicBlock(Stack<ExceptionRegion> nestedExceptionRegions, BasicBlock firstBB, List<BasicBlock> returnBBs, List<BasicBlock> exceptionBBs, boolean nextIsFallThrough, BasicBlock currBB, BasicBlock entryBB) Create special empty exit BasicBlock that all BasicBlocks will eventually flow into.private LinkedList<BasicBlock>Clone this CFG and return a new one.voidprivate BasicBlockcreateBB(Stack<ExceptionRegion> nestedExceptionRegions) private BasicBlockcreateBB(Label label, Stack<ExceptionRegion> nestedExceptionRegions) private voiddeleteOrphanedBlocks(org.jruby.dirgra.DirectedGraph<BasicBlock> graph) voidfixupEdges(BasicBlock bb) getBBForLabel(Label label) Iterable<org.jruby.dirgra.Edge<BasicBlock>>getIncomingEdges(BasicBlock block) getIncomingSourceOfType(BasicBlock block, Object type) getIncomingSources(BasicBlock block) intintgetOutgoingDestinationOfType(BasicBlock block, Object type) getOutgoingDestinationsNotOfType(BasicBlock block, Object type) getOutgoingDestinationsOfType(BasicBlock block, Object type) Collection<org.jruby.dirgra.Edge<BasicBlock>>getOutgoingEdges(BasicBlock block) getRescuerBBFor(BasicBlock block) getScope()intprivate booleanmergeBBs(BasicBlock a, BasicBlock b) voidoptimize()intprivate voidprintError(String message) voidvoidvoidremoveEdge(BasicBlock a, BasicBlock b) private voidWrapped IRClosures in dead BB are lexically rooted to that dead BB so they can be removed from the parent scope if the BB they live in died.voidvoidsetRescuerBB(BasicBlock block, BasicBlock rescuerBlock) intsize()How many BasicBlocks are there in this CFG?
-
Field Details
-
LOG
-
scope
-
bbMap
-
rescuerMap
-
entryBB
Entry BB -
exitBB
Exit BB -
returnBBs
List<BasicBlock> returnBBsList of bbs that have a 'return' instruction -
globalEnsureBB
BB that traps all exception-edges out of the cfg where we could add any cleanup/ensure code (ex: pop frames, etc.) -
graph
The graph itself -
nextBBId
private int nextBBId -
postOrderList
LinkedList<BasicBlock> postOrderList
-
-
Constructor Details
-
CFG
-
-
Method Details
-
getNextBBID
public int getNextBBID() -
getManager
-
getMaxNodeID
public int getMaxNodeID() -
bbIsProtected
-
getBBForLabel
-
getEntryBB
-
getExitBB
-
getGlobalEnsureBB
-
postOrderList
-
getPostOrderTraverser
-
getReversePostOrderTraverser
-
resetState
public void resetState() -
getScope
-
size
public int size()How many BasicBlocks are there in this CFG? -
getBasicBlocks
-
getSortedBasicBlocks
-
addEdge
-
inDegree
-
outDegree
-
getIncomingSources
-
getIncomingEdges
-
getIncomingSourceOfType
-
getOutgoingDestinationOfType
-
getOutgoingDestinations
-
getOutgoingDestinationsOfType
-
getOutgoingDestinationsNotOfType
-
getOutgoingEdges
-
getRescuerBBFor
-
addGlobalEnsureBB
-
setRescuerBB
-
build
Build the Control Flow Graph -
fixupEdges
-
addEdge
-
buildExitBasicBlock
private BasicBlock buildExitBasicBlock(Stack<ExceptionRegion> nestedExceptionRegions, BasicBlock firstBB, List<BasicBlock> returnBBs, List<BasicBlock> exceptionBBs, boolean nextIsFallThrough, BasicBlock currBB, BasicBlock entryBB) Create special empty exit BasicBlock that all BasicBlocks will eventually flow into. All Edges to this 'dummy' BasicBlock will get marked with an edge type of EXIT. Special BasicBlocks worth noting: 1. Exceptions, Returns, Entry(why?) -> ExitBB 2. Returns -> ExitBB -
createBB
-
createBB
-
addBasicBlock
-
removeAllOutgoingEdgesForBB
-
deleteOrphanedBlocks
-
mergeBBs
-
removeBB
-
removeNestedScopesFromBB
Wrapped IRClosures in dead BB are lexically rooted to that dead BB so they can be removed from the parent scope if the BB they live in died. -
collapseStraightLineBBs
public void collapseStraightLineBBs() -
optimize
public void optimize() -
toStringGraph
-
toStringInstrs
-
removeEdge
-
buildPostOrderList
-
clone
Clone this CFG and return a new one.- Parameters:
info- context object to perform the cloneclonedScope- already cloned IRScope which this new CFG will belong to- Returns:
- a newly cloned CFG
-
printError
-