Store return stack pop with stack context instead of what I was trying to do before

This commit is contained in:
Adam
2016-02-27 12:58:44 -05:00
parent 5fea3a9c31
commit fb4ee1ac9b
4 changed files with 42 additions and 22 deletions

View File

@@ -301,6 +301,14 @@ public class MappingExecutorUtil
return resolve(storedCtx, null); return resolve(storedCtx, null);
} }
} }
if (ctx.getInstruction() instanceof InvokeStatic)
{
if (from.returnSource != null)
{
return resolve(from.returnSource.getPushed(), from.returnSource);
}
}
return ctx; return ctx;
} }

View File

@@ -297,7 +297,7 @@ public class ParallellMappingExecutor
return f2; return f2;
} }
public static boolean enable = false; public static boolean enable = true;
public static List<StackContext> returnStacks = new ArrayList<>(); public static List<StackContext> returnStacks = new ArrayList<>();
private Frame popStack(Frame f) private Frame popStack(Frame f)
{ {
@@ -335,27 +335,30 @@ public class ParallellMappingExecutor
StackContext invokePushed = i2.getPushes().get(0); StackContext invokePushed = i2.getPushes().get(0);
if (invokePushed.getPushed().getInstruction() != i2.getInstruction()) //assert invokePushed.returnSource == null;
//if (!(invokePushed.getPushed().getInstruction() instanceof InvokeStatic)) invokePushed.returnSource = returnValue;
{ //
return r; // if (invokePushed.getPushed().getInstruction() != i2.getInstruction())
} // //if (!(invokePushed.getPushed().getInstruction() instanceof InvokeStatic))
// {
//returnStacks.add(invokePushed); // return r;
returnStacks.add(returnValue); // }
boolean b = returnStacks.contains(invokePushed); //
assert invokePushed.getPopped().isEmpty(); // //returnStacks.add(invokePushed);
// returnStacks.add(returnValue);
// replace invokePushed with returnValue? // boolean b = returnStacks.contains(invokePushed);
i2.getPushes().remove(invokePushed); // assert invokePushed.getPopped().isEmpty();
i2.getPushes().add(returnValue); //
// // replace invokePushed with returnValue?
//invokePushed.setpushed = null // i2.getPushes().remove(invokePushed);
// i2.getPushes().add(returnValue);
Stack stack = r.getStack(); //
StackContext s = stack.pop(); // //invokePushed.setpushed = null
assert s == invokePushed; //
stack.push(returnValue); // Stack stack = r.getStack();
// StackContext s = stack.pop();
// assert s == invokePushed;
// stack.push(returnValue);
//assert invokePushed.getPushed().getPushes().contains(invokePushed); //assert invokePushed.getPushed().getPushes().contains(invokePushed);
//invokePushed.getpu //invokePushed.getpu

View File

@@ -11,6 +11,7 @@ public class StackContext
public Type type; // type of this public Type type; // type of this
private Value value; private Value value;
public boolean removed; public boolean removed;
public StackContext returnSource; // if this is the return value of an invokestatic, returnSource is the stack popped by the Return instruction
public StackContext(InstructionContext pushed, Type type, Value value) public StackContext(InstructionContext pushed, Type type, Value value)
{ {

View File

@@ -522,6 +522,14 @@ public class MapStaticTest
} }
return list; return list;
} }
@Test
public void testPackets() throws IOException
{
ClassGroup group1 = JarUtil.loadJar(new File(JAR1));
ClassGroup group2 = JarUtil.loadJar(new File(JAR2));
testPackets(group1, group2);
}
//@Test //@Test
public ParallelExecutorMapping testPackets(ClassGroup group1, ClassGroup group2) throws IOException public ParallelExecutorMapping testPackets(ClassGroup group1, ClassGroup group2) throws IOException