public class MHGDominatorsFinder<N> extends java.lang.Object implements DominatorsFinder<N>
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.| Modifier and Type | Field and Description |
|---|---|
protected java.util.BitSet |
fullSet |
protected DirectedGraph<N> |
graph |
protected java.util.List<N> |
heads |
protected java.util.Map<java.lang.Integer,N> |
indexToNode |
protected int |
lastIndex |
protected java.util.Map<N,java.util.BitSet> |
nodeToFlowSet |
protected java.util.Map<N,java.lang.Integer> |
nodeToIndex |
| Constructor and Description |
|---|
MHGDominatorsFinder(DirectedGraph<N> graph) |
| Modifier and Type | Method and Description |
|---|---|
protected void |
doAnalysis() |
java.util.List<N> |
getDominators(N node)
Returns a list of dominators for the given node in the graph.
|
DirectedGraph<N> |
getGraph()
Returns the graph to which the analysis pertains.
|
N |
getImmediateDominator(N node)
Returns the immediate dominator of node or null if the node has
no immediate dominator.
|
protected int |
indexOf(N o) |
boolean |
isDominatedBy(N node,
N dominator)
True if "node" is dominated by "dominator" in the graph.
|
boolean |
isDominatedByAll(N node,
java.util.Collection<N> dominators)
True if "node" is dominated by all nodes in "dominators" in the graph.
|
protected DirectedGraph<N> graph
protected java.util.BitSet fullSet
protected java.util.List<N> heads
protected java.util.Map<N,java.util.BitSet> nodeToFlowSet
protected java.util.Map<N,java.lang.Integer> nodeToIndex
protected java.util.Map<java.lang.Integer,N> indexToNode
protected int lastIndex
public MHGDominatorsFinder(DirectedGraph<N> graph)
protected void doAnalysis()
protected int indexOf(N o)
public DirectedGraph<N> getGraph()
DominatorsFindergetGraph in interface DominatorsFinder<N>public java.util.List<N> getDominators(N node)
DominatorsFindergetDominators in interface DominatorsFinder<N>public N getImmediateDominator(N node)
DominatorsFindergetImmediateDominator in interface DominatorsFinder<N>public boolean isDominatedBy(N node, N dominator)
DominatorsFinderisDominatedBy in interface DominatorsFinder<N>public boolean isDominatedByAll(N node, java.util.Collection<N> dominators)
DominatorsFinderisDominatedByAll in interface DominatorsFinder<N>