pop stack more, I dont know if this is right, but maps a couple more fields
This commit is contained in:
@@ -136,17 +136,17 @@ public abstract class If extends Instruction implements JumpingInstruction, Comp
|
||||
|
||||
// switch frame order in executor frame list
|
||||
|
||||
Execution e = f1.getExecution(),
|
||||
e2 = f2.getExecution();
|
||||
|
||||
int i = e2.frames.indexOf(f2),
|
||||
i2 = e2.frames.indexOf(branch2);
|
||||
|
||||
e2.frames.remove(i);
|
||||
e2.frames.add(i, branch2);
|
||||
|
||||
e2.frames.remove(i2);
|
||||
e2.frames.add(i2, f2);
|
||||
// Execution e = f1.getExecution(),
|
||||
// e2 = f2.getExecution();
|
||||
//
|
||||
// int i = e2.frames.indexOf(f2),
|
||||
// i2 = e2.frames.indexOf(branch2);
|
||||
//
|
||||
// e2.frames.remove(i);
|
||||
// e2.frames.add(i, branch2);
|
||||
//
|
||||
// e2.frames.remove(i2);
|
||||
// e2.frames.add(i2, f2);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -139,17 +139,17 @@ public abstract class If0 extends Instruction implements JumpingInstruction, Com
|
||||
|
||||
// switch frame order in executor frame list
|
||||
|
||||
Execution e = f1.getExecution(),
|
||||
e2 = f2.getExecution();
|
||||
|
||||
int i = e2.frames.indexOf(f2),
|
||||
i2 = e2.frames.indexOf(branch2);
|
||||
|
||||
e2.frames.remove(i);
|
||||
e2.frames.add(i, branch2);
|
||||
|
||||
e2.frames.remove(i2);
|
||||
e2.frames.add(i2, f2);
|
||||
// Execution e = f1.getExecution(),
|
||||
// e2 = f2.getExecution();
|
||||
//
|
||||
// int i = e2.frames.indexOf(f2),
|
||||
// i2 = e2.frames.indexOf(branch2);
|
||||
//
|
||||
// e2.frames.remove(i);
|
||||
// e2.frames.add(i, branch2);
|
||||
//
|
||||
// e2.frames.remove(i2);
|
||||
// e2.frames.add(i2, f2);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -27,7 +27,7 @@ public class MethodSignatureMapper
|
||||
{
|
||||
for (Method m : c1.getMethods().getMethods())
|
||||
{
|
||||
if (m.isStatic() || m.getName().equals("<init>") || count(c1.getMethods(), m.getDescriptor()) > 1)
|
||||
if (m.isStatic() || count(c1.getMethods(), m.getDescriptor()) > 1)
|
||||
continue;
|
||||
|
||||
Method other = get(c2.getMethods(), m.getDescriptor());
|
||||
|
||||
@@ -12,7 +12,7 @@ public class ParallelExecutorMapping
|
||||
{
|
||||
private ClassGroup group, group2;
|
||||
private Map<Object, Object> map = new HashMap<>();
|
||||
private List<Object> order = new ArrayList<>();
|
||||
//private List<Object> order = new ArrayList<>();
|
||||
public Method m1, m2;
|
||||
|
||||
public ParallelExecutorMapping(ClassGroup group, ClassGroup group2)
|
||||
@@ -39,7 +39,7 @@ public class ParallelExecutorMapping
|
||||
belongs(two, group2);
|
||||
|
||||
map.put(one, two);
|
||||
order.add(one);
|
||||
//order.add(one);
|
||||
}
|
||||
|
||||
public Object get(Object o)
|
||||
@@ -52,7 +52,7 @@ public class ParallelExecutorMapping
|
||||
return map;
|
||||
}
|
||||
|
||||
public List<Object> getOrder() { return order; }
|
||||
//public List<Object> getOrder() { return order; }
|
||||
|
||||
private void belongs(Object o, ClassGroup to)
|
||||
{
|
||||
|
||||
@@ -51,6 +51,8 @@ public class ParallellMappingExecutor
|
||||
return step();
|
||||
}
|
||||
|
||||
//assert e2.frames.contains(f2);
|
||||
|
||||
// assert f1.other.other == f1;
|
||||
// assert f2.other.other == f2;
|
||||
|
||||
@@ -63,94 +65,16 @@ public class ParallellMappingExecutor
|
||||
// before realizing its already executed it before, so it will set the frame
|
||||
// as not executing
|
||||
if (!f1.isExecuting() || !f2.isExecuting())
|
||||
{
|
||||
// assert f1.returnTo == null || !e.frames.contains(f1.returnTo);
|
||||
// assert f2.returnTo == null || !e2.frames.contains(f2.returnTo);
|
||||
//
|
||||
// // get the previous instruction. if this frame is the result of a fork and there isn't any, get the fork instruction
|
||||
// InstructionContext fork1 = f1.getInstructions().isEmpty() ? f1.forking : f1.getInstructions().get(f1.getInstructions().size() - 1);
|
||||
// InstructionContext fork2 = f2.getInstructions().isEmpty() ? f2.forking : f2.getInstructions().get(f2.getInstructions().size() - 1);
|
||||
//
|
||||
// assert fork1 != null;
|
||||
// assert fork2 != null;
|
||||
//
|
||||
// if (!(f1.getInstructions().isEmpty() == f2.getInstructions().isEmpty()))
|
||||
// {
|
||||
// int i = 5;
|
||||
// }
|
||||
//
|
||||
// // Due to jump ob one side can stop while the other side jumps. So we need to remove the excess frames to keep it in line.
|
||||
//
|
||||
// if (fork1 == f1.forking)
|
||||
// {
|
||||
// // if f1 was forked, remove source frame.
|
||||
//
|
||||
// assert fork1.getBranches().size() == 1;
|
||||
// //assert fork1.getBranches().get(0) == f1;
|
||||
//
|
||||
// int i1 = e.frames.indexOf(fork1.getFrame()); // this might be -1 because it is now in an invokestatic. AHhh.
|
||||
// if (i1 == -1)
|
||||
// {
|
||||
// i1 = e.frames.indexOf(fork1.getFrame().returnTo);
|
||||
// //XXX returnframes are diff objects is why?
|
||||
// }
|
||||
// int i2 = e.frames.indexOf(fork1.getBranches().get(0));
|
||||
//
|
||||
// // remove fork1.frame
|
||||
// e.frames.remove(fork1.getFrame());
|
||||
// //e.frames.remove(fork1.getBranches().get(0));
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// //p1 = f1.getInstructions().get(f1.getInstructions().size() - 1);
|
||||
//
|
||||
// for (Frame branch : fork1.getBranches())
|
||||
// {
|
||||
// e.frames.remove(branch);
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// // this is empty but should be removing a branch, because of the map other, theres no prev instruction.
|
||||
// // should always populate prev instruction
|
||||
// //if (f2.getInstructions().size() > 0)
|
||||
// if (fork2 == f2.forking)
|
||||
// {
|
||||
// assert fork2.getBranches().size() == 1;
|
||||
// //assert fork2.getBranches().get(0) == f2;
|
||||
//
|
||||
// int i1 = e2.frames.indexOf(fork2.getFrame());
|
||||
// int i2 = e2.frames.indexOf(fork2.getBranches().get(0));
|
||||
//
|
||||
// e2.frames.remove(fork2.getFrame());
|
||||
// //e.frames.remove(fork2.getBranches().get(0));
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// //p2 = f2.getInstructions().get(f2.getInstructions().size() - 1);
|
||||
//
|
||||
// for (Frame branch : fork2.getBranches())
|
||||
// {
|
||||
// e2.frames.remove(branch);
|
||||
// }
|
||||
// }
|
||||
{
|
||||
// assert f1.returnTo == null;
|
||||
// assert f2.returnTo == null;
|
||||
|
||||
//assert e.frames.get(0) == f1;
|
||||
//assert e2.frames.get(0) == f2;
|
||||
// XXX I dont know if this is right! only helps a few fields.
|
||||
popStack(f1);
|
||||
popStack(f2);
|
||||
|
||||
e.frames.remove(f1);
|
||||
e2.frames.remove(f2);
|
||||
|
||||
// Frame f1wtf = e.frames.get(0),
|
||||
// f2wtf = e2.frames.get(0);
|
||||
//
|
||||
// int otherIndex1 = e2.frames.indexOf(f1wtf.other),
|
||||
// otherIndex2 = e.frames.indexOf(f2wtf.other);
|
||||
//
|
||||
// // assert f1wtf.other.other == f1wtf;
|
||||
// // assert f2wtf.other.other == f2wtf;
|
||||
//
|
||||
// assert f1wtf.other == f2wtf;
|
||||
// assert f2wtf.other == f1wtf;
|
||||
|
||||
step1 = step2 = true;
|
||||
|
||||
@@ -344,10 +268,17 @@ public class ParallellMappingExecutor
|
||||
f2.created = is;
|
||||
f2.initialize(i);
|
||||
|
||||
assert e.frames.contains(f);
|
||||
int idx = e.frames.indexOf(f);
|
||||
e.frames.remove(f); // old frame goes away
|
||||
e.frames.add(idx, f2);
|
||||
// assert e.frames.contains(f);
|
||||
if (e.frames.contains(f))
|
||||
{
|
||||
int idx = e.frames.indexOf(f);
|
||||
e.frames.remove(f); // old frame goes away
|
||||
e.frames.add(idx, f2);
|
||||
}
|
||||
else
|
||||
{
|
||||
e.frames.add(f);
|
||||
}
|
||||
|
||||
assert f.other.other == f;
|
||||
|
||||
@@ -370,9 +301,12 @@ public class ParallellMappingExecutor
|
||||
if (f.isExecuting() || f.returnTo == null)
|
||||
return f;
|
||||
|
||||
InstructionContext i = f.getInstructions().get(f.getInstructions().size() - 1);
|
||||
if (!(i.getInstruction() instanceof ReturnInstruction))
|
||||
return f;
|
||||
// if (!f.getInstructions().isEmpty())
|
||||
// return f;
|
||||
//
|
||||
// InstructionContext i = f.getInstructions().get(f.getInstructions().size() - 1);
|
||||
// if (!(i.getInstruction() instanceof ReturnInstruction))
|
||||
// return f;
|
||||
|
||||
Frame r = popStackForce(f);
|
||||
|
||||
@@ -390,14 +324,21 @@ public class ParallellMappingExecutor
|
||||
|
||||
assert f.returnTo != null;
|
||||
|
||||
assert e.frames.contains(f);
|
||||
//assert e.frames.contains(f);
|
||||
assert !e.frames.contains(f.returnTo);
|
||||
|
||||
// replace frame with returnTo
|
||||
int idx = e.frames.indexOf(f);
|
||||
e.frames.remove(f);
|
||||
assert !e.frames.contains(f.returnTo);
|
||||
e.frames.add(idx, f.returnTo);
|
||||
if (e.frames.contains(f))
|
||||
{
|
||||
// replace frame with returnTo
|
||||
int idx = e.frames.indexOf(f);
|
||||
e.frames.remove(f);
|
||||
assert !e.frames.contains(f.returnTo);
|
||||
e.frames.add(idx, f.returnTo);
|
||||
}
|
||||
else
|
||||
{
|
||||
e.frames.add(f.returnTo);
|
||||
}
|
||||
|
||||
assert f.other.other == f;
|
||||
assert f.returnTo.other == null;
|
||||
|
||||
@@ -88,13 +88,13 @@ public class MapStaticTest
|
||||
ClassGroup group1 = JarUtil.loadJar(new File(JAR1));
|
||||
ClassGroup group2 = JarUtil.loadJar(new File(JAR2));
|
||||
|
||||
Method m1 = group1.findClass("client").findMethod("vmethod3054");
|
||||
Method m2 = group2.findClass("client").findMethod("vmethod2973");
|
||||
Method m1 = group1.findClass("class92").findMethod("method2176");
|
||||
Method m2 = group2.findClass("client").findMethod("method540");
|
||||
|
||||
ParallelExecutorMapping mappings = MappingExecutorUtil.map(m1, m2);
|
||||
|
||||
System.out.println("BEGIN OF MAPPING");
|
||||
for (Object o : mappings.getOrder())
|
||||
for (Object o : mappings.getMap().keySet())
|
||||
{
|
||||
Object value = mappings.get(o);
|
||||
System.out.println(o + " <-> " + value);
|
||||
@@ -116,8 +116,8 @@ public class MapStaticTest
|
||||
ClassGroup group1 = JarUtil.loadJar(new File(JAR1));
|
||||
ClassGroup group2 = JarUtil.loadJar(new File(JAR2));
|
||||
|
||||
Method m1 = group1.findClass("client").findMethod("vmethod3096");
|
||||
Method m2 = group2.findClass("client").findMethod("vmethod2975");
|
||||
Method m1 = group1.findClass("class92").findMethod("method2176");
|
||||
Method m2 = group2.findClass("client").findMethod("method540");
|
||||
|
||||
HashMap<Object, Object> all = new HashMap();
|
||||
List<ParallelExecutorMapping> pmes = new ArrayList<>();
|
||||
@@ -127,7 +127,13 @@ public class MapStaticTest
|
||||
for (ParallelExecutorMapping pme : pmes)
|
||||
finalm.merge(pme);
|
||||
|
||||
//summary(finalm);
|
||||
System.out.println("BEGIN OF MAPPING");
|
||||
for (Object o : finalm.getMap().keySet())
|
||||
{
|
||||
Object value = finalm.get(o);
|
||||
System.out.println(o + " <-> " + value);
|
||||
}
|
||||
System.out.println("END OF MAPPINGS " + finalm.getMap().size());
|
||||
}
|
||||
|
||||
//@Test
|
||||
@@ -237,18 +243,18 @@ public class MapStaticTest
|
||||
|
||||
System.out.println("GROUP 1 " + sg1);
|
||||
System.out.println("GROUP 2 " + sg2);
|
||||
// System.out.println("db step " + ParallellMappingExecutor.doubleStep.size());
|
||||
//
|
||||
// for (Method m : group1.findClass("client").getMethods().getMethods())
|
||||
// {
|
||||
// if (!finalm.getMap().containsKey(m) && !m.isStatic())
|
||||
// System.out.println("missing " + m);
|
||||
// }
|
||||
// for (Field m : group1.findClass("client").getFields().getFields())
|
||||
// {
|
||||
// if (!finalm.getMap().containsKey(m))
|
||||
// System.out.println("missing " + m);
|
||||
// }
|
||||
|
||||
|
||||
for (Method m : group1.findClass("client").getMethods().getMethods())
|
||||
{
|
||||
if (!finalm.getMap().containsKey(m))
|
||||
System.out.println("missing " + m);
|
||||
}
|
||||
for (Field m : group1.findClass("client").getFields().getFields())
|
||||
{
|
||||
if (!finalm.getMap().containsKey(m))
|
||||
System.out.println("missing " + m);
|
||||
}
|
||||
}
|
||||
|
||||
//@Test
|
||||
|
||||
Reference in New Issue
Block a user