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

View File

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

View File

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

View File

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