Keep real type of stack contexts, which I think I need later. Exec test passes, not sure of other implications of this.

This commit is contained in:
Adam
2016-01-30 15:56:36 -05:00
parent 2a3b9158ea
commit cbe45eddfe
20 changed files with 40 additions and 33 deletions

View File

@@ -52,7 +52,7 @@ public class GetField extends Instruction implements GetFieldInstruction
StackContext object = stack.pop(); StackContext object = stack.pop();
ins.pop(object); ins.pop(object);
StackContext ctx = new StackContext(ins, new Type(field.getNameAndType().getDescriptorType()).toStackType(), Value.NULL); StackContext ctx = new StackContext(ins, new Type(field.getNameAndType().getDescriptorType()), Value.NULL);
stack.push(ctx); stack.push(ctx);
ins.push(ctx); ins.push(ctx);

View File

@@ -56,7 +56,7 @@ public class GetStatic extends Instruction implements GetFieldInstruction
InstructionContext ins = new InstructionContext(this, frame); InstructionContext ins = new InstructionContext(this, frame);
Stack stack = frame.getStack(); Stack stack = frame.getStack();
StackContext ctx = new StackContext(ins, new Type(field.getNameAndType().getDescriptorType()).toStackType(), Value.NULL); StackContext ctx = new StackContext(ins, new Type(field.getNameAndType().getDescriptorType()), Value.NULL);
stack.push(ctx); stack.push(ctx);
ins.push(ctx); ins.push(ctx);

View File

@@ -65,7 +65,7 @@ public class IInc extends Instruction implements LVTInstruction, WideInstruction
Variables var = frame.getVariables(); Variables var = frame.getVariables();
VariableContext vctx = var.get(index); VariableContext vctx = var.get(index);
assert vctx.getType().equals(new Type(int.class.getCanonicalName())); assert vctx.getType().isInt();
ins.read(vctx); ins.read(vctx);
Value value = vctx.getValue(); Value value = vctx.getValue();

View File

@@ -70,7 +70,7 @@ public class ILoad extends Instruction implements LVTInstruction, WideInstructio
Variables variables = frame.getVariables(); Variables variables = frame.getVariables();
VariableContext vctx = variables.get(index); VariableContext vctx = variables.get(index);
assert vctx.getType().equals(new Type(int.class.getName())); assert vctx.getType().isInt();
ins.read(vctx); ins.read(vctx);
StackContext ctx = new StackContext(ins, vctx); StackContext ctx = new StackContext(ins, vctx);

View File

@@ -29,7 +29,7 @@ public class ILoad_0 extends Instruction implements LVTInstruction
Variables variables = frame.getVariables(); Variables variables = frame.getVariables();
VariableContext vctx = variables.get(0); VariableContext vctx = variables.get(0);
assert vctx.getType().equals(new Type(int.class.getName())); assert vctx.getType().isInt();
ins.read(vctx); ins.read(vctx);
StackContext ctx = new StackContext(ins, vctx); StackContext ctx = new StackContext(ins, vctx);

View File

@@ -29,7 +29,7 @@ public class ILoad_1 extends Instruction implements LVTInstruction
Variables variables = frame.getVariables(); Variables variables = frame.getVariables();
VariableContext vctx = variables.get(1); VariableContext vctx = variables.get(1);
assert vctx.getType().equals(new Type(int.class.getName())); assert vctx.getType().isInt();
ins.read(vctx); ins.read(vctx);
StackContext ctx = new StackContext(ins, vctx); StackContext ctx = new StackContext(ins, vctx);

View File

@@ -29,7 +29,7 @@ public class ILoad_2 extends Instruction implements LVTInstruction
Variables variables = frame.getVariables(); Variables variables = frame.getVariables();
VariableContext vctx = variables.get(2); VariableContext vctx = variables.get(2);
assert vctx.getType().equals(new Type(int.class.getName())); assert vctx.getType().isInt();
ins.read(vctx); ins.read(vctx);
StackContext ctx = new StackContext(ins, vctx); StackContext ctx = new StackContext(ins, vctx);

View File

