diff --git a/src/main/java/net/runelite/asm/attributes/code/instructions/If.java b/src/main/java/net/runelite/asm/attributes/code/instructions/If.java index 9b28068374..b0bb14aba7 100644 --- a/src/main/java/net/runelite/asm/attributes/code/instructions/If.java +++ b/src/main/java/net/runelite/asm/attributes/code/instructions/If.java @@ -83,8 +83,6 @@ public abstract class If extends Instruction implements JumpingInstruction, Comp ins.pop(one, two); Frame other = frame.dup(); - other.created = this; - other.forking = ins; other.jump(ins, to); ins.branch(other); diff --git a/src/main/java/net/runelite/asm/attributes/code/instructions/If0.java b/src/main/java/net/runelite/asm/attributes/code/instructions/If0.java index 8d9216ae6b..c8b4ad749c 100644 --- a/src/main/java/net/runelite/asm/attributes/code/instructions/If0.java +++ b/src/main/java/net/runelite/asm/attributes/code/instructions/If0.java @@ -74,8 +74,6 @@ public abstract class If0 extends Instruction implements JumpingInstruction, Com ins.pop(one); Frame other = frame.dup(); - other.created = this; - other.forking = ins; other.jump(ins, to); ins.branch(other); diff --git a/src/main/java/net/runelite/asm/attributes/code/instructions/LookupSwitch.java b/src/main/java/net/runelite/asm/attributes/code/instructions/LookupSwitch.java index 3db9cdb795..576ab15ed8 100644 --- a/src/main/java/net/runelite/asm/attributes/code/instructions/LookupSwitch.java +++ b/src/main/java/net/runelite/asm/attributes/code/instructions/LookupSwitch.java @@ -114,7 +114,6 @@ public class LookupSwitch extends Instruction implements JumpingInstruction for (Instruction i : branchi) { Frame other = frame.dup(); - other.forking = ins; other.jump(ins, i); ins.branch(other); diff --git a/src/main/java/net/runelite/asm/execution/Frame.java b/src/main/java/net/runelite/asm/execution/Frame.java index 9f7c4aefbd..b647b3f4dd 100644 --- a/src/main/java/net/runelite/asm/execution/Frame.java +++ b/src/main/java/net/runelite/asm/execution/Frame.java @@ -28,14 +28,9 @@ public class Frame private List instructions = new ArrayList<>(); // instructions executed in this frame private MethodContext ctx; protected Method nonStatic; // next non static method up the stack - private Frame caller; public Frame other; // in the other execution for mapping public Frame returnTo; // is this the same as caller? public Frame otherStatic; - public Instruction created; - public InstructionContext forking; - public boolean initial; - public boolean isdup,iscopy; public Frame(Execution execution, Method method) { @@ -77,7 +72,6 @@ public class Frame public void initialize() { - initial = true; // initialize LVT int pos = 0; if (!method.isStatic()) @@ -96,7 +90,6 @@ public class Frame public void initialize(InstructionContext ctx) { - created = ctx.getInstruction(); // initialize frame from invoking context assert ctx.getInstruction() instanceof InvokeInstruction; @@ -107,7 +100,6 @@ public class Frame { this.nonStatic = ctx.getFrame().nonStatic; } - caller = ctx.getFrame(); // initialize LVT. the last argument is popped first, and is at arguments[0] List pops = ctx.getPops(); @@ -144,7 +136,6 @@ public class Frame protected Frame(Frame other) { - iscopy=true; this.execution = other.execution; this.method = other.method; this.executing = other.executing; @@ -153,21 +144,17 @@ public class Frame this.variables = new Variables(other.variables); this.ctx = other.ctx; this.nonStatic = other.nonStatic; - this.caller = other.caller; if (other.returnTo != null) { this.returnTo = new Frame(other.returnTo); this.returnTo.instructions.addAll(other.returnTo.instructions); } - this.created = other.created; - this.forking = other.forking; this.otherStatic = other.otherStatic; } public Frame dup() { Frame other = new Frame(this); - other.isdup=true; execution.frames.add(other); return other; } diff --git a/src/main/java/net/runelite/asm/execution/ParallellMappingExecutor.java b/src/main/java/net/runelite/asm/execution/ParallellMappingExecutor.java index f89b359f03..ac8b50e455 100644 --- a/src/main/java/net/runelite/asm/execution/ParallellMappingExecutor.java +++ b/src/main/java/net/runelite/asm/execution/ParallellMappingExecutor.java @@ -43,29 +43,13 @@ public class ParallellMappingExecutor return step(); } - //assert e2.frames.contains(f2); - -// assert f1.other.other == f1; -// assert f2.other.other == f2; - - //assert f1.other == f2; assert f2.other == f1; - //assert f1.isExecuting() == f2.isExecuting(); - // this will happen because conditional branches will create their frame // before realizing its already executed it before, so it will set the frame // as not executing if (!f1.isExecuting() || !f2.isExecuting()) - { -// assert f1.returnTo == null; -// assert f2.returnTo == null; - - // XXX I dont know if this is right! only helps a few fields. - // XXX if a frame exits from a jump loop it would step out which might be bad - //popStack(f1); - //popStack(f2); - + { e.frames.remove(f1); e2.frames.remove(f2); @@ -73,9 +57,6 @@ public class ParallellMappingExecutor return step(); } - - Frame old1 = new Frame(f1), old2 = new Frame(f2); - int s1 = e.frames.size(), s2 = e2.frames.size(); // step frame if (step1) @@ -100,11 +81,6 @@ public class ParallellMappingExecutor // System.out.println("STEP OUT " + oldf1.getMethod() + " <-> " + oldf2.getMethod()); } -// if (e.frames.size() - s1 != e2.frames.size() - s2) -// { -// System.out.println("fr mismatch"); -// } - if (oldf1 != f1 || oldf2 != f2) { if (f1 == oldf1) @@ -113,20 +89,6 @@ public class ParallellMappingExecutor step2 = false; return step(); } - - if (oldf1 != f1 || oldf2 != f2) - { -// assert oldf1 != f1; -// assert oldf2 != f2; -// -// Method m1 = oldf1.getMethod(), m2 = oldf2.getMethod(); -// -// System.out.println("RETURN MAP " + m1 + " -> " + m2); -// -// // if one exits and the other doesnt, the functions arent equal -// assert oldf1.otherStatic == oldf2; -// assert oldf2.otherStatic == oldf1; - } // get what each frame is paused/exited on p1 = f1.getInstructions().get(f1.getInstructions().size() - 1); @@ -144,58 +106,33 @@ public class ParallellMappingExecutor { if (stepInto(f1) == null) { - //f1.stop(); return step(); } - //try - //{ - step2 = false; - return step(); -// } -// finally -// { -// step2 = true; -// } + step2 = false; + return step(); } else if (MappingExecutorUtil.isInlineable(p2.getInstruction()) && !MappingExecutorUtil.isInlineable(p1.getInstruction())) { if (stepInto(f2) == null) { - //f2.stop(); return step(); } - //try - //{ - step1 = false; - return step(); -// } -// finally -// { -// step1 = true; -// } + step1 = false; + return step(); } else if (MappingExecutorUtil.isInlineable(p1.getInstruction()) && MappingExecutorUtil.isInlineable(p2.getInstruction())) { Frame stepf1 = stepInto(f1); Frame stepf2 = stepInto(f2); - if (stepf1 == null) - { - //f1.stop(); - } - if (stepf2 == null) - { - //f2.stop(); - } if (stepf1 == null || stepf2 == null) return step(); stepf1.otherStatic = stepf2; stepf2.otherStatic = stepf1; - doubleStep.add(stepf1.getMethod()); //System.out.println("STEP " + stepf1.getMethod() + " <-> " + stepf2.getMethod()); return step(); @@ -206,7 +143,6 @@ public class ParallellMappingExecutor return true; } - public static Set doubleStep = new HashSet(); public InstructionContext getP1() { @@ -254,14 +190,10 @@ public class ParallellMappingExecutor if (e.hasInvoked(i, to)) return null; - //assert e.methods.contains(to) == false; - //e.methods.add(to); Frame f2 = new Frame(e, to); - f2.created = is; f2.initialize(i); -// assert e.frames.contains(f); if (e.frames.contains(f)) { int idx = e.frames.indexOf(f); @@ -295,10 +227,7 @@ public class ParallellMappingExecutor if (f.isExecuting() || f.returnTo == null) return f; - -// if (!f.getInstructions().isEmpty()) -// return f; -// + InstructionContext i = f.getInstructions().get(f.getInstructions().size() - 1); if (!(i.getInstruction() instanceof ReturnInstruction)) return f; @@ -325,38 +254,9 @@ public class ParallellMappingExecutor StackContext invokePushed = i2.getPushes().get(0); - //assert invokePushed.returnSource == null; invokePushed.returnSource = returnValue; -// -// if (invokePushed.getPushed().getInstruction() != i2.getInstruction()) -// //if (!(invokePushed.getPushed().getInstruction() instanceof InvokeStatic)) -// { -// return r; -// } -// -// //returnStacks.add(invokePushed); -// returnStacks.add(returnValue); -// boolean b = returnStacks.contains(invokePushed); -// assert invokePushed.getPopped().isEmpty(); -// -// // replace invokePushed with returnValue? -// i2.getPushes().remove(invokePushed); -// i2.getPushes().add(returnValue); -// -// //invokePushed.setpushed = null -// -// Stack stack = r.getStack(); -// StackContext s = stack.pop(); -// assert s == invokePushed; -// stack.push(returnValue); - - //assert invokePushed.getPushed().getPushes().contains(invokePushed); - //invokePushed.getpu } - // step return frame - //r.execute(); - return r; } @@ -391,9 +291,6 @@ public class ParallellMappingExecutor f.other = null; - // step return frame - //f.returnTo.execute(); - return f.returnTo; }