Search in sources :

Example 16 with LVTInstruction

use of net.runelite.asm.attributes.code.instruction.types.LVTInstruction in project runelite by runelite.

the class ExprArgOrder method canRemove.

private boolean canRemove(MethodContext mctx, Instructions ins, Instruction i) {
    Set<InstructionContext> ctxs = new HashSet<>(mctx.getInstructonContexts(i));
    if (!alwaysPoppedBySameInstruction(ctxs, i) || !alwaysPopsFromSameInstructions(ctxs, i)) {
        return false;
    }
    if (i instanceof InvokeInstruction) {
        // func1() + func2() vs func2() + func1() is not the same thing
        return false;
    }
    int idx = ins.getInstructions().indexOf(i);
    if (idx == -1) {
        return false;
    }
    for (InstructionContext ictx : ctxs) {
        for (StackContext sctx : ictx.getPops()) {
            Instruction pushed = sctx.getPushed().getInstruction();
            int idx2 = ins.getInstructions().indexOf(pushed);
            if (idx2 == -1) {
                return false;
            }
            assert idx > idx2;
            // instructions, we can't move them
            for (int j = idx2; j <= idx; ++j) {
                Instruction i2 = ins.getInstructions().get(j);
                if (i2 instanceof LVTInstruction) {
                    if (((LVTInstruction) i2).store()) {
                        return false;
                    }
                }
                if (i2 instanceof IInc) {
                    return false;
                }
            }
            if (!canRemove(mctx, ins, pushed)) {
                return false;
            }
        }
    }
    return true;
}
Also used : InstructionContext(net.runelite.asm.execution.InstructionContext) InvokeInstruction(net.runelite.asm.attributes.code.instruction.types.InvokeInstruction) StackContext(net.runelite.asm.execution.StackContext) IInc(net.runelite.asm.attributes.code.instructions.IInc) PushConstantInstruction(net.runelite.asm.attributes.code.instruction.types.PushConstantInstruction) InvokeInstruction(net.runelite.asm.attributes.code.instruction.types.InvokeInstruction) LVTInstruction(net.runelite.asm.attributes.code.instruction.types.LVTInstruction) Instruction(net.runelite.asm.attributes.code.Instruction) LVTInstruction(net.runelite.asm.attributes.code.instruction.types.LVTInstruction) HashSet(java.util.HashSet)

Aggregations

LVTInstruction (net.runelite.asm.attributes.code.instruction.types.LVTInstruction)16 Instruction (net.runelite.asm.attributes.code.Instruction)11 InvokeInstruction (net.runelite.asm.attributes.code.instruction.types.InvokeInstruction)6 PushConstantInstruction (net.runelite.asm.attributes.code.instruction.types.PushConstantInstruction)6 InstructionContext (net.runelite.asm.execution.InstructionContext)6 StackContext (net.runelite.asm.execution.StackContext)6 ArrayList (java.util.ArrayList)5 Signature (net.runelite.asm.signature.Signature)5 Method (net.runelite.asm.Method)4 InstructionType (net.runelite.asm.attributes.code.InstructionType)4 SetFieldInstruction (net.runelite.asm.attributes.code.instruction.types.SetFieldInstruction)4 Collections (java.util.Collections)3 List (java.util.List)3 ClassFile (net.runelite.asm.ClassFile)3 ClassGroup (net.runelite.asm.ClassGroup)3 Type (net.runelite.asm.Type)3 DupInstruction (net.runelite.asm.attributes.code.instruction.types.DupInstruction)3 If (net.runelite.asm.attributes.code.instructions.If)3 HashMultimap (com.google.common.collect.HashMultimap)2 Multimap (com.google.common.collect.Multimap)2