Skip to content

Commit

Permalink
More move from HashSet to LinkedHashSet to stabelize itteration. Fixe…
Browse files Browse the repository at this point in the history
…d a try finally merge issue.
  • Loading branch information
LexManos committed Oct 22, 2015
1 parent cf2bb43 commit 2f1f8ef
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 25 deletions.
23 changes: 11 additions & 12 deletions src/org/jetbrains/java/decompiler/modules/decompiler/DomHelper.java
Original file line number Diff line number Diff line change
Expand Up @@ -213,12 +213,12 @@ public int compare(Integer o1, Integer o2) {
public static RootStatement parseGraph(ControlFlowGraph graph, StructMethod mt) {

RootStatement root = graphToStatement(graph);
if (!processStatement(root, new HashMap<Integer, Set<Integer>>())) {
if (!processStatement(root, new HashMap<Integer, LinkedHashSet<Integer>>())) {
DotExporter.toDotFile(graph, mt, "parseGraphFail", true);
throw new RuntimeException("parsing failure!");
}

LabelHelper.lowContinueLabels(root, new HashSet<StatEdge>());
LabelHelper.lowContinueLabels(root, new LinkedHashSet<StatEdge>());

SequenceHelper.condenseSequences(root);
root.buildMonitorFlags();
Expand Down Expand Up @@ -309,7 +309,7 @@ private static void buildSynchronized(Statement stat) {
}
}

private static boolean processStatement(Statement general, HashMap<Integer, Set<Integer>> mapExtPost) {
private static boolean processStatement(Statement general, HashMap<Integer, LinkedHashSet<Integer>> mapExtPost) {

if (general.type == Statement.TYPE_ROOT) {
Statement stat = general.getFirst();
Expand Down Expand Up @@ -358,7 +358,7 @@ private static boolean processStatement(Statement general, HashMap<Integer, Set<
// DotExporter.toDotFile(general, new File("c:\\Temp\\stat1.dot"));
// } catch(Exception ex) {ex.printStackTrace();}

mapExtPost = new HashMap<Integer, Set<Integer>>();
mapExtPost = new HashMap<Integer, LinkedHashSet<Integer>>();
mapRefreshed = true;
}

Expand All @@ -379,7 +379,7 @@ private static boolean processStatement(Statement general, HashMap<Integer, Set<
Statement stat = findGeneralStatement(general, forceall, mapExtPost);

if (stat != null) {
boolean complete = processStatement(stat, general.getFirst() == stat ? mapExtPost : new HashMap<Integer, Set<Integer>>());
boolean complete = processStatement(stat, general.getFirst() == stat ? mapExtPost : new HashMap<Integer, LinkedHashSet<Integer>>());

if (complete) {
// replace general purpose statement with simple one
Expand All @@ -389,7 +389,7 @@ private static boolean processStatement(Statement general, HashMap<Integer, Set<
return false;
}

mapExtPost = new HashMap<Integer, Set<Integer>>();
mapExtPost = new HashMap<Integer, LinkedHashSet<Integer>>();
mapRefreshed = true;
reducibility = 0;
}
Expand All @@ -410,14 +410,14 @@ private static boolean processStatement(Statement general, HashMap<Integer, Set<
break;
}
else {
mapExtPost = new HashMap<Integer, Set<Integer>>();
mapExtPost = new HashMap<Integer, LinkedHashSet<Integer>>();
}
}

return false;
}

private static Statement findGeneralStatement(Statement stat, boolean forceall, HashMap<Integer, Set<Integer>> mapExtPost) {
private static Statement findGeneralStatement(Statement stat, boolean forceall, HashMap<Integer, LinkedHashSet<Integer>> mapExtPost) {

VBStyleCollection<Statement, Integer> stats = stat.getStats();
VBStyleCollection<List<Integer>, Integer> vbPost;
Expand Down Expand Up @@ -595,7 +595,7 @@ private static boolean checkSynchronizedCompleteness(Statement head, HashSet<Sta
return true;
}

private static boolean findSimpleStatements(Statement stat, HashMap<Integer, Set<Integer>> mapExtPost) {
private static boolean findSimpleStatements(Statement stat, HashMap<Integer, LinkedHashSet<Integer>> mapExtPost) {

boolean found, success = false;

Expand Down Expand Up @@ -633,9 +633,9 @@ private static boolean findSimpleStatements(Statement stat, HashMap<Integer, Set
set.removeAll(setOldNodes);

if (setOldNodes.contains(key)) {
Set<Integer> setNew = mapExtPost.get(newid);
LinkedHashSet<Integer> setNew = mapExtPost.get(newid);
if (setNew == null) {
mapExtPost.put(newid, setNew = new HashSet<Integer>());
mapExtPost.put(newid, setNew = new LinkedHashSet<Integer>());
}
setNew.addAll(set);

Expand Down Expand Up @@ -666,7 +666,6 @@ private static boolean findSimpleStatements(Statement stat, HashMap<Integer, Set


private static Statement detectStatement(Statement head) {

Statement res;

if ((res = DoStatement.isHead(head)) != null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ public static void cleanUpEdges(RootStatement root) {

liftClosures(root);

lowContinueLabels(root, new HashSet<StatEdge>());
lowContinueLabels(root, new LinkedHashSet<StatEdge>());

lowClosures(root);
}
Expand Down Expand Up @@ -99,7 +99,7 @@ private static void removeNonImmediateEdges(Statement stat) {
}
}

public static void lowContinueLabels(Statement stat, HashSet<StatEdge> edges) {
public static void lowContinueLabels(Statement stat, LinkedHashSet<StatEdge> edges) {

boolean ok = (stat.type != Statement.TYPE_DO);
if (!ok) {
Expand Down Expand Up @@ -131,7 +131,7 @@ public static void lowContinueLabels(Statement stat, HashSet<StatEdge> edges) {
lowContinueLabels(st, edges);
}
else {
lowContinueLabels(st, new HashSet<StatEdge>());
lowContinueLabels(st, new LinkedHashSet<StatEdge>());
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ public class FastExtendedPostdominanceHelper {

private FastFixedSetFactory<Integer> factory;

public HashMap<Integer, Set<Integer>> getExtendedPostdominators(Statement statement) {
public HashMap<Integer, LinkedHashSet<Integer>> getExtendedPostdominators(Statement statement) {

this.statement = statement;

Expand Down Expand Up @@ -65,9 +65,11 @@ public HashMap<Integer, Set<Integer>> getExtendedPostdominators(Statement statem

filterOnDominance(filter);

HashMap<Integer, Set<Integer>> res = new HashMap<Integer, Set<Integer>>();
HashMap<Integer, LinkedHashSet<Integer>> res = new HashMap<Integer, LinkedHashSet<Integer>>();
for (Entry<Integer, FastFixedSet<Integer>> entry : mapExtPostdominators.entrySet()) {
res.put(entry.getKey(), entry.getValue().toPlainSet());
List<Integer> lst = new ArrayList<Integer>(entry.getValue().toPlainSet());
Collections.sort(lst); // Order matters!
res.put(entry.getKey(), new LinkedHashSet<Integer>(lst));
}

return res;
Expand All @@ -91,7 +93,7 @@ private void filterOnDominance(DominatorTreeExceptionFilter filter) {
Set<Statement> setVisited = new HashSet<Statement>();

setVisited.add(stack.getFirst());

while (!stack.isEmpty()) {

Statement stat = stack.removeFirst();
Expand All @@ -109,17 +111,17 @@ private void filterOnDominance(DominatorTreeExceptionFilter filter) {
setPostdoms.complement(path);
continue;
}

for (StatEdge edge : stat.getSuccessorEdges(StatEdge.TYPE_REGULAR)) {

Statement edge_destination = edge.getDestination();

if(!setVisited.contains(edge_destination)) {

stack.add(edge_destination);
stackPath.add(path.getCopy());
setVisited.add(edge_destination);

setVisited.add(edge_destination);
}
}
}
Expand Down

0 comments on commit 2f1f8ef

Please sign in to comment.