@@ -29,7 +29,7 @@ public class ILoad_3 extends Instruction implements LVTInstruction
Variables variables = frame.getVariables(); Variables variables = frame.getVariables();
VariableContext vctx = variables.get(3); VariableContext vctx = variables.get(3);
assert vctx.getType().equals(new Type(int.class.getName())); assert vctx.getType().isInt();
ins.read(vctx); ins.read(vctx);
StackContext ctx = new StackContext(ins, vctx); StackContext ctx = new StackContext(ins, vctx);

View File

@@ -55,7 +55,7 @@ public class IStore extends Instruction implements LVTInstruction, WideInstructi
Variables variables = frame.getVariables(); Variables variables = frame.getVariables();
StackContext value = stack.pop(); StackContext value = stack.pop();
assert value.getType().equals(new Type(int.class.getName())); assert value.getType().isInt();
ins.pop(value); ins.pop(value);
variables.set(index, new VariableContext(ins, value)); variables.set(index, new VariableContext(ins, value));

View File

@@ -34,7 +34,7 @@ public class IStore_0 extends Instruction implements LVTInstruction
Variables variables = frame.getVariables(); Variables variables = frame.getVariables();
StackContext value = stack.pop(); StackContext value = stack.pop();
assert value.getType().equals(new Type(int.class.getName())); assert value.getType().isInt();
ins.pop(value); ins.pop(value);
variables.set(0, new VariableContext(ins, value)); variables.set(0, new VariableContext(ins, value));

View File

@@ -34,7 +34,7 @@ public class IStore_1 extends Instruction implements LVTInstruction
Variables variables = frame.getVariables(); Variables variables = frame.getVariables();
StackContext value = stack.pop(); StackContext value = stack.pop();
assert value.getType().equals(new Type(int.class.getName())); assert value.getType().isInt();
ins.pop(value); ins.pop(value);
variables.set(1, new VariableContext(ins, value)); variables.set(1, new VariableContext(ins, value));

View File

@@ -34,7 +34,7 @@ public class IStore_2 extends Instruction implements LVTInstruction
Variables variables = frame.getVariables(); Variables variables = frame.getVariables();
StackContext value = stack.pop(); StackContext value = stack.pop();
assert value.getType().equals(new Type(int.class.getName())); assert value.getType().isInt();
ins.pop(value); ins.pop(value);
variables.set(2, new VariableContext(ins, value)); variables.set(2, new VariableContext(ins, value));

View File

@@ -29,7 +29,7 @@ public class IStore_3 extends Instruction implements LVTInstruction
Variables variables = frame.getVariables(); Variables variables = frame.getVariables();
StackContext value = stack.pop(); StackContext value = stack.pop();
assert value.getType().equals(new Type(int.class.getName())); assert value.getType().isInt();
ins.pop(value); ins.pop(value);
variables.set(3, new VariableContext(ins, value)); variables.set(3, new VariableContext(ins, value));

View File

