mirror of
https://github.com/konsoletyper/teavm.git
synced 2024-11-21 01:00:54 +08:00
Fix bugs in node splitting or irreducible graphs
This commit is contained in:
parent
6551f3eb68
commit
1b78ef99a6
@ -114,10 +114,6 @@ public class DJGraph {
|
||||
}
|
||||
}
|
||||
|
||||
public DominatorTree getDomTree() {
|
||||
return domTree;
|
||||
}
|
||||
|
||||
public MutableDirectedGraph getCfg() {
|
||||
return cfg;
|
||||
}
|
||||
@ -136,7 +132,17 @@ public class DJGraph {
|
||||
}
|
||||
|
||||
public boolean isDomEdge(int i, int j) {
|
||||
return domTree.immediateDominatorOf(mergeRoot[j]) == mergeRoot[i];
|
||||
return immediateDominatorOf(j) == mergeRoot[i];
|
||||
}
|
||||
|
||||
public int immediateDominatorOf(int node) {
|
||||
int dom = domTree.immediateDominatorOf(mergeRoot[node]);
|
||||
return dom >= 0 ? mergeRoot[dom] : dom;
|
||||
}
|
||||
|
||||
public int commonDominatorOf(int a, int b) {
|
||||
int dom = domTree.commonDominatorOf(mergeRoot[a], mergeRoot[b]);
|
||||
return dom >= 0 ? mergeRoot[dom] : dom;
|
||||
}
|
||||
|
||||
public boolean isJoinEdge(int i, int j) {
|
||||
|
@ -84,7 +84,7 @@ class IrreducibleGraphConverter {
|
||||
// Find shared dominator
|
||||
int sharedDom = scc[0];
|
||||
for (int i = 1; i < scc.length; ++i) {
|
||||
sharedDom = djGraph.getDomTree().commonDominatorOf(sharedDom, scc[i]);
|
||||
sharedDom = djGraph.commonDominatorOf(sharedDom, scc[i]);
|
||||
}
|
||||
|
||||
for (int i = 0; i < scc.length; ++i) {
|
||||
@ -103,7 +103,7 @@ class IrreducibleGraphConverter {
|
||||
}
|
||||
for (int i = 0; i < scc.length; ++i) {
|
||||
int node = scc[i];
|
||||
int idom = djGraph.getDomTree().immediateDominatorOf(node);
|
||||
int idom = djGraph.immediateDominatorOf(node);
|
||||
if (idom != sharedDom) {
|
||||
partitions.union(i, sccBack[idom]);
|
||||
}
|
||||
|
@ -24,7 +24,6 @@ import com.carrotsearch.hppc.IntSet;
|
||||
import java.util.Arrays;
|
||||
import java.util.Comparator;
|
||||
import java.util.function.IntPredicate;
|
||||
import org.junit.Ignore;
|
||||
import org.junit.Test;
|
||||
|
||||
public class GraphTest {
|
||||
@ -172,12 +171,10 @@ public class GraphTest {
|
||||
|
||||
assertTrue("Should be irreducible", GraphUtils.isIrreducible(graph));
|
||||
assertFalse("Should be reducible", GraphUtils.isIrreducible(result));
|
||||
assertTrue("Should be equialent", isEquialent(backend, graph));
|
||||
assertTrue("Should be equivalent", isEquialent(backend, graph));
|
||||
}
|
||||
|
||||
// TODO: fix and unignore
|
||||
@Test
|
||||
@Ignore
|
||||
public void irreducibleGraphSplit3() {
|
||||
GraphBuilder builder = new GraphBuilder();
|
||||
builder.addEdge(0, 1);
|
||||
@ -232,8 +229,8 @@ public class GraphTest {
|
||||
private IntPredicate filter = (int node) -> true;
|
||||
|
||||
private void sortSccs(int[][] sccs) {
|
||||
for (int i = 0; i < sccs.length; ++i) {
|
||||
Arrays.sort(sccs[i]);
|
||||
for (int[] scc : sccs) {
|
||||
Arrays.sort(scc);
|
||||
}
|
||||
Arrays.sort(sccs, Comparator.comparingInt(o -> o[0]));
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user