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
BitSet
s instead of HashSet
s, as the most expensive
operation in this algorithm used to be cloning of the fullSet, which is very cheap
for BitSet
s.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()
DominatorsFinder
getGraph
in interface DominatorsFinder<N>
public java.util.List<N> getDominators(N node)
DominatorsFinder
getDominators
in interface DominatorsFinder<N>
public N getImmediateDominator(N node)
DominatorsFinder
getImmediateDominator
in interface DominatorsFinder<N>
public boolean isDominatedBy(N node, N dominator)
DominatorsFinder
isDominatedBy
in interface DominatorsFinder<N>
public boolean isDominatedByAll(N node, java.util.Collection<N> dominators)
DominatorsFinder
isDominatedByAll
in interface DominatorsFinder<N>