|
|||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||
java.lang.Objectsoot.toolkits.graph.BlockGraph
Represents the control flow graph of a Body at the basic
block level. Each node of the graph is a Block while the
edges represent the flow of control from one basic block to
the next.
This is an abstract base class for different variants of
BlockGraph, where the variants differ in how they
analyze the control flow between individual units (represented
by passing different variants of UnitGraph to the
BlockGraph constructor) and in how they identify
block leaders (represented by overriding BlockGraph's
definition of computeLeaders().
| Constructor Summary | |
protected |
BlockGraph(UnitGraph unitGraph)
Create a BlockGraph representing at the basic block
level the control flow specified, at the Unit level,
by a given UnitGraph. |
| Method Summary | |
protected Map |
buildBlocks(Set leaders,
UnitGraph unitGraph)
A utility method that does most of the work of constructing basic blocks, once the set of block leaders has been determined, and which designates the heads and tails of the graph. |
protected Set |
computeLeaders(UnitGraph unitGraph)
Utility method for computing the basic block leaders for a Body, given its UnitGraph (i.e., the
instructions which begin new basic blocks). |
List |
getBlocks()
Returns a list of the Blocks composing this graph. |
Body |
getBody()
Returns the Body this BlockGraph is derived from. |
List |
getHeads()
Returns a list of entry points for this graph. |
List |
getPredsOf(Object o)
Returns a list of predecessors for the given node in the graph. |
List |
getSuccsOf(Object o)
Returns a list of successors for the given node in the graph. |
List |
getTails()
Returns a list of exit points for this graph. |
Iterator |
iterator()
Returns an iterator for the nodes in this graph. |
int |
size()
Returns the node count for this graph. |
String |
toString()
|
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Constructor Detail |
protected BlockGraph(UnitGraph unitGraph)
BlockGraph representing at the basic block
level the control flow specified, at the Unit level,
by a given UnitGraph.
unitGraph - A representation of the control flow at
the level of individual Units.| Method Detail |
protected Set computeLeaders(UnitGraph unitGraph)
Utility method for computing the basic block leaders for a
Body, given its UnitGraph (i.e., the
instructions which begin new basic blocks).
This implementation designates as basic block leaders :
Unit which has zero predecessors (e.g. the
Unit following a return or unconditional branch) or
more than one predecessor (e.g. a merge point).Units which are the target of any branch (even if
they have no other predecessors and the branch has no other
successors, which is possible for the targets of unconditional
branches or degenerate conditional branches which both branch
and fall through to the same Unit).Unit which has more than one
successor (this includes the successors of Units which
may throw an exception that gets caught within the
Body, as well the successors of conditional
branches).Unit in any Trap handler.
(Strictly speaking, if unitGraph were a
ExceptionalUnitGraph that included only a single
unexceptional predecessor for some handler—because no trapped
unit could possibly throw the exception that the handler
catches, while the code preceding the handler fell through to
the handler's code—then you could merge the handler into the
predecessor's basic block; but such situations occur only in
carefully contrived bytecode.)
unitGraph - is the Unit-level CFG which is to be split
into basic blocks.
Set of Units in unitGraph which
are block leaders.
protected Map buildBlocks(Set leaders,
UnitGraph unitGraph)
A utility method that does most of the work of constructing basic blocks, once the set of block leaders has been determined, and which designates the heads and tails of the graph.
BlockGraph provides an implementation of
buildBlocks() which splits the Units in
unitGraph so that each Unit in the
passed set of block leaders is the first unit in a block. It
defines as heads the blocks which begin with
Units which are heads in unitGraph,
and defines as tails the blocks which end with
Units which are tails in unitGraph.
Subclasses might override this behavior.
leaders - Contains Units which are
to be block leaders.unitGraph - Provides information about the predecessors and
successors of each Unit in the Body,
for determining the predecessors and successors of
each created Block.
Map from Units which begin or end a block
to the block which contains them.public Body getBody()
Body this BlockGraph is derived from.
Body this BlockGraph is derived from.public List getBlocks()
Blockpublic String toString()
public List getHeads()
DirectedGraph
getHeads in interface DirectedGraphpublic List getTails()
DirectedGraph
getTails in interface DirectedGraphpublic List getPredsOf(Object o)
DirectedGraph
getPredsOf in interface DirectedGraphpublic List getSuccsOf(Object o)
DirectedGraph
getSuccsOf in interface DirectedGraphpublic int size()
DirectedGraph
size in interface DirectedGraphpublic Iterator iterator()
DirectedGraph
iterator in interface DirectedGraph
|
|||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||