soot.toolkits.graph
Class MHGDominatorsFinder

java.lang.Object
  extended by soot.toolkits.graph.MHGDominatorsFinder
All Implemented Interfaces:
DominatorsFinder
Direct Known Subclasses:
MHGPostDominatorsFinder

public class MHGDominatorsFinder
extends Object
implements DominatorsFinder

Calculate dominators for basic blocks.

Uses the algorithm contained in Dragon book, pg. 670-1.

       D(n0) := { n0 }
       for n in N - { n0 } do D(n) := N;
       while changes to any D(n) occur do
         for n in N - {n0} do
             D(n) := {n} U (intersect of D(p) over all predecessors p of n)
 
2007/07/03 - updated to use BitSets instead of HashSets, as the most expensive operation in this algorithm used to be cloning of the fullSet, which is very cheap for BitSets.

Author:
Navindra Umanee, Eric Bodden

Field Summary
protected  BitSet fullSet
           
protected  DirectedGraph graph
           
protected  List heads
           
protected  Map<Integer,Object> indexToNode
           
protected  int lastIndex
           
protected  Map<Object,BitSet> nodeToFlowSet
           
protected  Map<Object,Integer> nodeToIndex
           
 
Constructor Summary
MHGDominatorsFinder(DirectedGraph graph)
           
 
Method Summary
protected  void doAnalysis()
           
 List getDominators(Object node)
          Returns a list of dominators for the given node in the graph.
 DirectedGraph getGraph()
          Returns the graph to which the analysis pertains.
 Object getImmediateDominator(Object node)
          Returns the immediate dominator of node or null if the node has no immediate dominator.
protected  int indexOf(Object o)
           
 boolean isDominatedBy(Object node, Object dominator)
          True if "node" is dominated by "dominator" in the graph.
 boolean isDominatedByAll(Object node, Collection dominators)
          True if "node" is dominated by all nodes in "dominators" in the graph.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

graph

protected DirectedGraph graph

fullSet

protected BitSet fullSet

heads

protected List heads

nodeToFlowSet

protected Map<Object,BitSet> nodeToFlowSet

nodeToIndex

protected Map<Object,Integer> nodeToIndex

indexToNode

protected Map<Integer,Object> indexToNode

lastIndex

protected int lastIndex
Constructor Detail

MHGDominatorsFinder

public MHGDominatorsFinder(DirectedGraph graph)
Method Detail

doAnalysis

protected void doAnalysis()

indexOf

protected int indexOf(Object o)

getGraph

public DirectedGraph getGraph()
Description copied from interface: DominatorsFinder
Returns the graph to which the analysis pertains.

Specified by:
getGraph in interface DominatorsFinder

getDominators

public List getDominators(Object node)
Description copied from interface: DominatorsFinder
Returns a list of dominators for the given node in the graph.

Specified by:
getDominators in interface DominatorsFinder

getImmediateDominator

public Object getImmediateDominator(Object node)
Description copied from interface: DominatorsFinder
Returns the immediate dominator of node or null if the node has no immediate dominator.

Specified by:
getImmediateDominator in interface DominatorsFinder

isDominatedBy

public boolean isDominatedBy(Object node,
                             Object dominator)
Description copied from interface: DominatorsFinder
True if "node" is dominated by "dominator" in the graph.

Specified by:
isDominatedBy in interface DominatorsFinder

isDominatedByAll

public boolean isDominatedByAll(Object node,
                                Collection dominators)
Description copied from interface: DominatorsFinder
True if "node" is dominated by all nodes in "dominators" in the graph.

Specified by:
isDominatedByAll in interface DominatorsFinder