Search in sources :

Example 11 with RegisterArg

use of jadx.core.dex.instructions.args.RegisterArg in project jadx by skylot.

the class InstructionRemover method unbindArgUsage.

public static void unbindArgUsage(MethodNode mth, InsnArg arg) {
    if (arg instanceof RegisterArg) {
        RegisterArg reg = (RegisterArg) arg;
        SSAVar sVar = reg.getSVar();
        if (sVar != null) {
            sVar.removeUse(reg);
        }
    } else if (arg instanceof InsnWrapArg) {
        InsnWrapArg wrap = (InsnWrapArg) arg;
        unbindInsn(mth, wrap.getWrapInsn());
    }
}
Also used : RegisterArg(jadx.core.dex.instructions.args.RegisterArg) SSAVar(jadx.core.dex.instructions.args.SSAVar) InsnWrapArg(jadx.core.dex.instructions.args.InsnWrapArg)

Example 12 with RegisterArg

use of jadx.core.dex.instructions.args.RegisterArg in project jadx by skylot.

the class SSATransform method renameVariables.

private static void renameVariables(MethodNode mth) {
    if (!mth.getSVars().isEmpty()) {
        throw new JadxRuntimeException("SSA rename variables already executed");
    }
    int regsCount = mth.getRegsCount();
    SSAVar[] vars = new SSAVar[regsCount];
    int[] versions = new int[regsCount];
    // init method arguments
    for (RegisterArg arg : mth.getArguments(true)) {
        int regNum = arg.getRegNum();
        vars[regNum] = newSSAVar(mth, versions, arg, regNum);
    }
    BlockNode enterBlock = mth.getEnterBlock();
    initPhiInEnterBlock(vars, enterBlock);
    renameVar(mth, vars, versions, enterBlock);
}
Also used : BlockNode(jadx.core.dex.nodes.BlockNode) RegisterArg(jadx.core.dex.instructions.args.RegisterArg) SSAVar(jadx.core.dex.instructions.args.SSAVar) JadxRuntimeException(jadx.core.utils.exceptions.JadxRuntimeException)

Example 13 with RegisterArg

use of jadx.core.dex.instructions.args.RegisterArg in project jadx by skylot.

the class SSATransform method removeBlockerInsns.

private static boolean removeBlockerInsns(MethodNode mth) {
    boolean removed = false;
    for (BlockNode block : mth.getBasicBlocks()) {
        PhiListAttr phiList = block.get(AType.PHI_LIST);
        if (phiList == null) {
            continue;
        }
        // check if args must be removed
        for (PhiInsn phi : phiList.getList()) {
            for (int i = 0; i < phi.getArgsCount(); i++) {
                RegisterArg arg = phi.getArg(i);
                InsnNode parentInsn = arg.getAssignInsn();
                if (parentInsn != null && parentInsn.contains(AFlag.REMOVE)) {
                    phi.removeArg(arg);
                    InstructionRemover.remove(mth, block, parentInsn);
                    removed = true;
                }
            }
        }
    }
    return removed;
}
Also used : BlockNode(jadx.core.dex.nodes.BlockNode) InsnNode(jadx.core.dex.nodes.InsnNode) RegisterArg(jadx.core.dex.instructions.args.RegisterArg) PhiInsn(jadx.core.dex.instructions.PhiInsn) PhiListAttr(jadx.core.dex.attributes.nodes.PhiListAttr)

Example 14 with RegisterArg

use of jadx.core.dex.instructions.args.RegisterArg in project jadx by skylot.

the class SSATransform method isSameArgs.

private static boolean isSameArgs(PhiInsn phi) {
    boolean allSame = true;
    SSAVar var = null;
    for (int i = 0; i < phi.getArgsCount(); i++) {
        RegisterArg arg = phi.getArg(i);
        if (var == null) {
            var = arg.getSVar();
        } else if (var != arg.getSVar()) {
            allSame = false;
            break;
        }
    }
    return allSame;
}
Also used : RegisterArg(jadx.core.dex.instructions.args.RegisterArg) SSAVar(jadx.core.dex.instructions.args.SSAVar)

Example 15 with RegisterArg

use of jadx.core.dex.instructions.args.RegisterArg in project jadx by skylot.

the class InsnNode method removeArg.

protected boolean removeArg(InsnArg arg) {
    int count = getArgsCount();
    for (int i = 0; i < count; i++) {
        if (arg == arguments.get(i)) {
            arguments.remove(i);
            if (arg instanceof RegisterArg) {
                RegisterArg reg = (RegisterArg) arg;
                reg.getSVar().removeUse(reg);
            }
            return true;
        }
    }
    return false;
}
Also used : RegisterArg(jadx.core.dex.instructions.args.RegisterArg)

Aggregations

RegisterArg (jadx.core.dex.instructions.args.RegisterArg)67 InsnNode (jadx.core.dex.nodes.InsnNode)39 InsnArg (jadx.core.dex.instructions.args.InsnArg)24 SSAVar (jadx.core.dex.instructions.args.SSAVar)22 BlockNode (jadx.core.dex.nodes.BlockNode)17 PhiInsn (jadx.core.dex.instructions.PhiInsn)11 IndexInsnNode (jadx.core.dex.instructions.IndexInsnNode)10 ArgType (jadx.core.dex.instructions.args.ArgType)8 ArrayList (java.util.ArrayList)8 PhiListAttr (jadx.core.dex.attributes.nodes.PhiListAttr)6 JadxRuntimeException (jadx.core.utils.exceptions.JadxRuntimeException)6 MethodNode (jadx.core.dex.nodes.MethodNode)4 MethodInfo (jadx.core.dex.info.MethodInfo)3 ConstClassNode (jadx.core.dex.instructions.ConstClassNode)3 LiteralArg (jadx.core.dex.instructions.args.LiteralArg)3 ConstructorInsn (jadx.core.dex.instructions.mods.ConstructorInsn)3 ClassNode (jadx.core.dex.nodes.ClassNode)3 FieldNode (jadx.core.dex.nodes.FieldNode)3 IContainer (jadx.core.dex.nodes.IContainer)3 ExceptionHandler (jadx.core.dex.trycatch.ExceptionHandler)3