Revert "Remove method context which is unnecessary now theres no more graph analysis"
This reverts commit 4e53b80079741083de724f1056380d095b679e9e.
This commit is contained in:
@@ -2,7 +2,6 @@ package net.runelite.asm.execution;
|
|||||||
|
|
||||||
import com.google.common.collect.Lists;
|
import com.google.common.collect.Lists;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Collection;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import net.runelite.asm.Method;
|
import net.runelite.asm.Method;
|
||||||
import net.runelite.asm.attributes.Code;
|
import net.runelite.asm.attributes.Code;
|
||||||
@@ -13,7 +12,6 @@ import net.runelite.asm.pool.NameAndType;
|
|||||||
import net.runelite.asm.attributes.code.instruction.types.InvokeInstruction;
|
import net.runelite.asm.attributes.code.instruction.types.InvokeInstruction;
|
||||||
import net.runelite.asm.attributes.code.instruction.types.MappableInstruction;
|
import net.runelite.asm.attributes.code.instruction.types.MappableInstruction;
|
||||||
import net.runelite.asm.attributes.code.instructions.InvokeStatic;
|
import net.runelite.asm.attributes.code.instructions.InvokeStatic;
|
||||||
import org.apache.commons.collections4.map.MultiValueMap;
|
|
||||||
|
|
||||||
public class Frame
|
public class Frame
|
||||||
{
|
{
|
||||||
@@ -24,7 +22,7 @@ public class Frame
|
|||||||
private Stack stack;
|
private Stack stack;
|
||||||
private Variables variables;
|
private Variables variables;
|
||||||
private List<InstructionContext> instructions = new ArrayList<>(); // instructions executed in this frame
|
private List<InstructionContext> instructions = new ArrayList<>(); // instructions executed in this frame
|
||||||
private MultiValueMap<InstructionContext, Instruction> visited = new MultiValueMap<>();
|
private MethodContext ctx;
|
||||||
protected Method nonStatic; // next non static method up the stack
|
protected Method nonStatic; // next non static method up the stack
|
||||||
public Frame other; // in the other execution for mapping
|
public Frame other; // in the other execution for mapping
|
||||||
public Frame returnTo; // is this the same as caller?
|
public Frame returnTo; // is this the same as caller?
|
||||||
@@ -39,6 +37,10 @@ public class Frame
|
|||||||
|
|
||||||
stack = new Stack(code.getMaxStack());
|
stack = new Stack(code.getMaxStack());
|
||||||
variables = new Variables(code.getMaxLocals());
|
variables = new Variables(code.getMaxLocals());
|
||||||
|
// don't cache method contexts per execution
|
||||||
|
// need to allow the same method to execute multiple times
|
||||||
|
// when called from multiple places to allow graph building //XXX there no longer is a graph
|
||||||
|
ctx = new MethodContext(execution);
|
||||||
nonStatic = method;
|
nonStatic = method;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -52,6 +54,7 @@ public class Frame
|
|||||||
stack = new Stack(code.getMaxStack());
|
stack = new Stack(code.getMaxStack());
|
||||||
variables = new Variables(code.getMaxLocals());
|
variables = new Variables(code.getMaxLocals());
|
||||||
|
|
||||||
|
ctx = new MethodContext(execution);
|
||||||
nonStatic = method;
|
nonStatic = method;
|
||||||
|
|
||||||
cur = i;
|
cur = i;
|
||||||
@@ -135,6 +138,7 @@ public class Frame
|
|||||||
this.cur = other.cur;
|
this.cur = other.cur;
|
||||||
this.stack = new Stack(other.stack);
|
this.stack = new Stack(other.stack);
|
||||||
this.variables = new Variables(other.variables);
|
this.variables = new Variables(other.variables);
|
||||||
|
this.ctx = other.ctx;
|
||||||
this.nonStatic = other.nonStatic;
|
this.nonStatic = other.nonStatic;
|
||||||
if (other.returnTo != null)
|
if (other.returnTo != null)
|
||||||
{
|
{
|
||||||
@@ -185,6 +189,11 @@ public class Frame
|
|||||||
{
|
{
|
||||||
return variables;
|
return variables;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public MethodContext getMethodCtx()
|
||||||
|
{
|
||||||
|
return ctx;
|
||||||
|
}
|
||||||
|
|
||||||
public void addInstructionContext(InstructionContext i)
|
public void addInstructionContext(InstructionContext i)
|
||||||
{
|
{
|
||||||
@@ -311,7 +320,7 @@ public class Frame
|
|||||||
assert to.getInstructions() == method.getCode().getInstructions();
|
assert to.getInstructions() == method.getCode().getInstructions();
|
||||||
assert method.getCode().getInstructions().getInstructions().contains(to);
|
assert method.getCode().getInstructions().getInstructions().contains(to);
|
||||||
|
|
||||||
if (hasJumped(from, to))
|
if (ctx.hasJumped(from, to))
|
||||||
{
|
{
|
||||||
executing = false;
|
executing = false;
|
||||||
return;
|
return;
|
||||||
@@ -319,14 +328,4 @@ public class Frame
|
|||||||
|
|
||||||
cur = to;
|
cur = to;
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean hasJumped(InstructionContext from, Instruction to)
|
|
||||||
{
|
|
||||||
Collection<Instruction> i = visited.getCollection(from);
|
|
||||||
if (i != null && i.contains(to))
|
|
||||||
return true;
|
|
||||||
|
|
||||||
visited.put(from, to);
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
28
src/main/java/net/runelite/asm/execution/MethodContext.java
Normal file
28
src/main/java/net/runelite/asm/execution/MethodContext.java
Normal file
@@ -0,0 +1,28 @@
|
|||||||
|
package net.runelite.asm.execution;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Collection;
|
||||||
|
import java.util.List;
|
||||||
|
import net.runelite.asm.attributes.code.Instruction;
|
||||||
|
import org.apache.commons.collections4.map.MultiValueMap;
|
||||||
|
|
||||||
|
public class MethodContext
|
||||||
|
{
|
||||||
|
private Execution execution;
|
||||||
|
private MultiValueMap<InstructionContext, Instruction> visited = new MultiValueMap<>();
|
||||||
|
|
||||||
|
public MethodContext(Execution execution)
|
||||||
|
{
|
||||||
|
this.execution = execution;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected boolean hasJumped(InstructionContext from, Instruction to)
|
||||||
|
{
|
||||||
|
Collection<Instruction> i = visited.getCollection(from);
|
||||||
|
if (i != null && i.contains(to))
|
||||||
|
return true;
|
||||||
|
|
||||||
|
visited.put(from, to);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user