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);
}
}
if (ctx.getInstruction() instanceof InvokeStatic)
{
if (from.returnSource != null)
{
return resolve(from.returnSource.getPushed(), from.returnSource);
}
}
return ctx;
}

View File

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

View File

@@ -11,6 +11,7 @@ public class StackContext
public Type type; // type of this
private Value value;
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)
{

View File

@@ -522,6 +522,14 @@ public class MapStaticTest
}
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
public ParallelExecutorMapping testPackets(ClassGroup group1, ClassGroup group2) throws IOException