Actually I think I can just stop the frame if it crashes. This runs forever for some reason.

This commit is contained in:
Adam
2016-02-07 14:27:19 -05:00
parent 6906c81455
commit c4bf4f65df
5 changed files with 102 additions and 27 deletions

View File

@@ -115,7 +115,57 @@ public class MappingExecutorUtil
if (!mi1.isSame(p1, p2)) if (!mi1.isSame(p1, p2))
{ {
throw new MappingException(); p1.getFrame().stop();
p2.getFrame().stop();
continue;
// if (!hit)
// {
// hit = true;
//
// throw new MappingException();
// }
//
// System.out.println("ERROR mapping " + p1 + " to " + p2);
//
// // methods don't map. find common static method and back out.
//
// Frame c1 = p1.getFrame(), c2 = p2.getFrame();
//
// while (c1 != null && c1.otherStatic == null)
// c1 = c1.returnTo;
//
// while (c2 != null && c2.otherStatic == null)
// c2 = c2.returnTo;
//
// // otherStatic would point to the original frame of the method, which the other might not be. we don't
// // care just compare the method.
// if (c1 == null || c2 == null || c1.otherStatic.getMethod() != c2.getMethod() || c2.otherStatic.getMethod() != c1.getMethod())
// {
// throw new MappingException();
// }
//
// // c1/c2 are top frames of static methods that we can't map.
// // return out of frames
// c1 = c1.returnTo;
// c2 = c2.returnTo;
//
// if (c1 == null || c2 == null)
// throw new MappingException();
//
// // Back execution out to c1 and c2.
// // When something is stepped into, the calling frame is removed.
// // Remove all frames from the respective method, add frame from good method to continue
// parallel.removeFramesFromMethod(p1.getFrame().getMethod());
// parallel.removeFramesFromMethod(p2.getFrame().getMethod());
//
// assert c1.other == null;
// assert c2.other == null;
//
// c1.other = c2;
// c2.other = c1;
//
// parallel.addFrame(c1, c2);
// continue;
} }
mi1.map(mappings, p1, p2); mi1.map(mappings, p1, p2);
@@ -125,6 +175,7 @@ public class MappingExecutorUtil
return mappings; return mappings;
} }
//static boolean hit;
public static boolean isMappable(InvokeInstruction ii) public static boolean isMappable(InvokeInstruction ii)
{ {

View File

@@ -12,9 +12,14 @@ public class ParallelExecutorMapping
private List<Object> order = new ArrayList<>(); private List<Object> order = new ArrayList<>();
public Method m1, m2; public Method m1, m2;
public void merge(ParallelExecutorMapping other)
{
map.putAll(other.map); // is this right?
}
public void map(Object one, Object two) public void map(Object one, Object two)
{ {
assert !map.containsKey(one) || map.get(one) == two; //assert !map.containsKey(one) || map.get(one) == two;
if (map.containsKey(one)) if (map.containsKey(one))
return; return;

View File

@@ -48,7 +48,7 @@ public class Frame
variables = new Variables(code.getMaxLocals()); variables = new Variables(code.getMaxLocals());
// don't cache method contexts per execution // don't cache method contexts per execution
// need to allow the same method to execute multiple times // need to allow the same method to execute multiple times
// when called from multiple places to allow graph building // when called from multiple places to allow graph building //XXX there no longer is a graph
ctx = new MethodContext(execution); ctx = new MethodContext(execution);
nonStatic = method; nonStatic = method;
} }
@@ -144,6 +144,7 @@ public class Frame
ffs.remove(this); ffs.remove(this);
this.created = other.created; this.created = other.created;
this.forking = other.forking; this.forking = other.forking;
this.otherStatic = other.otherStatic;
} }
public Frame dup() public Frame dup()

View File

@@ -3,6 +3,7 @@ package net.runelite.deob.execution;
import java.util.HashSet; import java.util.HashSet;
import java.util.List; import java.util.List;
import java.util.Set; import java.util.Set;
import java.util.stream.Collectors;
import net.runelite.deob.Method; import net.runelite.deob.Method;
import net.runelite.deob.attributes.code.instruction.types.ReturnInstruction; import net.runelite.deob.attributes.code.instruction.types.ReturnInstruction;
import net.runelite.deob.attributes.code.instructions.InvokeStatic; import net.runelite.deob.attributes.code.instructions.InvokeStatic;
@@ -407,4 +408,16 @@ public class ParallellMappingExecutor
return f.returnTo; return f.returnTo;
} }
public void removeFramesFromMethod(Method m)
{
e.frames = e.frames.stream().filter(f -> f.getMethod() != m).collect(Collectors.toList());
e2.frames = e2.frames.stream().filter(f -> f.getMethod() != m).collect(Collectors.toList());
}
public void addFrame(Frame f1, Frame f2)
{
e.frames.add(0, f1);
e2.frames.add(0, f2);
}
} }

View File

@@ -114,8 +114,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("class183").findMethod("method3685"); Method m1 = group1.findClass("client").findMethod("vmethod3096");
Method m2 = group2.findClass("class183").findMethod("method3560"); Method m2 = group2.findClass("client").findMethod("vmethod2975");
HashMap<Object, Object> all = new HashMap(); HashMap<Object, Object> all = new HashMap();
List<ParallelExecutorMapping> pmes = new ArrayList<>(); List<ParallelExecutorMapping> pmes = new ArrayList<>();
@@ -163,33 +163,38 @@ public class MapStaticTest
HashMap<Object, Object> all = new HashMap(); HashMap<Object, Object> all = new HashMap();
map(all, pmes, m1, m2); map(all, pmes, m1, m2);
} }
int fields = 0, staticMethod = 0, method = 0, total = 0;
ParallelExecutorMapping finalm = new ParallelExecutorMapping();
for (ParallelExecutorMapping pme : pmes) for (ParallelExecutorMapping pme : pmes)
for (Entry<Object, Object> e : pme.getMap().entrySet()) finalm.merge(pme);
int fields = 0, staticMethod = 0, method = 0, total = 0;
for (Entry<Object, Object> e : finalm.getMap().entrySet())
{
System.out.println(e.getKey() + " <-> " + e.getValue());
Object o = e.getKey();
if (o instanceof Field)
++fields;
else if (o instanceof Method)
{ {
System.out.println(e.getKey() + " <-> " + e.getValue()); Method m = (Method) o;
Object o = e.getKey(); if (m.isStatic())
if (o instanceof Field) ++staticMethod;
++fields; else
else if (o instanceof Method) ++method;
{
Method m = (Method) o;
if (m.isStatic())
++staticMethod;
else
++method;
}
++total;
} }
++total;
}
System.out.println("Total " + total + ". " + fields + " fields, " + staticMethod + " static methods, " + method + " methods"); System.out.println("Total " + total + ". " + fields + " fields, " + staticMethod + " static methods, " + method + " methods");
// for (Method m : group1.findClass("client").getMethods().getMethods())
// { for (Method m : group1.findClass("client").getMethods().getMethods())
// if (!all.containsKey(m) && !m.isStatic()) {
// System.out.println("missing " + m); if (!finalm.getMap().containsKey(m) && !m.isStatic())
// } System.out.println("missing " + m);
}
} }
public List<Method> getInitialMethods(ClassGroup group) public List<Method> getInitialMethods(ClassGroup group)