this wont work because exception handlers arent run so it wont see all returns
This commit is contained in:
@@ -11,11 +11,13 @@ import net.runelite.deob.attributes.code.instruction.types.DupInstruction;
|
|||||||
import net.runelite.deob.attributes.code.instruction.types.InvokeInstruction;
|
import net.runelite.deob.attributes.code.instruction.types.InvokeInstruction;
|
||||||
import net.runelite.deob.attributes.code.instruction.types.LVTInstruction;
|
import net.runelite.deob.attributes.code.instruction.types.LVTInstruction;
|
||||||
import net.runelite.deob.attributes.code.instruction.types.MappableInstruction;
|
import net.runelite.deob.attributes.code.instruction.types.MappableInstruction;
|
||||||
|
import net.runelite.deob.attributes.code.instruction.types.ReturnInstruction;
|
||||||
import net.runelite.deob.attributes.code.instruction.types.SetFieldInstruction;
|
import net.runelite.deob.attributes.code.instruction.types.SetFieldInstruction;
|
||||||
import net.runelite.deob.attributes.code.instructions.InvokeStatic;
|
import net.runelite.deob.attributes.code.instructions.InvokeStatic;
|
||||||
import net.runelite.deob.execution.Execution;
|
import net.runelite.deob.execution.Execution;
|
||||||
import net.runelite.deob.execution.Frame;
|
import net.runelite.deob.execution.Frame;
|
||||||
import net.runelite.deob.execution.InstructionContext;
|
import net.runelite.deob.execution.InstructionContext;
|
||||||
|
import net.runelite.deob.execution.MethodContext;
|
||||||
import net.runelite.deob.execution.ParallellMappingExecutor;
|
import net.runelite.deob.execution.ParallellMappingExecutor;
|
||||||
import net.runelite.deob.execution.StackContext;
|
import net.runelite.deob.execution.StackContext;
|
||||||
import net.runelite.deob.execution.VariableContext;
|
import net.runelite.deob.execution.VariableContext;
|
||||||
@@ -86,6 +88,9 @@ public class MappingExecutorUtil
|
|||||||
frame.other = frame2;
|
frame.other = frame2;
|
||||||
frame2.other = frame;
|
frame2.other = frame;
|
||||||
|
|
||||||
|
MethodContext ctx1 = frame.getMethodCtx(),
|
||||||
|
ctx2 = frame2.getMethodCtx();
|
||||||
|
|
||||||
ParallellMappingExecutor parallel = new ParallellMappingExecutor(e, e2);
|
ParallellMappingExecutor parallel = new ParallellMappingExecutor(e, e2);
|
||||||
ParallelExecutorMapping mappings = new ParallelExecutorMapping(m1.getMethods().getClassFile().getGroup(),
|
ParallelExecutorMapping mappings = new ParallelExecutorMapping(m1.getMethods().getClassFile().getGroup(),
|
||||||
m2.getMethods().getClassFile().getGroup());
|
m2.getMethods().getClassFile().getGroup());
|
||||||
@@ -184,9 +189,31 @@ public class MappingExecutorUtil
|
|||||||
e.paused = e2.paused = false;
|
e.paused = e2.paused = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// if (mappings.getMap().isEmpty() == false)
|
||||||
|
// {
|
||||||
|
// checkReturns(m1, ctx1);
|
||||||
|
// }
|
||||||
|
|
||||||
return mappings;
|
return mappings;
|
||||||
}
|
}
|
||||||
//static boolean hit;
|
|
||||||
|
private static boolean checkReturns(Method method, MethodContext ctx)
|
||||||
|
{
|
||||||
|
List<Instruction> ins = method.getCode().getInstructions().getInstructions().stream().filter(i -> i instanceof ReturnInstruction).collect(Collectors.toList());
|
||||||
|
List<Instruction> exc = ctx.instructions.stream().map(i -> i.getInstruction()).collect(Collectors.toList());
|
||||||
|
|
||||||
|
for (Instruction i : ins)
|
||||||
|
{
|
||||||
|
if (!exc.contains(i))
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
//private static boolean containsMappableInstruction
|
||||||
|
|
||||||
public static boolean isMappable(InvokeInstruction ii)
|
public static boolean isMappable(InvokeInstruction ii)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -236,9 +236,12 @@ public class Frame
|
|||||||
}
|
}
|
||||||
|
|
||||||
InstructionContext ictx = this.instructions.get(this.instructions.size() - 1);
|
InstructionContext ictx = this.instructions.get(this.instructions.size() - 1);
|
||||||
|
|
||||||
assert ictx.getInstruction() == oldCur;
|
assert ictx.getInstruction() == oldCur;
|
||||||
execution.contexts.put(oldCur, ictx);
|
execution.contexts.put(oldCur, ictx);
|
||||||
|
|
||||||
|
this.ctx.instructions.add(ictx);
|
||||||
|
|
||||||
execution.executed.add(oldCur);
|
execution.executed.add(oldCur);
|
||||||
|
|
||||||
processExceptions(oldCur);
|
processExceptions(oldCur);
|
||||||
|
|||||||
@@ -1,7 +1,8 @@
|
|||||||
package net.runelite.deob.execution;
|
package net.runelite.deob.execution;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import net.runelite.deob.Field;
|
import java.util.List;
|
||||||
import net.runelite.deob.attributes.code.Instruction;
|
import net.runelite.deob.attributes.code.Instruction;
|
||||||
import org.apache.commons.collections4.map.MultiValueMap;
|
import org.apache.commons.collections4.map.MultiValueMap;
|
||||||
|
|
||||||
@@ -9,6 +10,7 @@ public class MethodContext
|
|||||||
{
|
{
|
||||||
private Execution execution;
|
private Execution execution;
|
||||||
private MultiValueMap<InstructionContext, Instruction> visited = new MultiValueMap<>();
|
private MultiValueMap<InstructionContext, Instruction> visited = new MultiValueMap<>();
|
||||||
|
public List<InstructionContext> instructions = new ArrayList<>();
|
||||||
|
|
||||||
public MethodContext(Execution execution)
|
public MethodContext(Execution execution)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -117,8 +117,8 @@ public class MapStaticTest
|
|||||||
ClassGroup group1 = JarUtil.loadJar(new File(JAR1));
|
ClassGroup group1 = JarUtil.loadJar(new File(JAR1));
|
||||||
ClassGroup group2 = JarUtil.loadJar(new File(JAR2));
|
ClassGroup group2 = JarUtil.loadJar(new File(JAR2));
|
||||||
|
|
||||||
Method m1 = group1.findClass("client").findMethod("method273");
|
Method m1 = group1.findClass("client").findMethod("method585");
|
||||||
Method m2 = group2.findClass("client").findMethod("method235");
|
Method m2 = group2.findClass("class44").findMethod("method930");
|
||||||
|
|
||||||
HashMap<Object, Object> all = new HashMap();
|
HashMap<Object, Object> all = new HashMap();
|
||||||
List<ParallelExecutorMapping> pmes = new ArrayList<>();
|
List<ParallelExecutorMapping> pmes = new ArrayList<>();
|
||||||
@@ -200,15 +200,15 @@ public class MapStaticTest
|
|||||||
assert m1s.size() == m2s.size();
|
assert m1s.size() == m2s.size();
|
||||||
|
|
||||||
List<ParallelExecutorMapping> pmes = new ArrayList<>();
|
List<ParallelExecutorMapping> pmes = new ArrayList<>();
|
||||||
for (int i = 0; i < m1s.size(); ++i)
|
// for (int i = 0; i < m1s.size(); ++i)
|
||||||
{
|
// {
|
||||||
Method m1 = m1s.get(i), m2 = m2s.get(i);
|
// Method m1 = m1s.get(i), m2 = m2s.get(i);
|
||||||
|
//
|
||||||
assert m1.getPoolMethod().equals(m2.getPoolMethod());
|
// assert m1.getPoolMethod().equals(m2.getPoolMethod());
|
||||||
|
//
|
||||||
HashMap<Object, Object> all = new HashMap();
|
// HashMap<Object, Object> all = new HashMap();
|
||||||
map(all, pmes, m1, m2);
|
// map(all, pmes, m1, m2);
|
||||||
}
|
// }
|
||||||
|
|
||||||
ParallelExecutorMapping finalm = new ParallelExecutorMapping(group1, group2);
|
ParallelExecutorMapping finalm = new ParallelExecutorMapping(group1, group2);
|
||||||
for (ParallelExecutorMapping pme : pmes)
|
for (ParallelExecutorMapping pme : pmes)
|
||||||
@@ -246,10 +246,20 @@ public class MapStaticTest
|
|||||||
// ClassGroup two = JarUtil.loadJar(new File(JAR2));
|
// ClassGroup two = JarUtil.loadJar(new File(JAR2));
|
||||||
|
|
||||||
List<ParallelExecutorMapping> pmes = new ArrayList<>();
|
List<ParallelExecutorMapping> pmes = new ArrayList<>();
|
||||||
for (int i = 0; i < 250; ++i)
|
for (int i = -1; i < 250; ++i)
|
||||||
{
|
{
|
||||||
ClassFile c1 = one.findClass("class" + i);
|
ClassFile c1, c2;
|
||||||
ClassFile c2 = two.findClass("class" + i);
|
|
||||||
|
if (i == -1)
|
||||||
|
{
|
||||||
|
c1 = one.findClass("client");
|
||||||
|
c2 = two.findClass("client");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
c1 = one.findClass("class" + i);
|
||||||
|
c2 = two.findClass("class" + i);
|
||||||
|
}
|
||||||
|
|
||||||
if (c1 == null || c2 == null)
|
if (c1 == null || c2 == null)
|
||||||
continue;
|
continue;
|
||||||
@@ -258,20 +268,22 @@ public class MapStaticTest
|
|||||||
msm.map(c1, c2);
|
msm.map(c1, c2);
|
||||||
|
|
||||||
Multimap<Method, Method> map = msm.getMap();
|
Multimap<Method, Method> map = msm.getMap();
|
||||||
for (Method m : msm.getMap().keySet())
|
for (Method m : map.keySet())
|
||||||
{
|
{
|
||||||
Collection<Method> methods = msm.getMap().get(m);
|
Collection<Method> methods = map.get(m);
|
||||||
|
|
||||||
for (Method other : methods)
|
for (Method other : methods)
|
||||||
{
|
{
|
||||||
ParallelExecutorMapping pme = MappingExecutorUtil.map(m, other);
|
HashMap<Object, Object> all = new HashMap();
|
||||||
|
map(all, pmes, m, other);
|
||||||
if (pme.getMap().isEmpty())
|
// ParallelExecutorMapping pme = MappingExecutorUtil.map(m, other);
|
||||||
continue;
|
//
|
||||||
|
// if (pme.getMap().isEmpty())
|
||||||
pme.map(m, other);
|
// continue;
|
||||||
|
//
|
||||||
pmes.add(pme);
|
// pme.map(m, other);
|
||||||
|
//
|
||||||
|
// pmes.add(pme);
|
||||||
}
|
}
|
||||||
//HashMap<Object, Object> all = new HashMap();
|
//HashMap<Object, Object> all = new HashMap();
|
||||||
//map(all, pmes, e.getKey(), e.getValue());
|
//map(all, pmes, e.getKey(), e.getValue());
|
||||||
@@ -305,17 +317,17 @@ public class MapStaticTest
|
|||||||
{
|
{
|
||||||
for (Method other : methods)
|
for (Method other : methods)
|
||||||
{
|
{
|
||||||
ParallelExecutorMapping pme = MappingExecutorUtil.map(m, other);
|
HashMap<Object, Object> all = new HashMap();
|
||||||
|
map(all, pmes, m, other);
|
||||||
|
|
||||||
if (pme.getMap().isEmpty())
|
// ParallelExecutorMapping pme = MappingExecutorUtil.map(m, other);
|
||||||
continue;
|
//
|
||||||
|
// if (pme.getMap().isEmpty())
|
||||||
// HashMap<Object, Object> all = new HashMap();
|
// continue;
|
||||||
// map(all, pmes, m, other);
|
//
|
||||||
pme.map(m, other);
|
// pme.map(m, other);
|
||||||
|
//
|
||||||
pmes.add(pme);
|
// pmes.add(pme);
|
||||||
//System.out.println(m + " " + other + " " + pme.getMap().size());
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -378,25 +390,12 @@ public class MapStaticTest
|
|||||||
if (m1.getName().equals("vmethod3096"))
|
if (m1.getName().equals("vmethod3096"))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (m1.getName().equals("method32"))
|
ParallelExecutorMapping mappings = MappingExecutorUtil.map(m1, m2);
|
||||||
{
|
|
||||||
int i=5;
|
|
||||||
}
|
|
||||||
|
|
||||||
ParallelExecutorMapping
|
if (mappings.getMap().isEmpty())
|
||||||
// try
|
return;
|
||||||
// {
|
|
||||||
mappings = MappingExecutorUtil.map(m1, m2);
|
|
||||||
// }
|
|
||||||
// catch (Throwable ex)
|
|
||||||
// {
|
|
||||||
// ex.printStackTrace();
|
|
||||||
// System.err.println("Error mapping " + m1 + " to " + m2);
|
|
||||||
// //if (test)
|
|
||||||
// // throw ex;
|
|
||||||
// return;
|
|
||||||
// }
|
|
||||||
|
|
||||||
|
mappings.map(m1, m2);
|
||||||
result.add(mappings);
|
result.add(mappings);
|
||||||
|
|
||||||
for (Entry<Object, Object> e : mappings.getMap().entrySet())
|
for (Entry<Object, Object> e : mappings.getMap().entrySet())
|
||||||
|
|||||||
Reference in New Issue
Block a user