mirror of
https://github.com/Eaglercraft-TeaVM-Fork/eagler-teavm.git
synced 2024-12-22 08:14:09 -08:00
When copying basic blocks in async splitter, copy exception variable as well. Fix https://github.com/konsoletyper/teavm/issues/230
This commit is contained in:
parent
c7829a77cf
commit
02d8439920
|
@ -142,6 +142,7 @@ public class AsyncProgramSplitter {
|
||||||
}
|
}
|
||||||
targetBlock.addAll(ProgramUtils.copyInstructions(last, null, targetBlock.getProgram()));
|
targetBlock.addAll(ProgramUtils.copyInstructions(last, null, targetBlock.getProgram()));
|
||||||
targetBlock.getTryCatchBlocks().addAll(ProgramUtils.copyTryCatches(sourceBlock, targetBlock.getProgram()));
|
targetBlock.getTryCatchBlocks().addAll(ProgramUtils.copyTryCatches(sourceBlock, targetBlock.getProgram()));
|
||||||
|
targetBlock.setExceptionVariable(sourceBlock.getExceptionVariable());
|
||||||
for (TryCatchBlock tryCatch : targetBlock.getTryCatchBlocks()) {
|
for (TryCatchBlock tryCatch : targetBlock.getTryCatchBlocks()) {
|
||||||
if (tryCatch.getHandler() != null) {
|
if (tryCatch.getHandler() != null) {
|
||||||
Step next = new Step();
|
Step next = new Step();
|
||||||
|
|
|
@ -38,6 +38,7 @@ public class ProgramNodeSplittingBackend implements GraphSplittingBackend {
|
||||||
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));
|
blockCopy.getTryCatchBlocks().addAll(ProgramUtils.copyTryCatches(block, program));
|
||||||
|
blockCopy.setExceptionVariable(block.getExceptionVariable());
|
||||||
copies[i] = blockCopy.getIndex();
|
copies[i] = blockCopy.getIndex();
|
||||||
map.put(nodes[i], copies[i] + 1);
|
map.put(nodes[i], copies[i] + 1);
|
||||||
}
|
}
|
||||||
|
@ -45,11 +46,11 @@ public class ProgramNodeSplittingBackend implements GraphSplittingBackend {
|
||||||
int mappedIndex = map.get(block);
|
int mappedIndex = map.get(block);
|
||||||
return mappedIndex == 0 ? block : mappedIndex - 1;
|
return mappedIndex == 0 ? block : mappedIndex - 1;
|
||||||
});
|
});
|
||||||
for (int i = 0; i < copies.length; ++i) {
|
for (int copy : copies) {
|
||||||
copyBlockMapper.transform(program.basicBlockAt(copies[i]));
|
copyBlockMapper.transform(program.basicBlockAt(copy));
|
||||||
}
|
}
|
||||||
for (int i = 0; i < domain.length; ++i) {
|
for (int domainNode : domain) {
|
||||||
copyBlockMapper.transform(program.basicBlockAt(domain[i]));
|
copyBlockMapper.transform(program.basicBlockAt(domainNode));
|
||||||
}
|
}
|
||||||
return copies;
|
return copies;
|
||||||
}
|
}
|
||||||
|
|
|
@ -18,9 +18,11 @@ package org.teavm.vm;
|
||||||
import static org.junit.Assert.*;
|
import static org.junit.Assert.*;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
import org.junit.runner.RunWith;
|
import org.junit.runner.RunWith;
|
||||||
|
import org.teavm.interop.Async;
|
||||||
import org.teavm.jso.JSBody;
|
import org.teavm.jso.JSBody;
|
||||||
import org.teavm.junit.SkipJVM;
|
import org.teavm.junit.SkipJVM;
|
||||||
import org.teavm.junit.TeaVMTestRunner;
|
import org.teavm.junit.TeaVMTestRunner;
|
||||||
|
import org.teavm.platform.async.AsyncCallback;
|
||||||
|
|
||||||
@RunWith(TeaVMTestRunner.class)
|
@RunWith(TeaVMTestRunner.class)
|
||||||
public class VMTest {
|
public class VMTest {
|
||||||
|
@ -152,6 +154,23 @@ public class VMTest {
|
||||||
assertEquals(30, s);
|
assertEquals(30, s);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@SkipJVM
|
||||||
|
public void asyncTryCatch() {
|
||||||
|
try {
|
||||||
|
throwExceptionAsync();
|
||||||
|
fail("Exception should have been thrown");
|
||||||
|
} catch (RuntimeException e) {
|
||||||
|
assertEquals("OK", e.getMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Async
|
||||||
|
private static native void throwExceptionAsync();
|
||||||
|
private static void throwExceptionAsync(AsyncCallback<Void> callback) {
|
||||||
|
callback.error(new RuntimeException("OK"));
|
||||||
|
}
|
||||||
|
|
||||||
@JSBody(script = "return [1, 2]")
|
@JSBody(script = "return [1, 2]")
|
||||||
private static native int[] createArray();
|
private static native int[] createArray();
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user