diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/AVM2Code.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/AVM2Code.java index 86bcc370d..c95d45579 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/AVM2Code.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/AVM2Code.java @@ -324,8 +324,6 @@ public class AVM2Code implements Cloneable { private static final boolean DEBUG_MODE = false; - public static final boolean USE_KILL_INS = false; - public static int toSourceLimit = -1; public List code; @@ -1488,33 +1486,6 @@ public class AVM2Code implements Cloneable { } } - public List clearTemporaryRegisters(List input) { - List output = new ArrayList<>(input); - for (int i = 0; i < output.size(); i++) { - if (output.get(i) instanceof SetLocalAVM2Item) { - if (USE_KILL_INS && isKilled(((SetLocalAVM2Item) output.get(i)).regIndex, 0, code.size() - 1)) { - SetLocalAVM2Item lsi = (SetLocalAVM2Item) output.get(i); - if (i + 1 < output.size()) { - if (output.get(i + 1) instanceof ExitItem) { - GraphTargetItem rv = output.get(i + 1); - if (rv.value instanceof LocalRegAVM2Item) { - LocalRegAVM2Item lr = (LocalRegAVM2Item) rv.value; - if (lr.regIndex == lsi.regIndex) { - rv.value = lsi.value; - } - } - } - } - output.remove(i); - i--; - } - } else if (output.get(i) instanceof WithAVM2Item) { - clearTemporaryRegisters(((WithAVM2Item) output.get(i)).items); - } - } - return output; - } - public int fixIPAfterDebugLine(int ip) { if (code.isEmpty()) { return ip; @@ -1629,24 +1600,7 @@ public class AVM2Code implements Cloneable { } } }*/ - if (USE_KILL_INS && (ins.definition instanceof GetLocalTypeIns) && (!output.isEmpty()) && (output.get(output.size() - 1) instanceof SetLocalAVM2Item) && (((SetLocalAVM2Item) output.get(output.size() - 1)).regIndex == ((GetLocalTypeIns) ins.definition).getRegisterId(ins)) && isKilled(((SetLocalAVM2Item) output.get(output.size() - 1)).regIndex, start, end)) { - SetLocalAVM2Item slt = (SetLocalAVM2Item) output.remove(output.size() - 1); - stack.push(slt.getValue()); - ip++; - } else if (USE_KILL_INS && (ins.definition instanceof SetLocalTypeIns) && (ip + 1 <= end) && (isKilled(((SetLocalTypeIns) ins.definition).getRegisterId(ins), ip, end))) { // set_local_x,get_local_x..kill x - AVM2Instruction insAfter = code.get(ip + 1); - if ((insAfter.definition instanceof GetLocalTypeIns) && (((GetLocalTypeIns) insAfter.definition).getRegisterId(insAfter) == ((SetLocalTypeIns) ins.definition).getRegisterId(ins))) { - GraphTargetItem before = stack.peek(); - ins.definition.translate(setLocalPosToGetLocalPos, lineStartItem, isStatic, scriptIndex, classIndex, localRegs, stack, scopeStack, ins, output, body, abc, localRegNames, fullyQualifiedNames, path, localRegAssigmentIps, ip, refs, this, thisHasDefaultToPrimitive); - stack.push(before); - ip += 2; - continue iploop; - } else { - ins.definition.translate(setLocalPosToGetLocalPos, lineStartItem, isStatic, scriptIndex, classIndex, localRegs, stack, scopeStack, ins, output, body, abc, localRegNames, fullyQualifiedNames, path, localRegAssigmentIps, ip, refs, this, thisHasDefaultToPrimitive); - ip++; - continue iploop; - } - } else if (!USE_KILL_INS && (ins.definition instanceof SetLocalTypeIns) && (ip + 1 <= end)) { // set_local_x,get_local_x.. no other local_x get + if ((ins.definition instanceof SetLocalTypeIns) && (ip + 1 <= end)) { // set_local_x,get_local_x.. no other local_x get AVM2Instruction insAfter = code.get(ip + 1); Set usages = setLocalPosToGetLocalPos.get(ip); @@ -1684,59 +1638,6 @@ public class AVM2Code implements Cloneable { } else if (processJumps && (insAfter.definition instanceof IfTrueIns)) { //stack.add("(" + stack.pop() + ")||"); isAnd = false; - } else if (USE_KILL_INS && insAfter.definition instanceof SetLocalTypeIns) { - // chained assignments - int reg = (((SetLocalTypeIns) insAfter.definition).getRegisterId(insAfter)); - for (int t = ip + 1; t <= end - 1; t++) { - if (code.get(t).definition instanceof KillIns) { - if (code.get(t).operands[0] == reg) { - break; - } - } - if (code.get(t).definition instanceof GetLocalTypeIns) { - if (((GetLocalTypeIns) code.get(t).definition).getRegisterId(code.get(t)) == reg) { - if (code.get(t + 1).definition instanceof KillIns) { - if (code.get(t + 1).operands[0] == reg) { - ConvertOutput assignment = toSourceOutput(setLocalPosToGetLocalPos, thisHasDefaultToPrimitive, lineStartItem, path, part, processJumps, isStatic, scriptIndex, classIndex, localRegs, stack, scopeStack, abc, body, ip + 2, t - 1, localRegNames, fullyQualifiedNames, visited, localRegAssigmentIps, refs); - if (!assignment.output.isEmpty()) { - GraphTargetItem tar = assignment.output.remove(assignment.output.size() - 1); - tar.firstPart = part; - stack.push(tar); - ip = t + 2; - - continue iploop; - } - } - } - } - } - } - if (USE_KILL_INS && !isKilled(reg, 0, end)) { - GraphTargetItem vx = stack.pop().getThroughDuplicate(); - int dupCnt = 1; - for (int i = ip - 1; i >= start; i--) { - if (code.get(i).definition instanceof DupIns) { - if (stack.isEmpty()) { - break; // FIXME?o - } - stack.pop(); - dupCnt++; - //stack.push(v); - } else { - break; - } - } - for (int i = 0; i < dupCnt; i++) { - stack.push(new LocalRegAVM2Item(ins, (AVM2Instruction) lineStartItem.getVal(), reg, vx)); - } - stack.push(vx); - } else { - ins.definition.translate(setLocalPosToGetLocalPos, lineStartItem, isStatic, scriptIndex, classIndex, localRegs, stack, scopeStack, ins, output, body, abc, localRegNames, fullyQualifiedNames, path, localRegAssigmentIps, ip, refs, this, thisHasDefaultToPrimitive); - } - ip++; - break; - //} - } else { ins.definition.translate(setLocalPosToGetLocalPos, lineStartItem, isStatic, scriptIndex, classIndex, localRegs, stack, scopeStack, ins, output, body, abc, localRegNames, fullyQualifiedNames, path, localRegAssigmentIps, ip, refs, this, thisHasDefaultToPrimitive); ip++; diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/graph/AVM2Graph.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/graph/AVM2Graph.java index 7925450eb..5325b622d 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/graph/AVM2Graph.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/graph/AVM2Graph.java @@ -604,26 +604,6 @@ public class AVM2Graph extends Graph { return ret; } - if (part.nextParts.isEmpty()) { - if (avm2code.code.get(part.end).definition instanceof ReturnValueIns) { //returns in finally clause - if (part.getHeight() >= 3) { - if (AVM2Code.USE_KILL_INS && avm2code.code.get(part.getPosAt(part.getHeight() - 2)).definition instanceof KillIns) { - if (avm2code.code.get(part.getPosAt(part.getHeight() - 3)).definition instanceof GetLocalTypeIns) { - if (output.size() >= 2) { - if (output.get(output.size() - 2) instanceof SetLocalAVM2Item) { - ret = new ArrayList<>(); - ret.addAll(output); - ret.remove(ret.size() - 1); - GraphTargetItem v = ((SetLocalAVM2Item) output.get(output.size() - 2)).value; - ret.add(new ReturnValueAVM2Item(avm2code.code.get(part.end), (AVM2Instruction) v.getLineStartItem(), v)); - return ret; - } - } - } - } - } - } - } if ((avm2code.code.get(part.end).definition instanceof LookupSwitchIns) && (ignoredSwitches.containsValue(part.end) || ignoredSwitches2.contains(part.end))) { ret = new ArrayList<>(); ret.addAll(output); @@ -1211,7 +1191,7 @@ public class AVM2Graph extends Graph { continue; } } - if (!AVM2Code.USE_KILL_INS && usages.size() <= 1) { + if (usages.size() <= 1) { if (i + 2 < list.size()) { if ((list.get(i + 1) instanceof IntegerValueAVM2Item) && (list.get(i + 2) instanceof ReturnValueAVM2Item) && (list.get(i + 2).value instanceof LocalRegAVM2Item) @@ -1239,44 +1219,10 @@ public class AVM2Graph extends Graph { } } } - if (AVM2Code.USE_KILL_INS && avm2code.isKilled(ri.regIndex, 0, Integer.MAX_VALUE)) { - if (i + 1 < list.size()) { - if (list.get(i + 1) instanceof SwitchItem) { - SwitchItem si = (SwitchItem) list.get(i + 1); - if (si.switchedObject instanceof LocalRegAVM2Item) { - if (((LocalRegAVM2Item) si.switchedObject).regIndex == ri.regIndex) { - si.switchedObject = ri.value; - } - } - } - } - if (i + 2 < list.size()) { - if ((list.get(i + 1) instanceof IntegerValueAVM2Item) && (list.get(i + 2) instanceof ReturnValueAVM2Item)) { - ReturnValueAVM2Item r = (ReturnValueAVM2Item) list.get(i + 2); - r.value = ri.value; - list.remove(i + 1); - continue; - } - if ((list.get(i + 1) instanceof IntegerValueAVM2Item) && (list.get(i + 2) instanceof ThrowAVM2Item)) { - ThrowAVM2Item t = (ThrowAVM2Item) list.get(i + 2); - t.value = ri.value; - list.remove(i + 1); - //continue; - } - } else if (i + 1 < list.size()) { - if (list.get(i + 1) instanceof IntegerValueAVM2Item) { - list.remove(i + 1); - } - } - } } } - List ret = avm2code.clearTemporaryRegisters(list); - if (ret != list) { - list.clear(); - list.addAll(ret); - } + List ret = list; for (int i = 0; i < list.size(); i++) { if (list.get(i) instanceof SetTypeAVM2Item) { if (((SetTypeAVM2Item) list.get(i)).getValue() instanceof ExceptionAVM2Item) { @@ -1337,22 +1283,6 @@ public class AVM2Graph extends Graph { return finalProcess; } - @Override - protected boolean isEmpty(List output) { - if (super.isEmpty(output)) { - return true; - } - for (GraphTargetItem i : output) { - if (i instanceof SetLocalAVM2Item) { - if (AVM2Code.USE_KILL_INS && avm2code.isKilled(((SetLocalAVM2Item) i).regIndex, 0, avm2code.code.size() - 1)) { - continue; - } - } - return false; - } - return true; - } - @Override public AVM2LocalData prepareBranchLocalData(BaseLocalData localData) { AVM2LocalData aLocalData = (AVM2LocalData) localData; @@ -1363,11 +1293,6 @@ public class AVM2Graph extends Graph { return ret; } - @Override - protected List filter(List list) { - return avm2code.clearTemporaryRegisters(list); - } - @Override protected void checkSwitch(BaseLocalData localData, SwitchItem switchItem, Map otherSides, List output) { if (output.isEmpty()) {