AS3: Faster remove ignored without reparsing

This commit is contained in:
Jindra Petřík
2015-06-21 15:42:24 +02:00
parent 108f86dd98
commit e49362cf47
2 changed files with 5 additions and 27 deletions

View File

@@ -2525,35 +2525,13 @@ public class AVM2Code implements Cloneable {
//restoreControlFlowPass(constants, body, true);
}
/*private void removeIgnored(MethodBody body) {
for (int rem = code.size() - 1; rem >= 0; rem--) {
if (code.get(rem).ignored) {
removeInstruction(rem, body);
}
}
}*/
public void removeIgnored(AVM2ConstantPool constants, Trait trait, MethodInfo info, MethodBody body) throws InterruptedException {
try {
List<Integer> outputMap = new ArrayList<>();
HighlightedTextWriter writer = new HighlightedTextWriter(Configuration.getCodeFormatting(), false);
toASMSource(constants, trait, info, body, outputMap, ScriptExportMode.PCODE, writer);
String src = writer.toString();
AVM2Code acode = ASM3Parser.parse(new StringReader(src), constants, trait, body, info);
for (int i = 0; i < acode.code.size(); i++) {
if (outputMap.size() > i) {
int tpos = outputMap.get(i);
if (tpos == -1) {
} else if (code.get(tpos).mappedOffset >= 0) {
acode.code.get(i).mappedOffset = code.get(tpos).mappedOffset;
} else {
acode.code.get(i).mappedOffset = pos2adr(tpos);
}
}
for (int i = 0; i < code.size(); i++) {
if (code.get(i).ignored) {
removeInstruction(i, body);
i--;
}
this.code = acode.code;
} catch (IOException | AVM2ParseException ex) {
}
invalidateCache();
}
public int removeDeadCode(AVM2ConstantPool constants, Trait trait, MethodInfo info, MethodBody body) throws InterruptedException {

View File

@@ -233,7 +233,7 @@ public class AVM2DeobfuscatorRegisters extends AVM2DeobfuscatorSimple {
}
}
} catch (EmptyStackException | TranslateException | InterruptedException ex) {
ex.printStackTrace();
//ignore
}
}