mirror of
https://github.com/Eaglercraft-TeaVM-Fork/eagler-teavm.git
synced 2024-12-22 16:14:10 -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 IntSet[] nodeCopies;
|
||||||
private IntegerArray nodeOriginals;
|
private IntegerArray nodeOriginals;
|
||||||
|
|
||||||
public void convertToReducible(Graph cfg, int[] weight, GraphSplittingBackend backend) {
|
void convertToReducible(Graph cfg, int[] weight, GraphSplittingBackend backend) {
|
||||||
this.backend = backend;
|
this.backend = backend;
|
||||||
|
|
||||||
nodeCopies = new IntOpenHashSet[cfg.size()];
|
nodeCopies = new IntOpenHashSet[cfg.size()];
|
||||||
|
|
|
@ -164,12 +164,16 @@ public class AsyncProgramSplitter {
|
||||||
}
|
}
|
||||||
|
|
||||||
for (Part part : parts) {
|
for (Part part : parts) {
|
||||||
|
Graph graph = ProgramUtils.buildControlFlowGraph(part.program);
|
||||||
|
if (!GraphUtils.isIrreducible(graph)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
IntegerArray blockSuccessors = IntegerArray.of(part.blockSuccessors);
|
IntegerArray blockSuccessors = IntegerArray.of(part.blockSuccessors);
|
||||||
IntegerArray originalBlocks = IntegerArray.of(part.originalBlocks);
|
IntegerArray originalBlocks = IntegerArray.of(part.originalBlocks);
|
||||||
List<Instruction> splitPoints = new ArrayList<>(Arrays.asList(part.splitPoints));
|
List<Instruction> splitPoints = new ArrayList<>(Arrays.asList(part.splitPoints));
|
||||||
AsyncProgramSplittingBackend splittingBackend = new AsyncProgramSplittingBackend(
|
AsyncProgramSplittingBackend splittingBackend = new AsyncProgramSplittingBackend(
|
||||||
new ProgramNodeSplittingBackend(part.program), blockSuccessors, originalBlocks, splitPoints);
|
new ProgramNodeSplittingBackend(part.program), blockSuccessors, originalBlocks, splitPoints);
|
||||||
Graph graph = ProgramUtils.buildControlFlowGraph(part.program);
|
|
||||||
int[] weights = new int[graph.size()];
|
int[] weights = new int[graph.size()];
|
||||||
for (int i = 0; i < part.program.basicBlockCount(); ++i) {
|
for (int i = 0; i < part.program.basicBlockCount(); ++i) {
|
||||||
weights[i] = part.program.basicBlockAt(i).instructionCount();
|
weights[i] = part.program.basicBlockAt(i).instructionCount();
|
||||||
|
@ -278,7 +282,7 @@ public class AsyncProgramSplitter {
|
||||||
private IntegerArray originalBlocks;
|
private IntegerArray originalBlocks;
|
||||||
private List<Instruction> splitPoints;
|
private List<Instruction> splitPoints;
|
||||||
|
|
||||||
public AsyncProgramSplittingBackend(GraphSplittingBackend inner, IntegerArray blockSuccessors,
|
AsyncProgramSplittingBackend(GraphSplittingBackend inner, IntegerArray blockSuccessors,
|
||||||
IntegerArray originalBlocks, List<Instruction> splitPoints) {
|
IntegerArray originalBlocks, List<Instruction> splitPoints) {
|
||||||
this.inner = inner;
|
this.inner = inner;
|
||||||
this.blockSuccessors = blockSuccessors;
|
this.blockSuccessors = blockSuccessors;
|
||||||
|
|
|
@ -43,10 +43,9 @@ public class BasicBlockMapper extends AbstractInstructionVisitor {
|
||||||
|
|
||||||
public void transform(BasicBlock block) {
|
public void transform(BasicBlock block) {
|
||||||
Instruction lastInsn = block.getLastInstruction();
|
Instruction lastInsn = block.getLastInstruction();
|
||||||
if (lastInsn == null) {
|
if (lastInsn != null) {
|
||||||
return;
|
|
||||||
}
|
|
||||||
lastInsn.acceptVisitor(this);
|
lastInsn.acceptVisitor(this);
|
||||||
|
}
|
||||||
|
|
||||||
for (Phi phi : block.getPhis()) {
|
for (Phi phi : block.getPhis()) {
|
||||||
for (Incoming incoming : phi.getIncomings()) {
|
for (Incoming incoming : phi.getIncomings()) {
|
||||||
|
|
|
@ -37,6 +37,7 @@ public class ProgramNodeSplittingBackend implements GraphSplittingBackend {
|
||||||
BasicBlock block = program.basicBlockAt(node);
|
BasicBlock block = program.basicBlockAt(node);
|
||||||
BasicBlock blockCopy = program.createBasicBlock();
|
BasicBlock blockCopy = program.createBasicBlock();
|
||||||
blockCopy.addAll(ProgramUtils.copyInstructions(block.getFirstInstruction(), null, program));
|
blockCopy.addAll(ProgramUtils.copyInstructions(block.getFirstInstruction(), null, program));
|
||||||
|
blockCopy.getTryCatchBlocks().addAll(ProgramUtils.copyTryCatches(block, program));
|
||||||
copies[i] = blockCopy.getIndex();
|
copies[i] = blockCopy.getIndex();
|
||||||
map.put(nodes[i], copies[i] + 1);
|
map.put(nodes[i], copies[i] + 1);
|
||||||
}
|
}
|
||||||
|
|
|
@ -17,6 +17,7 @@
|
||||||
<JAVADOC />
|
<JAVADOC />
|
||||||
<SOURCES>
|
<SOURCES>
|
||||||
<root url="file://$MODULE_DIR$/../../core/src/main/java" />
|
<root url="file://$MODULE_DIR$/../../core/src/main/java" />
|
||||||
|
<root url="file://$MODULE_DIR$/../../../core/src/main/java" />
|
||||||
</SOURCES>
|
</SOURCES>
|
||||||
</library>
|
</library>
|
||||||
</orderEntry>
|
</orderEntry>
|
||||||
|
|
Loading…
Reference in New Issue
Block a user