Execution test is inf looping with new frame/exec stuff, dont know why.
This commit is contained in:
@@ -129,35 +129,35 @@ public class Rename
|
||||
groupOne = one;
|
||||
groupTwo = two;
|
||||
|
||||
// Execution eone = new Execution(one);
|
||||
// eone.setBuildGraph(true);
|
||||
// eone.setFollowInvokes(false);
|
||||
// eone.populateInitialMethods();
|
||||
// List<Method> initial1 = eone.getInitialMethods().stream().sorted((m1, m2) -> m1.getName().compareTo(m2.getName())).collect(Collectors.toList());
|
||||
// eone.run();
|
||||
//
|
||||
// Execution etwo = new Execution(two);
|
||||
// etwo.setBuildGraph(true);
|
||||
// etwo.setFollowInvokes(false);
|
||||
// etwo.populateInitialMethods();
|
||||
// List<Method> initial2 = etwo.getInitialMethods().stream().sorted((m1, m2) -> m1.getName().compareTo(m2.getName())).collect(Collectors.toList());
|
||||
// etwo.run();
|
||||
//
|
||||
// assert initial1.size() == initial2.size();
|
||||
//
|
||||
// for (int i = 0; i < initial1.size(); ++i)
|
||||
// {
|
||||
// Method m1 = initial1.get(i), m2 = initial2.get(i);
|
||||
//
|
||||
// assert m1.getName().equals(m2.getName());
|
||||
//
|
||||
// objMap.put(m1, m2);
|
||||
// }
|
||||
Execution eone = new Execution(one);
|
||||
eone.setBuildGraph(true);
|
||||
eone.setFollowInvokes(false);
|
||||
eone.populateInitialMethods();
|
||||
List<Method> initial1 = eone.getInitialMethods().stream().sorted((m1, m2) -> m1.getName().compareTo(m2.getName())).collect(Collectors.toList());
|
||||
eone.run();
|
||||
|
||||
Execution etwo = new Execution(two);
|
||||
etwo.setBuildGraph(true);
|
||||
etwo.setFollowInvokes(false);
|
||||
etwo.populateInitialMethods();
|
||||
List<Method> initial2 = etwo.getInitialMethods().stream().sorted((m1, m2) -> m1.getName().compareTo(m2.getName())).collect(Collectors.toList());
|
||||
etwo.run();
|
||||
|
||||
assert initial1.size() == initial2.size();
|
||||
|
||||
for (int i = 0; i < initial1.size(); ++i)
|
||||
{
|
||||
Method m1 = initial1.get(i), m2 = initial2.get(i);
|
||||
|
||||
assert m1.getName().equals(m2.getName());
|
||||
|
||||
objMap.put(m1, m2);
|
||||
}
|
||||
|
||||
process(
|
||||
one.findClass("class143").findMethod("method3014"),
|
||||
two.findClass("class143").findMethod("method2966")
|
||||
);
|
||||
// process(
|
||||
// one.findClass("class143").findMethod("method3014"),
|
||||
// two.findClass("class143").findMethod("method2966")
|
||||
// );
|
||||
|
||||
for (;;)
|
||||
{
|
||||
|
||||
@@ -10,6 +10,7 @@ import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
@@ -19,8 +20,8 @@ import org.apache.commons.collections4.map.MultiValueMap;
|
||||
public class Execution
|
||||
{
|
||||
private ClassGroup group;
|
||||
public List<Frame> frames = new ArrayList<>(),
|
||||
processedFrames = new ArrayList<>();
|
||||
public List<Frame> frames = new LinkedList<>(),
|
||||
processedFrames = new LinkedList<>();
|
||||
public Set<Method> methods = new HashSet<>(); // all methods
|
||||
public Set<Instruction> executed = new HashSet<>(); // executed instructions
|
||||
private MultiValueMap<InstructionContext, Method> invokes = new MultiValueMap<>();
|
||||
@@ -110,7 +111,7 @@ public class Execution
|
||||
|
||||
private void addFrame(Frame frame)
|
||||
{
|
||||
frames.add(frame);
|
||||
frames.add(0, frame);
|
||||
}
|
||||
|
||||
public void invoke(InstructionContext from, Method to)
|
||||
@@ -123,8 +124,7 @@ public class Execution
|
||||
|
||||
Frame f = new Frame(this, to);
|
||||
f.initialize(from);
|
||||
frames.add(0, f);
|
||||
//this.addFrame(f);
|
||||
this.addFrame(f);
|
||||
}
|
||||
|
||||
public void addMethod(Method to)
|
||||
@@ -139,13 +139,25 @@ public class Execution
|
||||
int fcount = 0;
|
||||
while (!frames.isEmpty())
|
||||
{
|
||||
Frame frame = frames.remove(0);
|
||||
Frame frame = frames.get(0);
|
||||
|
||||
methods.add(frame.getMethod());
|
||||
|
||||
++fcount;
|
||||
frame.execute();
|
||||
processedFrames.add(frame);
|
||||
|
||||
if (!frame.isExecuting())
|
||||
{
|
||||
assert frames.get(0) == frame;
|
||||
frames.remove(0);
|
||||
processedFrames.add(frame);
|
||||
System.out.println(fcount + "/" + frames.size());
|
||||
}
|
||||
else
|
||||
{
|
||||
System.out.println("deferring");
|
||||
// another frame takes priority
|
||||
}
|
||||
}
|
||||
|
||||
System.out.println("Processed " + fcount + " frames");
|
||||
|
||||
@@ -129,6 +129,11 @@ public class Frame
|
||||
{
|
||||
return execution;
|
||||
}
|
||||
|
||||
public boolean isExecuting()
|
||||
{
|
||||
return executing;
|
||||
}
|
||||
|
||||
public Method getMethod()
|
||||
{
|
||||
@@ -201,17 +206,8 @@ public class Frame
|
||||
|
||||
execution.executed.add(oldCur);
|
||||
|
||||
if (!execution.frames.isEmpty() && execution.frames.get(0) != this)
|
||||
break;
|
||||
|
||||
processExceptions(oldCur);
|
||||
|
||||
if (oldCur instanceof InvokeInstruction)
|
||||
{
|
||||
InvokeInstruction ii = (InvokeInstruction) oldCur;
|
||||
// this.prevInvokes = ii.getMethods();
|
||||
}
|
||||
|
||||
if (!executing)
|
||||
break;
|
||||
|
||||
@@ -227,6 +223,9 @@ public class Frame
|
||||
{
|
||||
/* jump */
|
||||
}
|
||||
|
||||
if (!execution.frames.isEmpty() && execution.frames.get(0) != this)
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -12,8 +12,18 @@ public class ExecutionTest
|
||||
{
|
||||
ClassGroup group = JarUtil.loadJar(new File("d:/rs/07/adamin1.jar"));
|
||||
|
||||
System.out.println("Done loading jar " + System.currentTimeMillis() / 1000);
|
||||
|
||||
Execution e = new Execution(group);
|
||||
//e.setBuildGraph(true);
|
||||
//e.setFollowInvokes(false);
|
||||
e.populateInitialMethods();
|
||||
e.run();
|
||||
|
||||
System.out.println("Done exec " + System.currentTimeMillis() / 1000);
|
||||
|
||||
Runtime runtime = Runtime.getRuntime();
|
||||
|
||||
System.out.println("Total memory (MB) " + runtime.totalMemory()/1024L/1024L);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user