Methods Summary |
---|
private void | buildDomTree()The dominators algorithm leaves us knowing who the immediate dominator
is for each node. This sweeps the node list and builds the proper
dominance tree.
int szNodes = nodes.size();
for (int i = 0; i < szNodes; i++) {
DomInfo info = domInfos[i];
SsaBasicBlock domParent = nodes.get(info.idom);
domParent.addDomChild(nodes.get(i));
}
|
private void | calcDomFronts()Calculates the dominance-frontier set.
from "A Simple, Fast Dominance Algorithm" by Cooper,
Harvey, and Kennedy; transliterated to Java.
int szNodes = nodes.size();
for (int b = 0; b < szNodes; b++) {
SsaBasicBlock nb = nodes.get(b);
DomInfo nbInfo = domInfos[b];
BitSet pred = nb.getPredecessors();
if (pred.cardinality() > 1) {
for (int i = pred.nextSetBit(0); i >= 0;
i = pred.nextSetBit(i + 1)) {
for(int runnerIndex = i
; runnerIndex != nbInfo.idom
;) {
// We can stop if we hit a block we already
// added label to, since we must be at a part
// of the dom tree we have seen before.
DomInfo runnerInfo = domInfos[runnerIndex];
if (runnerInfo.dominanceFrontiers.has(b))
break;
// "add b to runner's dominance frontier set"
runnerInfo.dominanceFrontiers.add(b);
runnerIndex = runnerInfo.idom;
}
}
}
}
|
private void | debugPrintDomChildren()
int szNodes = nodes.size();
for (int i = 0; i < szNodes; i++) {
SsaBasicBlock node = nodes.get(i);
StringBuffer sb = new StringBuffer();
sb.append('{");
boolean comma = false;
for (SsaBasicBlock child: node.getDomChildren()) {
if (comma) {
sb.append(',");
}
sb.append(child);
comma = true;
}
sb.append('}");
System.out.println("domChildren[" + node + "]: "
+ sb);
}
|
public com.android.dx.ssa.DomFront$DomInfo[] | run()Calculates the dominance frontier information for the method.
int szNodes = nodes.size();
if (DEBUG) {
for (int i = 0; i < szNodes; i++) {
SsaBasicBlock node = nodes.get(i);
System.out.println("pred[" + i + "]: "
+ node.getPredecessors());
}
}
Dominators methDom = new Dominators(domInfos, false);
methDom.run(meth);
if (DEBUG) {
for (int i = 0; i < szNodes; i++) {
DomInfo info = domInfos[i];
System.out.println("idom[" + i + "]: "
+ info.idom);
}
}
buildDomTree();
if (DEBUG) {
debugPrintDomChildren();
}
for (int i = 0; i < szNodes; i++) {
domInfos[i].dominanceFrontiers
= SetFactory.makeDomFrontSet(szNodes);
}
calcDomFronts();
if (DEBUG) {
for (int i = 0; i < szNodes; i++) {
System.out.println("df[" + i + "]: "
+ domInfos[i].dominanceFrontiers);
}
}
return domInfos;
|