diff --git a/core/src/main/java/org/teavm/common/IrreducibleGraphConverter.java b/core/src/main/java/org/teavm/common/IrreducibleGraphConverter.java index 17cd3fe83..fb043184b 100644 --- a/core/src/main/java/org/teavm/common/IrreducibleGraphConverter.java +++ b/core/src/main/java/org/teavm/common/IrreducibleGraphConverter.java @@ -35,7 +35,7 @@ class IrreducibleGraphConverter { private IntSet[] nodeCopies; private IntegerArray nodeOriginals; - public void convertToReducible(Graph cfg, int[] weight, GraphSplittingBackend backend) { + void convertToReducible(Graph cfg, int[] weight, GraphSplittingBackend backend) { this.backend = backend; nodeCopies = new IntOpenHashSet[cfg.size()]; diff --git a/core/src/main/java/org/teavm/model/util/AsyncProgramSplitter.java b/core/src/main/java/org/teavm/model/util/AsyncProgramSplitter.java index ea6e47622..ac6971df7 100644 --- a/core/src/main/java/org/teavm/model/util/AsyncProgramSplitter.java +++ b/core/src/main/java/org/teavm/model/util/AsyncProgramSplitter.java @@ -164,12 +164,16 @@ public class AsyncProgramSplitter { } for (Part part : parts) { + Graph graph = ProgramUtils.buildControlFlowGraph(part.program); + if (!GraphUtils.isIrreducible(graph)) { + continue; + } + IntegerArray blockSuccessors = IntegerArray.of(part.blockSuccessors); IntegerArray originalBlocks = IntegerArray.of(part.originalBlocks); List splitPoints = new ArrayList<>(Arrays.asList(part.splitPoints)); AsyncProgramSplittingBackend splittingBackend = new AsyncProgramSplittingBackend( new ProgramNodeSplittingBackend(part.program), blockSuccessors, originalBlocks, splitPoints); - Graph graph = ProgramUtils.buildControlFlowGraph(part.program); int[] weights = new int[graph.size()]; for (int i = 0; i < part.program.basicBlockCount(); ++i) { weights[i] = part.program.basicBlockAt(i).instructionCount(); @@ -278,7 +282,7 @@ public class AsyncProgramSplitter { private IntegerArray originalBlocks; private List splitPoints; - public AsyncProgramSplittingBackend(GraphSplittingBackend inner, IntegerArray blockSuccessors, + AsyncProgramSplittingBackend(GraphSplittingBackend inner, IntegerArray blockSuccessors, IntegerArray originalBlocks, List splitPoints) { this.inner = inner; this.blockSuccessors = blockSuccessors; diff --git a/core/src/main/java/org/teavm/model/util/BasicBlockMapper.java b/core/src/main/java/org/teavm/model/util/BasicBlockMapper.java index 1216d8c75..c2b92591e 100644 --- a/core/src/main/java/org/teavm/model/util/BasicBlockMapper.java +++ b/core/src/main/java/org/teavm/model/util/BasicBlockMapper.java @@ -43,10 +43,9 @@ public class BasicBlockMapper extends AbstractInstructionVisitor { public void transform(BasicBlock block) { Instruction lastInsn = block.getLastInstruction(); - if (lastInsn == null) { - return; + if (lastInsn != null) { + lastInsn.acceptVisitor(this); } - lastInsn.acceptVisitor(this); for (Phi phi : block.getPhis()) { for (Incoming incoming : phi.getIncomings()) { diff --git a/core/src/main/java/org/teavm/model/util/ProgramNodeSplittingBackend.java b/core/src/main/java/org/teavm/model/util/ProgramNodeSplittingBackend.java index e281a61fe..8939fc9c5 100644 --- a/core/src/main/java/org/teavm/model/util/ProgramNodeSplittingBackend.java +++ b/core/src/main/java/org/teavm/model/util/ProgramNodeSplittingBackend.java @@ -37,6 +37,7 @@ public class ProgramNodeSplittingBackend implements GraphSplittingBackend { BasicBlock block = program.basicBlockAt(node); BasicBlock blockCopy = program.createBasicBlock(); blockCopy.addAll(ProgramUtils.copyInstructions(block.getFirstInstruction(), null, program)); + blockCopy.getTryCatchBlocks().addAll(ProgramUtils.copyTryCatches(block, program)); copies[i] = blockCopy.getIndex(); map.put(nodes[i], copies[i] + 1); } diff --git a/tools/idea/jps-common/teavm-jps-common.iml b/tools/idea/jps-common/teavm-jps-common.iml index f8f512fdd..c5cba2620 100644 --- a/tools/idea/jps-common/teavm-jps-common.iml +++ b/tools/idea/jps-common/teavm-jps-common.iml @@ -17,6 +17,7 @@ +