@@ -92,7 +92,7 @@ public class InvokeInterface extends Instruction implements InvokeInstruction
if (!method.getNameAndType().isVoid()) if (!method.getNameAndType().isVoid())
{ {
StackContext ctx = new StackContext(ins, StackContext ctx = new StackContext(ins,
new Type(method.getNameAndType().getDescriptor().getReturnValue()).toStackType(), new Type(method.getNameAndType().getDescriptor().getReturnValue()),
Value.NULL Value.NULL
); );
stack.push(ctx); stack.push(ctx);

View File

@@ -77,7 +77,7 @@ public class InvokeSpecial extends Instruction implements InvokeInstruction
if (!method.getNameAndType().isVoid()) if (!method.getNameAndType().isVoid())
{ {
StackContext ctx = new StackContext(ins, StackContext ctx = new StackContext(ins,
new Type(method.getNameAndType().getDescriptor().getReturnValue()).toStackType(), new Type(method.getNameAndType().getDescriptor().getReturnValue()),
Value.NULL Value.NULL
); );
stack.push(ctx); stack.push(ctx);

View File

@@ -87,7 +87,7 @@ public class InvokeStatic extends Instruction implements InvokeInstruction
if (!method.getNameAndType().isVoid()) if (!method.getNameAndType().isVoid())
{ {
StackContext ctx = new StackContext(ins, StackContext ctx = new StackContext(ins,
new Type(method.getNameAndType().getDescriptor().getReturnValue()).toStackType(), new Type(method.getNameAndType().getDescriptor().getReturnValue()),
Value.NULL Value.NULL
); );
stack.push(ctx); stack.push(ctx);

View File

@@ -79,7 +79,7 @@ public class InvokeVirtual extends Instruction implements InvokeInstruction
if (!method.getNameAndType().isVoid()) if (!method.getNameAndType().isVoid())
{ {
StackContext ctx = new StackContext(ins, StackContext ctx = new StackContext(ins,
new Type(method.getNameAndType().getDescriptor().getReturnValue()).toStackType(), new Type(method.getNameAndType().getDescriptor().getReturnValue()),
Value.NULL Value.NULL
); );
stack.push(ctx); stack.push(ctx);

View File

@@ -64,7 +64,7 @@ public class Frame
NameAndType nat = method.getNameAndType(); NameAndType nat = method.getNameAndType();
for (int i = 0; i < nat.getNumberOfArgs(); ++i) for (int i = 0; i < nat.getNumberOfArgs(); ++i)
{ {
variables.set(pos, new VariableContext(new Type(nat.getDescriptor().getTypeOfArg(i)).toStackType()).markParameter()); variables.set(pos, new VariableContext(new Type(nat.getDescriptor().getTypeOfArg(i))).markParameter());
pos += nat.getDescriptor().getTypeOfArg(i).getSlots(); pos += nat.getDescriptor().getTypeOfArg(i).getSlots();
} }

View File

@@ -18,7 +18,7 @@ public class Type
type = type + "[]"; type = type + "[]";
} }
public Type toStackType() private Type toStackType()
{ {
if (type.equals(byte.class.getCanonicalName()) || type.equals(char.class.getCanonicalName()) || type.equals(short.class.getCanonicalName()) if (type.equals(byte.class.getCanonicalName()) || type.equals(char.class.getCanonicalName()) || type.equals(short.class.getCanonicalName())
|| type.equals(boolean.class.getCanonicalName())) || type.equals(boolean.class.getCanonicalName()))
@@ -26,6 +26,11 @@ public class Type
return this; return this;
} }
public boolean isInt()
{
return toStackType().equals(new Type(int.class.getName()));
}
private static String asmTypeToClass(String type) private static String asmTypeToClass(String type)
{ {
switch (type) switch (type)

View File

@@ -2,28 +2,30 @@ package net.runelite.deob.execution;
import java.io.File; import java.io.File;
import net.runelite.deob.ClassGroup; import net.runelite.deob.ClassGroup;
import net.runelite.deob.deobfuscators.rename.MapStaticTest;
import net.runelite.deob.util.JarUtil; import net.runelite.deob.util.JarUtil;
import org.junit.Test; import org.junit.Test;
public class ExecutionTest public class ExecutionTest
{ {
private static final String JAR1 = MapStaticTest.class.getResource("/adamin1.jar").getFile(),
JAR2 = MapStaticTest.class.getResource("/adamin2.jar").getFile();
@Test @Test
public void test() throws Exception public void test() throws Exception
{ {
ClassGroup group = JarUtil.loadJar(new File("d:/rs/07/adamin1.jar")); ClassGroup group1 = JarUtil.loadJar(new File(JAR1));
Execution e = new Execution(group1);
System.out.println("Done loading jar " + System.currentTimeMillis() / 1000);
Execution e = new Execution(group);
//e.setBuildGraph(true);
//e.setFollowInvokes(false);
e.populateInitialMethods(); e.populateInitialMethods();
e.run(); e.run();
}
System.out.println("Done exec " + System.currentTimeMillis() / 1000); @Test
public void test2() throws Exception
Runtime runtime = Runtime.getRuntime(); {
ClassGroup group2 = JarUtil.loadJar(new File(JAR2));
System.out.println("Total memory (MB) " + runtime.totalMemory()/1024L/1024L); Execution e = new Execution(group2);
e.populateInitialMethods();
e.run();
} }
} }