mirror of
https://github.com/Eaglercraft-TeaVM-Fork/eagler-teavm.git
synced 2024-12-22 08:14:09 -08:00
Fix bugs in optimized try/catch decompiler
This commit is contained in:
parent
1f5c5ce85e
commit
4b4af6dd4e
|
@ -93,13 +93,13 @@ public final class TeaVMRunner {
|
||||||
.create('c'));
|
.create('c'));
|
||||||
options.addOption(OptionBuilder
|
options.addOption(OptionBuilder
|
||||||
.withDescription("Wait for command after compilation, in order to enable hot recompilation")
|
.withDescription("Wait for command after compilation, in order to enable hot recompilation")
|
||||||
.withLongOpt("--wait")
|
.withLongOpt("wait")
|
||||||
.create('w'));
|
.create('w'));
|
||||||
options.addOption(OptionBuilder
|
options.addOption(OptionBuilder
|
||||||
.withArgName("classpath")
|
.withArgName("classpath")
|
||||||
.hasArgs()
|
.hasArgs()
|
||||||
.withDescription("Additional classpath that will be reloaded by TeaVM each time in wait mode")
|
.withDescription("Additional classpath that will be reloaded by TeaVM each time in wait mode")
|
||||||
.withLongOpt("--classpath")
|
.withLongOpt("classpath")
|
||||||
.create('p'));
|
.create('p'));
|
||||||
|
|
||||||
if (args.length == 0) {
|
if (args.length == 0) {
|
||||||
|
|
|
@ -143,9 +143,9 @@ class BreakEliminator implements StatementVisitor {
|
||||||
outerStatements = new HashSet<>();
|
outerStatements = new HashSet<>();
|
||||||
blockSuccessors = new HashMap<>();
|
blockSuccessors = new HashMap<>();
|
||||||
processSequence(statement.getProtectedBody());
|
processSequence(statement.getProtectedBody());
|
||||||
processSequence(statement.getHandler());
|
|
||||||
outerStatements = oldOuterStatements;
|
outerStatements = oldOuterStatements;
|
||||||
blockSuccessors = oldBlockSuccessors;
|
blockSuccessors = oldBlockSuccessors;
|
||||||
|
processSequence(statement.getHandler());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -289,7 +289,7 @@ public class Decompiler {
|
||||||
private AsyncMethodPart getRegularMethodStatement(Program program, int[] targetBlocks, boolean async) {
|
private AsyncMethodPart getRegularMethodStatement(Program program, int[] targetBlocks, boolean async) {
|
||||||
AsyncMethodPart result = new AsyncMethodPart();
|
AsyncMethodPart result = new AsyncMethodPart();
|
||||||
lastBlockId = 1;
|
lastBlockId = 1;
|
||||||
graph = ProgramUtils.buildControlFlowGraph(program);
|
graph = ProgramUtils.buildControlFlowGraphWithTryCatch(program);
|
||||||
int[] weights = new int[graph.size()];
|
int[] weights = new int[graph.size()];
|
||||||
for (int i = 0; i < weights.length; ++i) {
|
for (int i = 0; i < weights.length; ++i) {
|
||||||
weights[i] = program.basicBlockAt(i).getInstructions().size();
|
weights[i] = program.basicBlockAt(i).getInstructions().size();
|
||||||
|
@ -349,7 +349,9 @@ public class Decompiler {
|
||||||
List<Statement> blockPart = oldBlock.body.subList(bookmark.offset, oldBlock.body.size());
|
List<Statement> blockPart = oldBlock.body.subList(bookmark.offset, oldBlock.body.size());
|
||||||
tryCatchStmt.getProtectedBody().addAll(blockPart);
|
tryCatchStmt.getProtectedBody().addAll(blockPart);
|
||||||
blockPart.clear();
|
blockPart.clear();
|
||||||
blockPart.add(tryCatchStmt);
|
if (!tryCatchStmt.getProtectedBody().isEmpty()) {
|
||||||
|
blockPart.add(tryCatchStmt);
|
||||||
|
}
|
||||||
inheritedBookmarks.add(bookmark);
|
inheritedBookmarks.add(bookmark);
|
||||||
}
|
}
|
||||||
oldBlock.tryCatches.clear();
|
oldBlock.tryCatches.clear();
|
||||||
|
@ -439,7 +441,9 @@ public class Decompiler {
|
||||||
program.basicBlockAt(bookmark.exceptionHandler)));
|
program.basicBlockAt(bookmark.exceptionHandler)));
|
||||||
tryCatchStmt.getProtectedBody().addAll(block.body);
|
tryCatchStmt.getProtectedBody().addAll(block.body);
|
||||||
block.body.clear();
|
block.body.clear();
|
||||||
block.body.add(tryCatchStmt);
|
if (!tryCatchStmt.getProtectedBody().isEmpty()) {
|
||||||
|
block.body.add(tryCatchStmt);
|
||||||
|
}
|
||||||
block = block.parent;
|
block = block.parent;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -451,11 +455,15 @@ public class Decompiler {
|
||||||
List<Statement> blockPart = block.body.subList(bookmark.offset, block.body.size());
|
List<Statement> blockPart = block.body.subList(bookmark.offset, block.body.size());
|
||||||
tryCatchStmt.getProtectedBody().addAll(blockPart);
|
tryCatchStmt.getProtectedBody().addAll(blockPart);
|
||||||
blockPart.clear();
|
blockPart.clear();
|
||||||
blockPart.add(tryCatchStmt);
|
if (!tryCatchStmt.getProtectedBody().isEmpty()) {
|
||||||
|
blockPart.add(tryCatchStmt);
|
||||||
|
}
|
||||||
|
|
||||||
bookmark.block.tryCatches.remove(bookmark);
|
bookmark.block.tryCatches.remove(bookmark);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
tryCatchBookmarks.subList(start, tryCatchBookmarks.size()).clear();
|
||||||
|
|
||||||
// Add new bookmarks
|
// Add new bookmarks
|
||||||
for (int i = start; i < tryCatchBlocks.size(); ++i) {
|
for (int i = start; i < tryCatchBlocks.size(); ++i) {
|
||||||
TryCatchBlock tryCatch = tryCatchBlocks.get(i);
|
TryCatchBlock tryCatch = tryCatchBlocks.get(i);
|
||||||
|
|
Loading…
Reference in New Issue
Block a user