minor try improvement

This commit is contained in:
Jindra Petřík
2021-02-08 20:15:19 +01:00
parent 14403e034b
commit 914a2bb701
2 changed files with 14 additions and 1 deletions
@@ -83,6 +83,8 @@ public class AVM2LocalData extends BaseLocalData {
public Map<Integer, GraphPart> defaultParts = new HashMap<>();
public Map<Integer, Integer> switchedRegs = new HashMap<>();
public Map<Integer, GraphPart> pushDefaultPart = new HashMap<>();
/**
* exception index -> switch throw part
@@ -159,6 +161,7 @@ public class AVM2LocalData extends BaseLocalData {
inGetLoops = localData.inGetLoops;
parsedExceptionIds = localData.parsedExceptionIds;
finallyTargetParts = localData.finallyTargetParts;
pushDefaultPart = localData.pushDefaultPart;
}
public AVM2ConstantPool getConstants() {
@@ -316,8 +316,12 @@ public class AVM2Graph extends Graph {
} else if (ins.definition instanceof PushByteIns) {
defaultPushByte = ins.operands[0];
localData.pushDefaultPart.put(e, prevFinallyEndPart);
} else if (ins.definition instanceof JumpIns) {
} else {
if(localData.pushDefaultPart.containsKey(e)){
localData.pushDefaultPart.remove(e);
}
defaultPushByte = null;
break;
}
@@ -333,6 +337,7 @@ public class AVM2Graph extends Graph {
} else if (ins.definition instanceof PushByteIns) {
defaultPushByte = ins.operands[0];
localData.pushDefaultPart.put(e, prevFinallyEndPart);
break;
} else {
break;
@@ -1049,7 +1054,7 @@ public class AVM2Graph extends Graph {
if (afterPart == null) {
afterPart = searchFirstPartOutSideTryCatch(localData, finallyException, loops, allParts);
}
if (afterPart != null) {
tryStopPart.add(afterPart);
}
@@ -1061,6 +1066,11 @@ public class AVM2Graph extends Graph {
afterPart = null;
}
}
if (afterPart == null && localData.pushDefaultPart.containsKey(finallyIndex)){
exAfterPart = localData.pushDefaultPart.get(finallyIndex);
tryStopPart.add(exAfterPart);
}
tryCommands = printGraph(foundGotos, partCodes, partCodePos, visited, localData, stack, allParts, null, part, tryStopPart, loops, throwStates, staticOperation, path);
makeAllCommands(tryCommands, stack);