Experimenting with using parallel executor for all mapping

This commit is contained in:
Adam
2016-01-24 13:22:10 -05:00
parent d328551750
commit a56e2b2783
14 changed files with 153 additions and 8 deletions

View File

@@ -8,4 +8,6 @@ public interface MappableInstruction
void map(ParallelExecutorMapping mappings, InstructionContext ctx, InstructionContext other);
boolean isSame(InstructionContext thisIc, InstructionContext otherIc);
boolean canMap();
}

View File

@@ -152,4 +152,10 @@ public abstract class If extends Instruction implements JumpingInstruction, Comp
{
return thisIc.getInstruction().getClass() == otherIc.getInstruction().getClass();
}
@Override
public boolean canMap()
{
return true;
}
}

View File

@@ -155,4 +155,10 @@ public abstract class If0 extends Instruction implements JumpingInstruction, Com
{
return thisIc.getInstruction().getClass() == otherIc.getInstruction().getClass();
}
@Override
public boolean canMap()
{
return true;
}
}

View File

@@ -3,6 +3,7 @@ package net.runelite.deob.attributes.code.instructions;
import net.runelite.deob.attributes.code.InstructionType;
import net.runelite.deob.attributes.code.Instructions;
import net.runelite.deob.attributes.code.instruction.types.PushConstantInstruction;
import net.runelite.deob.deobfuscators.rename.ParallelExecutorMapping;
import net.runelite.deob.execution.InstructionContext;
import net.runelite.deob.execution.StackContext;
@@ -34,7 +35,7 @@ public class IfICmpEq extends If
return true;
// check for other being ifeq and this has a constant 0
if (otherIc.getInstruction() instanceof IfEq)
if (otherIc.getInstruction() instanceof IfEq || otherIc.getInstruction() instanceof IfNe)
{
StackContext s1 = thisIc.getPops().get(0),
s2 = thisIc.getPops().get(1);
@@ -45,4 +46,17 @@ public class IfICmpEq extends If
return false;
}
@Override
public void map(ParallelExecutorMapping mapping, InstructionContext ctx, InstructionContext other)
{
if (other.getInstruction() instanceof IfNe)
{
super.mapOtherBranch(mapping, ctx, other);
}
else
{
super.map(mapping, ctx, other);
}
}
}

View File

@@ -177,4 +177,10 @@ public class InvokeInterface extends Instruction implements InvokeInstruction
{
return thisIc.getInstruction().getClass() == otherIc.getInstruction().getClass();
}
@Override
public boolean canMap()
{
return true;
}
}

View File

@@ -178,4 +178,10 @@ public class InvokeSpecial extends Instruction implements InvokeInstruction
{
return thisIc.getInstruction().getClass() == otherIc.getInstruction().getClass();
}
@Override
public boolean canMap()
{
return true;
}
}

View File

@@ -180,4 +180,10 @@ public class InvokeStatic extends Instruction implements InvokeInstruction
{
return thisIc.getInstruction().getClass() == otherIc.getInstruction().getClass();
}
@Override
public boolean canMap()
{
return true;
}
}

View File

@@ -23,6 +23,7 @@ import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import net.runelite.deob.attributes.code.instruction.types.MappableInstruction;
import net.runelite.deob.deobfuscators.rename.MappingExecutorUtil;
import net.runelite.deob.deobfuscators.rename.ParallelExecutorMapping;
import net.runelite.deob.execution.Execution;
import net.runelite.deob.execution.Value;
@@ -187,4 +188,10 @@ public class InvokeVirtual extends Instruction implements InvokeInstruction
{
return thisIc.getInstruction().getClass() == otherIc.getInstruction().getClass();
}
@Override
public boolean canMap()
{
return MappingExecutorUtil.isMappable(this);
}
}

View File

@@ -128,4 +128,10 @@ public class PutField extends Instruction implements SetFieldInstruction
{
return thisIc.getInstruction().getClass() == otherIc.getInstruction().getClass();
}
@Override
public boolean canMap()
{
return true;
}
}

View File

@@ -110,4 +110,10 @@ public class PutStatic extends Instruction implements SetFieldInstruction
{
return thisIc.getInstruction().getClass() == otherIc.getInstruction().getClass();
}
@Override
public boolean canMap()
{
return true;
}
}

View File

@@ -1,7 +1,5 @@
package net.runelite.deob.deobfuscators.rename;
import java.io.File;
import java.io.IOException;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@@ -9,12 +7,12 @@ import java.util.stream.Collectors;
import net.runelite.deob.ClassGroup;
import net.runelite.deob.Method;
import net.runelite.deob.attributes.code.Instruction;
import net.runelite.deob.attributes.code.instruction.types.InvokeInstruction;
import net.runelite.deob.attributes.code.instruction.types.MappableInstruction;
import net.runelite.deob.execution.Execution;
import net.runelite.deob.execution.Frame;
import net.runelite.deob.execution.InstructionContext;
import net.runelite.deob.execution.ParallellMappingExecutor;
import net.runelite.deob.util.JarUtil;
public class MappingExecutorUtil
{
@@ -112,4 +110,22 @@ public class MappingExecutorUtil
return mappings;
}
public static boolean isMappable(InvokeInstruction ii)
{
net.runelite.deob.pool.Method m = (net.runelite.deob.pool.Method) ii.getMethod();
String className = m.getClassEntry().getName();
if (className.startsWith("java/"))
return false;
// switch (className)
// {
// case "java/lang/String":
//
// }
// if (m.getClassEntry().getName().equals("java/lang/String"))
// return false;
return true;
}
}

View File

@@ -229,8 +229,12 @@ public class Frame
if (execution.step && oldCur instanceof MappableInstruction)
{
execution.paused = true;
return;
MappableInstruction mi = (MappableInstruction) oldCur;
if (mi.canMap())
{
execution.paused = true;
return;
}
}
}
}

View File

@@ -2,7 +2,7 @@ package net.runelite.deob.util;
public class IdGen
{
private volatile int cur = 1;
private int cur = 1;
public synchronized int get()
{