Top Description Inners Fields Constructors Methods
org.droidparts.dexmaker.dx.ssa

public final Class Dominators

extends Object
Class Inheritance
Imports
java.util.ArrayList, .BitSet, .HashSet

This class computes dominator and post-dominator information using the Lengauer-Tarjan method. See A Fast Algorithm for Finding Dominators in a Flowgraph T. Lengauer & R. Tarjan, ACM TOPLAS July 1979, pgs 121-141. This implementation runs in time O(n log n). The time bound could be changed to O(n * ack(n)) with a small change to the link and eval, and an addition of a child field to the DFS info. In reality, the constant overheads are high enough that the current method is faster in all but the strangest artificially constructed examples. The basic idea behind this algorithm is to perform a DFS walk, keeping track of various info about parents. We then use this info to calculate the dominators, using union-find structures to link together the DFS info, then finally evaluate the union-find results to get the dominators. This implementation is m log n because it does not perform union by rank to keep the union-find tree balanced.

Nested and Inner Type Summary

Modifier and TypeClass and Description
private static class
private class
Dominators.DfsWalker

Callback for depth-first walk through control flow graph (either from the entry block or the exit block).

Field Summary

Modifier and TypeField and Description
private final ArrayList<SsaBasicBlock>
private final DomFront.DomInfo[]
domInfos

non-null; the raw dominator info

private final Dominators.DFSInfo[]
info

indexed by basic block index

private final SsaMethod
private final boolean
private final ArrayList<SsaBasicBlock>

Constructor Summary

AccessConstructor and Description
private
Dominators(SsaMethod
non-null; method to process
meth
,
DomFront.DomInfo[]
non-null; the raw dominator info
domInfos
,
boolean
true for postdom information, false for normal dom info
postdom
)

Constructs an instance.

Method Summary

Modifier and TypeMethod and Description
private void
compress(SsaBasicBlock
Basic block whose DFS info we are path compressing.
in
)

Performs path compress on the DFS info.

private SsaBasicBlock
private BitSet
private BitSet
public static Dominators
make(SsaMethod
non-null; method to process
meth
,
DomFront.DomInfo[]
non-null; the raw dominator info
domInfos
,
boolean
true for postdom information, false for normal dom info
postdom
)

Constructs a fully-initialized instance.

private void
run()

Performs dominator/post-dominator calculation for the control flow graph.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

blocksback to summary
private final ArrayList<SsaBasicBlock> blocks
domInfosback to summary
private final DomFront.DomInfo[] domInfos

non-null; the raw dominator info

infoback to summary
private final Dominators.DFSInfo[] info

indexed by basic block index

methback to summary
private final SsaMethod meth
postdomback to summary
private final boolean postdom
vertexback to summary
private final ArrayList<SsaBasicBlock> vertex

Constructor Detail

Dominatorsback to summary
private Dominators(SsaMethod meth, DomFront.DomInfo[] domInfos, boolean postdom)

Constructs an instance.

Parameters
meth:SsaMethod

non-null; method to process

domInfos:DomFront.DomInfo[]

non-null; the raw dominator info

postdom:boolean

true for postdom information, false for normal dom info

Method Detail

compressback to summary
private void compress(SsaBasicBlock in)

Performs path compress on the DFS info.

Parameters
in:SsaBasicBlock

Basic block whose DFS info we are path compressing.

evalback to summary
private SsaBasicBlock eval(SsaBasicBlock v)
getPredsback to summary
private BitSet getPreds(SsaBasicBlock block)
getSuccsback to summary
private BitSet getSuccs(SsaBasicBlock block)
makeback to summary
public static Dominators make(SsaMethod meth, DomFront.DomInfo[] domInfos, boolean postdom)

Constructs a fully-initialized instance. (This method exists so as to avoid calling a large amount of code in the constructor.)

Parameters
meth:SsaMethod

non-null; method to process

domInfos:DomFront.DomInfo[]

non-null; the raw dominator info

postdom:boolean

true for postdom information, false for normal dom info

runback to summary
private void run()

Performs dominator/post-dominator calculation for the control flow graph.

org.droidparts.dexmaker.dx.ssa back to summary

private final Class Dominators.DFSInfo

extends Object
Class Inheritance

Field Summary

Modifier and TypeField and Description
public SsaBasicBlock
public ArrayList<SsaBasicBlock>
public SsaBasicBlock
public SsaBasicBlock
rep

rep(resentative) is known as "label" in the paper.

public int

Constructor Summary

AccessConstructor and Description
public

Method Summary

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

ancestorback to summary
public SsaBasicBlock ancestor
bucketback to summary
public ArrayList<SsaBasicBlock> bucket
parentback to summary
public SsaBasicBlock parent
repback to summary
public SsaBasicBlock rep

rep(resentative) is known as "label" in the paper. It is the node that our block's DFS info has been unioned to.

semidomback to summary
public int semidom

Constructor Detail

DFSInfoback to summary
public DFSInfo()
org.droidparts.dexmaker.dx.ssa back to summary

private Class Dominators.DfsWalker

extends Object
implements Visitor
Class Inheritance
All Implemented Interfaces
org.droidparts.dexmaker.dx.ssa.SsaBasicBlock.Visitor

Callback for depth-first walk through control flow graph (either from the entry block or the exit block). Records the traversal order in the infolist.

Field Summary

Modifier and TypeField and Description
private int

Constructor Summary

AccessConstructor and Description
private

Method Summary

Modifier and TypeMethod and Description
public void
visitBlock(SsaBasicBlock
non-null; block visited
v
,
SsaBasicBlock
null-ok; parent node if applicable
parent
)

Implements org.droidparts.dexmaker.dx.ssa.SsaBasicBlock.Visitor.visitBlock.

Indicates a block has been visited by an iterator method.
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

dfsNumback to summary
private int dfsNum

Constructor Detail

DfsWalkerback to summary
private DfsWalker()

Method Detail

visitBlockback to summary
public void visitBlock(SsaBasicBlock v, SsaBasicBlock parent)

Implements org.droidparts.dexmaker.dx.ssa.SsaBasicBlock.Visitor.visitBlock.

Doc from org.droidparts.dexmaker.dx.ssa.SsaBasicBlock.Visitor.visitBlock.

Indicates a block has been visited by an iterator method.

Parameters
v:SsaBasicBlock

non-null; block visited

parent:SsaBasicBlock

null-ok; parent node if applicable