mirror of
https://github.com/Eaglercraft-TeaVM-Fork/eagler-teavm.git
synced 2024-12-22 08:14:09 -08:00
Fix async splitting of blocks with exception handlers in some cases. Fix https://github.com/konsoletyper/teavm/issues/234
This commit is contained in:
parent
5c936878a7
commit
55836d6ed7
|
@ -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()];
|
||||
|
|
|
@ -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<Instruction> 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<Instruction> splitPoints;
|
||||
|
||||
public AsyncProgramSplittingBackend(GraphSplittingBackend inner, IntegerArray blockSuccessors,
|
||||
AsyncProgramSplittingBackend(GraphSplittingBackend inner, IntegerArray blockSuccessors,
|
||||
IntegerArray originalBlocks, List<Instruction> splitPoints) {
|
||||
this.inner = inner;
|
||||
this.blockSuccessors = blockSuccessors;
|
||||
|
|
|
@ -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()) {
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
|
|
@ -17,6 +17,7 @@
|
|||
<JAVADOC />
|
||||
<SOURCES>
|
||||
<root url="file://$MODULE_DIR$/../../core/src/main/java" />
|
||||
<root url="file://$MODULE_DIR$/../../../core/src/main/java" />
|
||||
</SOURCES>
|
||||
</library>
|
||||
</orderEntry>
|
||||
|
|
Loading…
Reference in New Issue
Block a user