Execution test is inf looping with new frame/exec stuff, dont know why.

This commit is contained in:
Adam
2015-11-15 21:35:35 -05:00
parent 5e4458ae6e
commit ceafe5acec
4 changed files with 65 additions and 44 deletions

View File

@@ -129,35 +129,35 @@ public class Rename
groupOne = one; groupOne = one;
groupTwo = two; groupTwo = two;
// Execution eone = new Execution(one); Execution eone = new Execution(one);
// eone.setBuildGraph(true); eone.setBuildGraph(true);
// eone.setFollowInvokes(false); eone.setFollowInvokes(false);
// eone.populateInitialMethods(); eone.populateInitialMethods();
// List<Method> initial1 = eone.getInitialMethods().stream().sorted((m1, m2) -> m1.getName().compareTo(m2.getName())).collect(Collectors.toList()); List<Method> initial1 = eone.getInitialMethods().stream().sorted((m1, m2) -> m1.getName().compareTo(m2.getName())).collect(Collectors.toList());
// eone.run(); eone.run();
//
// Execution etwo = new Execution(two); Execution etwo = new Execution(two);
// etwo.setBuildGraph(true); etwo.setBuildGraph(true);
// etwo.setFollowInvokes(false); etwo.setFollowInvokes(false);
// etwo.populateInitialMethods(); etwo.populateInitialMethods();
// List<Method> initial2 = etwo.getInitialMethods().stream().sorted((m1, m2) -> m1.getName().compareTo(m2.getName())).collect(Collectors.toList()); List<Method> initial2 = etwo.getInitialMethods().stream().sorted((m1, m2) -> m1.getName().compareTo(m2.getName())).collect(Collectors.toList());
// etwo.run(); etwo.run();
//
// assert initial1.size() == initial2.size(); assert initial1.size() == initial2.size();
//
// for (int i = 0; i < initial1.size(); ++i) for (int i = 0; i < initial1.size(); ++i)
// { {
// Method m1 = initial1.get(i), m2 = initial2.get(i); Method m1 = initial1.get(i), m2 = initial2.get(i);
//
// assert m1.getName().equals(m2.getName()); assert m1.getName().equals(m2.getName());
//
// objMap.put(m1, m2); objMap.put(m1, m2);
// } }
process( // process(
one.findClass("class143").findMethod("method3014"), // one.findClass("class143").findMethod("method3014"),
two.findClass("class143").findMethod("method2966") // two.findClass("class143").findMethod("method2966")
); // );
for (;;) for (;;)
{ {

View File

@@ -10,6 +10,7 @@ import java.util.ArrayList;
import java.util.Collection; import java.util.Collection;
import java.util.HashMap; import java.util.HashMap;
import java.util.HashSet; import java.util.HashSet;
import java.util.LinkedList;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.Set; import java.util.Set;
@@ -19,8 +20,8 @@ import org.apache.commons.collections4.map.MultiValueMap;
public class Execution public class Execution
{ {
private ClassGroup group; private ClassGroup group;
public List<Frame> frames = new ArrayList<>(), public List<Frame> frames = new LinkedList<>(),
processedFrames = new ArrayList<>(); processedFrames = new LinkedList<>();
public Set<Method> methods = new HashSet<>(); // all methods public Set<Method> methods = new HashSet<>(); // all methods
public Set<Instruction> executed = new HashSet<>(); // executed instructions public Set<Instruction> executed = new HashSet<>(); // executed instructions
private MultiValueMap<InstructionContext, Method> invokes = new MultiValueMap<>(); private MultiValueMap<InstructionContext, Method> invokes = new MultiValueMap<>();
@@ -110,7 +111,7 @@ public class Execution
private void addFrame(Frame frame) private void addFrame(Frame frame)
{ {
frames.add(frame); frames.add(0, frame);
} }
public void invoke(InstructionContext from, Method to) public void invoke(InstructionContext from, Method to)
@@ -123,8 +124,7 @@ public class Execution
Frame f = new Frame(this, to); Frame f = new Frame(this, to);
f.initialize(from); f.initialize(from);
frames.add(0, f); this.addFrame(f);
//this.addFrame(f);
} }
public void addMethod(Method to) public void addMethod(Method to)
@@ -139,13 +139,25 @@ public class Execution
int fcount = 0; int fcount = 0;
while (!frames.isEmpty()) while (!frames.isEmpty())
{ {
Frame frame = frames.remove(0); Frame frame = frames.get(0);
methods.add(frame.getMethod()); methods.add(frame.getMethod());
++fcount; ++fcount;
frame.execute(); 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"); System.out.println("Processed " + fcount + " frames");

View File

@@ -129,6 +129,11 @@ public class Frame
{ {
return execution; return execution;
} }
public boolean isExecuting()
{
return executing;
}
public Method getMethod() public Method getMethod()
{ {
@@ -201,17 +206,8 @@ public class Frame
execution.executed.add(oldCur); execution.executed.add(oldCur);
if (!execution.frames.isEmpty() && execution.frames.get(0) != this)
break;
processExceptions(oldCur); processExceptions(oldCur);
if (oldCur instanceof InvokeInstruction)
{
InvokeInstruction ii = (InvokeInstruction) oldCur;
// this.prevInvokes = ii.getMethods();
}
if (!executing) if (!executing)
break; break;
@@ -227,6 +223,9 @@ public class Frame
{ {
/* jump */ /* jump */
} }
if (!execution.frames.isEmpty() && execution.frames.get(0) != this)
break;
} }
} }

View File

@@ -12,8 +12,18 @@ public class ExecutionTest
{ {
ClassGroup group = JarUtil.loadJar(new File("d:/rs/07/adamin1.jar")); 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); Execution e = new Execution(group);
//e.setBuildGraph(true);
//e.setFollowInvokes(false);
e.populateInitialMethods(); e.populateInitialMethods();
e.run(); e.run();
System.out.println("Done exec " + System.currentTimeMillis() / 1000);
Runtime runtime = Runtime.getRuntime();
System.out.println("Total memory (MB) " + runtime.totalMemory()/1024L/1024L);
} }
} }