Add flag for graph building, which uses too much memory.
This commit is contained in:
@@ -27,6 +27,7 @@ public class Execution
|
|||||||
private Encryption encryption;
|
private Encryption encryption;
|
||||||
public MultiValueMap<Instruction, InstructionContext> contexts = new MultiValueMap<>();
|
public MultiValueMap<Instruction, InstructionContext> contexts = new MultiValueMap<>();
|
||||||
private Map<Method, MethodContext> methodContexts = new HashMap<>();
|
private Map<Method, MethodContext> methodContexts = new HashMap<>();
|
||||||
|
private boolean buildGraph;
|
||||||
|
|
||||||
public Execution(ClassGroup group)
|
public Execution(ClassGroup group)
|
||||||
{
|
{
|
||||||
@@ -139,8 +140,18 @@ public class Execution
|
|||||||
if (c != null)
|
if (c != null)
|
||||||
return c;
|
return c;
|
||||||
|
|
||||||
c = new MethodContext();
|
c = new MethodContext(this);
|
||||||
methodContexts.put(m, c);
|
methodContexts.put(m, c);
|
||||||
return c;
|
return c;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean isBuildGraph()
|
||||||
|
{
|
||||||
|
return buildGraph;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setBuildGraph(boolean buildGraph)
|
||||||
|
{
|
||||||
|
this.buildGraph = buildGraph;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -12,6 +12,7 @@ import java.util.Objects;
|
|||||||
import net.runelite.deob.Method;
|
import net.runelite.deob.Method;
|
||||||
import net.runelite.deob.attributes.code.Instruction;
|
import net.runelite.deob.attributes.code.Instruction;
|
||||||
import net.runelite.deob.attributes.code.instruction.types.InvokeInstruction;
|
import net.runelite.deob.attributes.code.instruction.types.InvokeInstruction;
|
||||||
|
import net.runelite.deob.attributes.code.instructions.InvokeStatic;
|
||||||
import net.runelite.deob.util.IdGen;
|
import net.runelite.deob.util.IdGen;
|
||||||
import org.apache.commons.collections4.map.MultiValueMap;
|
import org.apache.commons.collections4.map.MultiValueMap;
|
||||||
|
|
||||||
@@ -67,11 +68,17 @@ class MIKey
|
|||||||
|
|
||||||
public class MethodContext
|
public class MethodContext
|
||||||
{
|
{
|
||||||
|
private Execution execution;
|
||||||
private MultiValueMap<MIKey, Instruction> visited = new MultiValueMap<>();
|
private MultiValueMap<MIKey, Instruction> visited = new MultiValueMap<>();
|
||||||
private IdGen ids = new IdGen();
|
private IdGen ids = new IdGen();
|
||||||
private Map<Integer, Instruction> idMap = new HashMap<>();
|
private Map<Integer, Instruction> idMap = new HashMap<>();
|
||||||
private Map<Instruction, Integer> insMap = new HashMap<>();
|
private Map<Instruction, Integer> insMap = new HashMap<>();
|
||||||
private Graph graph = new SparseDirectedGraph();
|
private Graph graph = new SparseDirectedGraph();
|
||||||
|
|
||||||
|
public MethodContext(Execution execution)
|
||||||
|
{
|
||||||
|
this.execution = execution;
|
||||||
|
}
|
||||||
|
|
||||||
public Map<Integer, Instruction> getIdMap()
|
public Map<Integer, Instruction> getIdMap()
|
||||||
{
|
{
|
||||||
@@ -85,11 +92,13 @@ public class MethodContext
|
|||||||
|
|
||||||
protected boolean hasJumped(List<Method> fromm, InstructionContext from, Instruction to)
|
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))
|
if (i != null && i.contains(to))
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
visited.put(new MIKey(fromm, from), to);
|
visited.put(key, to);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -110,8 +119,14 @@ public class MethodContext
|
|||||||
|
|
||||||
protected void buildGraph(Frame frame, Instruction i)
|
protected void buildGraph(Frame frame, Instruction i)
|
||||||
{
|
{
|
||||||
|
if (!execution.isBuildGraph())
|
||||||
|
return;
|
||||||
|
|
||||||
if (i instanceof InvokeInstruction)
|
if (i instanceof InvokeInstruction)
|
||||||
{
|
{
|
||||||
|
// if (i instanceof InvokeStatic)
|
||||||
|
// return;
|
||||||
|
|
||||||
InvokeInstruction ii = (InvokeInstruction) i;
|
InvokeInstruction ii = (InvokeInstruction) i;
|
||||||
|
|
||||||
List<Method> methods = ii.getMethods();
|
List<Method> methods = ii.getMethods();
|
||||||
|
|||||||
@@ -70,6 +70,7 @@ public class FrameTest
|
|||||||
ins.addInstruction(i);
|
ins.addInstruction(i);
|
||||||
|
|
||||||
Execution e = new Execution(group);
|
Execution e = new Execution(group);
|
||||||
|
e.setBuildGraph(true);
|
||||||
e.populateInitialMethods();
|
e.populateInitialMethods();
|
||||||
e.run();
|
e.run();
|
||||||
|
|
||||||
@@ -123,6 +124,7 @@ public class FrameTest
|
|||||||
ins.addInstruction(i);
|
ins.addInstruction(i);
|
||||||
|
|
||||||
Execution e = new Execution(group);
|
Execution e = new Execution(group);
|
||||||
|
e.setBuildGraph(true);
|
||||||
e.populateInitialMethods();
|
e.populateInitialMethods();
|
||||||
e.run();
|
e.run();
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user