mirror of
https://git.huckle.dev/Huckles-Minecraft-Archive/jpexs-decompiler.git
synced 2026-09-24 23:50:47 +00:00
Position cache (Faster decompiling)
Not clearing killed registers
This commit is contained in:
@@ -797,27 +797,36 @@ public class AVM2Code {
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private boolean cacheActual=false;
|
||||||
|
private List<Long> posCache;
|
||||||
|
private void buildCache()
|
||||||
|
{
|
||||||
|
posCache=new ArrayList<Long>();
|
||||||
|
long a = 0;
|
||||||
|
for (int i = 0; i < code.size(); i++) {
|
||||||
|
posCache.add(a);
|
||||||
|
a += code.get(i).getBytes().length;
|
||||||
|
}
|
||||||
|
posCache.add(a);
|
||||||
|
cacheActual=true;
|
||||||
|
}
|
||||||
|
|
||||||
public int adr2pos(long address) throws ConvertException {
|
public int adr2pos(long address) throws ConvertException {
|
||||||
int a = 0;
|
if(!cacheActual){
|
||||||
for (int i = 0; i < code.size(); i++) {
|
buildCache();
|
||||||
if (a == address) {
|
}
|
||||||
return i;
|
int ret=posCache.indexOf(address);
|
||||||
}
|
if(ret == -1) {
|
||||||
a += code.get(i).getBytes().length;
|
throw new ConvertException("Bad jump", -1);
|
||||||
}
|
}
|
||||||
if (a == address) {
|
return ret;
|
||||||
return code.size();
|
|
||||||
}
|
|
||||||
throw new ConvertException("Bad jump", -1);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public int pos2adr(int pos) {
|
public int pos2adr(int pos) {
|
||||||
int a = 0;
|
if(!cacheActual){
|
||||||
for (int i = 0; i < pos; i++) {
|
buildCache();
|
||||||
a += code.get(i).getBytes().length;
|
}
|
||||||
}
|
return posCache.get(pos).intValue();
|
||||||
|
|
||||||
return a;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private static String listToString(List<TreeItem> stack, ConstantPool constants) {
|
private static String listToString(List<TreeItem> stack, ConstantPool constants) {
|
||||||
@@ -1713,7 +1722,7 @@ public HashMap<Integer,String> getLocalRegNamesFromDebug(ABC abc){
|
|||||||
}
|
}
|
||||||
if (debugMode)
|
if (debugMode)
|
||||||
System.out.println("CLOSE SubSource:" + start + "-" + end + " " + code.get(start).toString() + " to " + code.get(end).toString());
|
System.out.println("CLOSE SubSource:" + start + "-" + end + " " + code.get(start).toString() + " to " + code.get(end).toString());
|
||||||
clearKilledAssigments(output);
|
//clearKilledAssigments(output);
|
||||||
return new ConvertOutput(stack, output);
|
return new ConvertOutput(stack, output);
|
||||||
} catch (ConvertException cex) {
|
} catch (ConvertException cex) {
|
||||||
throw cex;
|
throw cex;
|
||||||
@@ -2349,7 +2358,7 @@ public HashMap<Integer,String> getLocalRegNamesFromDebug(ABC abc){
|
|||||||
} catch (ConvertException ex1) {
|
} catch (ConvertException ex1) {
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return stats;
|
return stats;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user