|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object soot.toolkits.graph.BlockGraph
public abstract class 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()
.
Field Summary | |
---|---|
protected List<Block> |
mBlocks
|
protected Body |
mBody
|
protected List<Block> |
mHeads
|
protected List<Block> |
mTails
|
protected Chain<Unit> |
mUnits
|
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<Unit,Block> |
buildBlocks(Set<Unit> 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<Unit> |
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<Block> |
getBlocks()
Returns a list of the Blocks composing this graph. |
Body |
getBody()
Returns the Body this BlockGraph is derived from. |
List<Block> |
getHeads()
Returns a list of entry points for this graph. |
List<Block> |
getPredsOf(Block b)
Returns a list of predecessors for the given node in the graph. |
List<Block> |
getSuccsOf(Block b)
Returns a list of successors for the given node in the graph. |
List<Block> |
getTails()
Returns a list of exit points for this graph. |
Iterator<Block> |
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 |
Field Detail |
---|
protected Body mBody
protected Chain<Unit> mUnits
protected List<Block> mBlocks
protected List<Block> mHeads
protected List<Block> mTails
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 Unit
s.Method Detail |
---|
protected Set<Unit> 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).Unit
s 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 Unit
s 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 Unit
s in unitGraph
which
are block leaders.protected Map<Unit,Block> buildBlocks(Set<Unit> 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 Unit
s 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
Unit
s which are heads in unitGraph
,
and defines as tails the blocks which end with
Unit
s which are tails in unitGraph
.
Subclasses might override this behavior.
leaders
- Contains Unit
s 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 Unit
s 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<Block> getBlocks()
Block
public String toString()
toString
in class Object
public List<Block> getHeads()
DirectedGraph
getHeads
in interface DirectedGraph<Block>
public List<Block> getTails()
DirectedGraph
getTails
in interface DirectedGraph<Block>
public List<Block> getPredsOf(Block b)
DirectedGraph
getPredsOf
in interface DirectedGraph<Block>
public List<Block> getSuccsOf(Block b)
DirectedGraph
getSuccsOf
in interface DirectedGraph<Block>
public int size()
DirectedGraph
size
in interface DirectedGraph<Block>
public Iterator<Block> iterator()
DirectedGraph
iterator
in interface Iterable<Block>
iterator
in interface DirectedGraph<Block>
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |