Add flag for graph building, which uses too much memory.

This commit is contained in:
Adam
2015-11-15 11:59:08 -05:00
parent 7b94552825
commit 44767a9735
3 changed files with 31 additions and 3 deletions

View File

@@ -27,6 +27,7 @@ public class Execution
private Encryption encryption;
public MultiValueMap<Instruction, InstructionContext> contexts = new MultiValueMap<>();
private Map<Method, MethodContext> methodContexts = new HashMap<>();
private boolean buildGraph;
public Execution(ClassGroup group)
{
@@ -139,8 +140,18 @@ public class Execution
if (c != null)
return c;
c = new MethodContext();
c = new MethodContext(this);
methodContexts.put(m, c);
return c;
}
public boolean isBuildGraph()
{
return buildGraph;
}
public void setBuildGraph(boolean buildGraph)
{
this.buildGraph = buildGraph;
}
}

View File

@@ -12,6 +12,7 @@ import java.util.Objects;
import net.runelite.deob.Method;
import net.runelite.deob.attributes.code.Instruction;
import net.runelite.deob.attributes.code.instruction.types.InvokeInstruction;
import net.runelite.deob.attributes.code.instructions.InvokeStatic;
import net.runelite.deob.util.IdGen;
import org.apache.commons.collections4.map.MultiValueMap;
@@ -67,11 +68,17 @@ class MIKey
public class MethodContext
{
private Execution execution;
private MultiValueMap<MIKey, Instruction> visited = new MultiValueMap<>();
private IdGen ids = new IdGen();
private Map<Integer, Instruction> idMap = new HashMap<>();
private Map<Instruction, Integer> insMap = new HashMap<>();
private Graph graph = new SparseDirectedGraph();
public MethodContext(Execution execution)
{
this.execution = execution;
}
public Map<Integer, Instruction> getIdMap()
{
@@ -85,11 +92,13 @@ public class MethodContext
protected boolean hasJumped(List<Method> fromm, InstructionContext from, Instruction to)
{
Collection<Instruction> i = visited.getCollection(new MIKey(fromm, from));
// with this true, there are so many frames I can't run a full execution without oom.
MIKey key = execution.isBuildGraph() ? new MIKey(fromm, from) : new MIKey(null, from);
Collection<Instruction> i = visited.getCollection(key);
if (i != null && i.contains(to))
return true;
visited.put(new MIKey(fromm, from), to);
visited.put(key, to);
return false;
}
@@ -110,8 +119,14 @@ public class MethodContext
protected void buildGraph(Frame frame, Instruction i)
{
if (!execution.isBuildGraph())
return;
if (i instanceof InvokeInstruction)
{
// if (i instanceof InvokeStatic)
// return;
InvokeInstruction ii = (InvokeInstruction) i;
List<Method> methods = ii.getMethods();

View File

@@ -70,6 +70,7 @@ public class FrameTest
ins.addInstruction(i);
Execution e = new Execution(group);
e.setBuildGraph(true);
e.populateInitialMethods();
e.run();
@@ -123,6 +124,7 @@ public class FrameTest
ins.addInstruction(i);
Execution e = new Execution(group);
e.setBuildGraph(true);
e.populateInitialMethods();
e.run();