Only re-generate pool info for get/put/invoke instructions if something changes, otherwise it uses the pool info of the resolved field which isn't always the same

This commit is contained in:
Adam
2016-03-20 17:30:31 -04:00
parent c79a344008
commit 9b1f5720b0
7 changed files with 48 additions and 33 deletions

View File

@@ -106,6 +106,10 @@ public class GetField extends Instruction implements GetFieldInstruction
public void regeneratePool()
{
if (myField != null)
field = myField.getPoolField();
// only rebuild field info if the field has changed.
// otherwise it will rewrite the pool field into to something
// different if the field was deep
if (getMyField() != myField)
field = myField.getPoolField();
}
}

View File

@@ -103,6 +103,7 @@ public class GetStatic extends Instruction implements GetFieldInstruction
public void regeneratePool()
{
if (myField != null)
field = myField.getPoolField();
if (getMyField() != myField)
field = myField.getPoolField();
}
}

View File

@@ -146,26 +146,29 @@ public class InvokeInterface extends Instruction implements InvokeInstruction
return method;
}
@Override
public void lookup()
private List<net.runelite.deob.Method> lookupMethods()
{
ClassGroup group = this.getInstructions().getCode().getAttributes().getClassFile().getGroup();
ClassFile otherClass = group.findClass(method.getClassEntry().getName());
if (otherClass == null)
return; // not our class
return null; // not our class
// look up this method in this class and anything that inherits from it
//List<net.runelite.deob.Method> list = new ArrayList<>();
//findMethodFromClass(list, otherClass);
myMethods = Renamer.getVirutalMethods(otherClass.findMethod(method.getNameAndType()));
return Renamer.getVirutalMethods(otherClass.findMethod(method.getNameAndType()));
}
@Override
public void lookup()
{
myMethods = lookupMethods();
}
@Override
public void regeneratePool()
{
if (myMethods != null && !myMethods.isEmpty())
method = myMethods.get(0).getPoolInterfaceMethod(); // is this right?
if (!myMethods.equals(lookupMethods()))
method = myMethods.get(0).getPoolInterfaceMethod(); // is this right?
}
@Override

View File

@@ -32,7 +32,7 @@ import net.runelite.deob.execution.Value;
public class InvokeStatic extends Instruction implements InvokeInstruction
{
private Method method;
private List<net.runelite.deob.Method> myMethods;
private net.runelite.deob.Method myMethod;
public InvokeStatic(Instructions instructions, InstructionType type, int pc)
{
@@ -69,7 +69,7 @@ public class InvokeStatic extends Instruction implements InvokeInstruction
@Override
public List<net.runelite.deob.Method> getMethods()
{
return myMethods != null ? myMethods : Arrays.asList();
return myMethod != null ? Arrays.asList(myMethod) : Arrays.asList();
}
@Override
@@ -141,28 +141,32 @@ public class InvokeStatic extends Instruction implements InvokeInstruction
return method;
}
@Override
public void lookup()
private net.runelite.deob.Method lookupMethod()
{
ClassGroup group = this.getInstructions().getCode().getAttributes().getClassFile().getGroup();
ClassFile otherClass = group.findClass(method.getClassEntry().getName());
if (otherClass == null)
return; // not our class
return null; // not our class
net.runelite.deob.Method other = otherClass.findMethodDeepStatic(method.getNameAndType());
assert other != null;
List<net.runelite.deob.Method> list = new ArrayList<>();
list.add(other);
myMethods = list;
return other;
}
@Override
public void lookup()
{
myMethod = lookupMethod();
}
@Override
public void regeneratePool()
{
if (myMethods != null && !myMethods.isEmpty())
method = myMethods.get(0).getPoolMethod();
if (myMethod != null)
if (myMethod != lookupMethod())
method = myMethod.getPoolMethod();
}
@Override

View File

@@ -21,7 +21,6 @@ import java.io.DataOutputStream;
import java.io.IOException;
import java.util.Arrays;
import java.util.List;
import java.util.Set;
import net.runelite.deob.Field;
import net.runelite.deob.attributes.code.instruction.types.GetFieldInstruction;
import net.runelite.deob.deobfuscators.Renamer;
@@ -140,33 +139,37 @@ public class InvokeVirtual extends Instruction implements InvokeInstruction
return method;
}
@Override
public void lookup()
private List<net.runelite.deob.Method> lookupMethods()
{
ClassGroup group = this.getInstructions().getCode().getAttributes().getClassFile().getGroup();
ClassFile otherClass = group.findClass(method.getClassEntry().getName());
if (otherClass == null)
return; // not our class
return null; // not our class
// when I recompile classes I can see the class of invokevirtuals methods change, get all methods
//List<net.runelite.deob.Method> list = new ArrayList<>();
//findMethodFromClass(new HashSet<>(), list, otherClass);
net.runelite.deob.Method m = otherClass.findMethodDeep(method.getNameAndType());
if (m == null)
{
return;
return null;
}
myMethods = Renamer.getVirutalMethods(m);
return Renamer.getVirutalMethods(m);
}
@Override
public void lookup()
{
myMethods = lookupMethods();
}
@Override
public void regeneratePool()
{
if (myMethods != null && !myMethods.isEmpty())
method = myMethods.get(0).getPoolMethod(); // is this right?
if (!myMethods.equals(lookupMethods()))
method = myMethods.get(0).getPoolMethod(); // is this right?
}
@Override

View File

@@ -18,7 +18,6 @@ import java.io.DataOutputStream;
import java.io.IOException;
import net.runelite.deob.Method;
import net.runelite.deob.attributes.code.instruction.types.GetFieldInstruction;
import net.runelite.deob.attributes.code.instruction.types.MappableInstruction;
import net.runelite.deob.attributes.code.instruction.types.PushConstantInstruction;
import net.runelite.deob.deobfuscators.rename.MappingExecutorUtil;
import net.runelite.deob.deobfuscators.rename.ParallelExecutorMapping;
@@ -97,7 +96,8 @@ public class PutField extends Instruction implements SetFieldInstruction
public void regeneratePool()
{
if (myField != null)
field = myField.getPoolField();
if (getMyField() != myField)
field = myField.getPoolField();
}
@Override

View File

@@ -18,7 +18,6 @@ import java.io.DataOutputStream;
import java.io.IOException;
import net.runelite.deob.Method;
import net.runelite.deob.attributes.code.instruction.types.GetFieldInstruction;
import net.runelite.deob.attributes.code.instruction.types.MappableInstruction;
import net.runelite.deob.deobfuscators.rename.MappingExecutorUtil;
import net.runelite.deob.deobfuscators.rename.ParallelExecutorMapping;
@@ -95,7 +94,8 @@ public class PutStatic extends Instruction implements SetFieldInstruction
public void regeneratePool()
{
if (myField != null)
field = myField.getPoolField();
if (getMyField() != myField)
field = myField.getPoolField();
}
@Override