When splitting async program, don't process same blocks twice

The old assumption was: if a block has instructions, it was already processed. However, that might be not true in some cases. This led to duplication of exception handlers in some blocks which in turn broken decompiler. From now on processed blocks are stored in a set.
This commit is contained in:
Alexey Andreev 2018-01-07 16:04:11 +03:00
parent a445b1bef8
commit 0c8013dfcf

View File

@ -19,6 +19,7 @@ import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Queue;
@ -67,11 +68,12 @@ public class AsyncProgramSplitter {
initialStep.targetPart = initialPart;
Queue<Step> queue = new ArrayDeque<>();
queue.add(initialStep);
Set<BasicBlock> visitedBlocks = new HashSet<>();
taskLoop: while (!queue.isEmpty()) {
Step step = queue.remove();
BasicBlock targetBlock = step.targetPart.program.basicBlockAt(step.source);
if (targetBlock.instructionCount() > 0) {
if (!visitedBlocks.add(targetBlock)) {
continue;
}
BasicBlock sourceBlock = program.basicBlockAt(step.source);