Revert some code

This commit is contained in:
Alexey Andreev 2015-02-27 21:33:57 +03:00
parent 59408e40e5
commit 9adbb1ae93
4 changed files with 12 additions and 14 deletions

View File

@ -45,12 +45,12 @@ class DominatorTreeBuilder {
bucket = new IntegerArray[graph.size()]; bucket = new IntegerArray[graph.size()];
} }
public void build(int[] start) { public void build() {
for (int i = 0; i < labels.length; ++i) { for (int i = 0; i < labels.length; ++i) {
labels[i] = i; labels[i] = i;
} }
Arrays.fill(ancestors, -1); Arrays.fill(ancestors, -1);
dfs(start); dfs();
for (int i = effectiveSize - 1; i >= 0; --i) { for (int i = effectiveSize - 1; i >= 0; --i) {
int w = vertices[i]; int w = vertices[i];
if (parents[w] < 0) { if (parents[w] < 0) {
@ -120,13 +120,15 @@ class DominatorTreeBuilder {
return labels[v]; return labels[v];
} }
private void dfs(int[] start) { private void dfs() {
Arrays.fill(semidominators, -1); Arrays.fill(semidominators, -1);
Arrays.fill(vertices, -1); Arrays.fill(vertices, -1);
IntegerStack stack = new IntegerStack(graph.size()); IntegerStack stack = new IntegerStack(graph.size());
for (int node : start) { for (int i = graph.size() - 1; i >= 0; --i) {
stack.push(node); if (graph.incomingEdgesCount(i) == 0) {
parents[node] = -1; stack.push(i);
parents[i] = -1;
}
} }
int i = 0; int i = 0;
while (!stack.isEmpty()) { while (!stack.isEmpty()) {

View File

@ -161,12 +161,8 @@ public final class GraphUtils {
} }
public static DominatorTree buildDominatorTree(Graph graph) { public static DominatorTree buildDominatorTree(Graph graph) {
return buildDominatorTree(graph, 0);
}
public static DominatorTree buildDominatorTree(Graph graph, int... start) {
DominatorTreeBuilder builder = new DominatorTreeBuilder(graph); DominatorTreeBuilder builder = new DominatorTreeBuilder(graph);
builder.build(start); builder.build();
return new DefaultDominatorTree(builder.dominators, builder.vertices); return new DefaultDominatorTree(builder.dominators, builder.vertices);
} }

View File

@ -38,9 +38,9 @@ public class DJGraph {
private int[] mergeRoot; private int[] mergeRoot;
private IntegerArray[] mergeClasses; private IntegerArray[] mergeClasses;
public DJGraph(Graph src, int top) { public DJGraph(Graph src) {
this.cfg = new MutableDirectedGraph(src); this.cfg = new MutableDirectedGraph(src);
domTree = GraphUtils.buildDominatorTree(src, top); domTree = GraphUtils.buildDominatorTree(src);
buildGraph(src); buildGraph(src);
buildLevels(); buildLevels();
dfs(); dfs();

View File

@ -32,7 +32,7 @@ public class IrreducibleGraphConverter {
public void convertToReducible(Graph cfg, GraphSplittingBackend backend) { public void convertToReducible(Graph cfg, GraphSplittingBackend backend) {
this.backend = backend; this.backend = backend;
handleLoops(new DJGraph(cfg, 0)); handleLoops(new DJGraph(cfg));
this.backend = null; this.backend = null;
} }