• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Java Insn类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中com.android.dx.rop.code.Insn的典型用法代码示例。如果您正苦于以下问题:Java Insn类的具体用法?Java Insn怎么用?Java Insn使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



Insn类属于com.android.dx.rop.code包,在下文中一共展示了Insn类的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: setupArrays

import com.android.dx.rop.code.Insn; //导入依赖的package包/类
/**
 * Sets up the address arrays.
 */
private void setupArrays(RopMethod method) {
    BasicBlockList blocks = method.getBlocks();
    int sz = blocks.size();

    for (int i = 0; i < sz; i++) {
        BasicBlock one = blocks.get(i);
        int label = one.getLabel();
        Insn insn = one.getInsns().get(0);

        starts[label] = new CodeAddress(insn.getPosition());

        SourcePosition pos = one.getLastInsn().getPosition();

        lasts[label] = new CodeAddress(pos);
        ends[label] = new CodeAddress(pos);
    }
}
 
开发者ID:JLLK,项目名称:multidex-maker,代码行数:21,代码来源:BlockAddresses.java


示例2: getRegs

import com.android.dx.rop.code.Insn; //导入依赖的package包/类
/**
 * Gets the complete register list (result and sources) out of a
 * given rop instruction. For insns that are commutative, have
 * two register sources, and have a source equal to the result,
 * place that source first.
 *
 * @param insn {@code non-null;} instruction in question
 * @param resultReg {@code null-ok;} the real result to use (ignore the insn's)
 * @return {@code non-null;} the instruction's complete register list
 */
private static RegisterSpecList getRegs(Insn insn,
        RegisterSpec resultReg) {
    RegisterSpecList regs = insn.getSources();

    if (insn.getOpcode().isCommutative()
            && (regs.size() == 2)
            && (resultReg.getReg() == regs.get(1).getReg())) {

        /*
         * For commutative ops which have two register sources,
         * if the second source is the same register as the result,
         * swap the sources so that an opcode of form 12x can be selected
         * instead of one of form 23x
         */

        regs = RegisterSpecList.make(regs.get(1), regs.get(0));
    }

    if (resultReg == null) {
        return regs;
    }

    return regs.withFirst(resultReg);
}
 
开发者ID:JLLK,项目名称:multidex-maker,代码行数:35,代码来源:RopTranslator.java


示例3: getNextMoveResultPseudo

import com.android.dx.rop.code.Insn; //导入依赖的package包/类
/**
 * Looks forward to the current block's primary successor, returning
 * the RegisterSpec of the result of the move-result-pseudo at the
 * top of that block or null if none.
 *
 * @return {@code null-ok;} result of move-result-pseudo at the beginning of
 * primary successor
 */
private RegisterSpec getNextMoveResultPseudo()
{
    int label = block.getPrimarySuccessor();

    if (label < 0) {
        return null;
    }

    Insn insn
            = method.getBlocks().labelToBlock(label).getInsns().get(0);

    if (insn.getOpcode().getOpcode() != RegOps.MOVE_RESULT_PSEUDO) {
        return null;
    } else {
        return insn.getResult();
    }
}
 
开发者ID:JLLK,项目名称:multidex-maker,代码行数:26,代码来源:RopTranslator.java


示例4: isRegALocal

import com.android.dx.rop.code.Insn; //导入依赖的package包/类
/**
 * Checks to see if the given SSA reg is ever associated with a local
 * local variable. Each SSA reg may be associated with at most one
 * local var.
 *
 * @param spec {@code non-null;} ssa reg
 * @return true if reg is ever associated with a local
 */
public boolean isRegALocal(RegisterSpec spec) {
    SsaInsn defn = getDefinitionForRegister(spec.getReg());

    if (defn == null) {
        // version 0 registers are never used as locals
        return false;
    }

    // Does the definition have a local associated with it?
    if (defn.getLocalAssignment() != null) return true;

    // If not, is there a mark-local insn?
    for (SsaInsn use : getUseListForRegister(spec.getReg())) {
        Insn insn = use.getOriginalRopInsn();

        if (insn != null
                && insn.getOpcode().getOpcode() == RegOps.MARK_LOCAL) {
            return true;
        }
    }

    return false;
}
 
开发者ID:JLLK,项目名称:multidex-maker,代码行数:32,代码来源:SsaMethod.java


示例5: calculateParamsAreInOrder

import com.android.dx.rop.code.Insn; //导入依赖的package包/类
/**
 * Checks to see if the move-param instructions that occur in this
 * method happen to slot the params in an order at the top of the
 * stack frame that matches dalvik's calling conventions. This will
 * alway result in "true" for methods that have run through the
 * SSA optimizer.
 *
 * @param paramSize size, in register units, of all the parameters
 * to this method
 */
private static boolean calculateParamsAreInOrder(RopMethod method,
        final int paramSize) {
    final boolean[] paramsAreInOrder = { true };
    final int initialRegCount = method.getBlocks().getRegCount();

    /*
     * We almost could just check the first block here, but the
     * {@code cf} layer will put in a second move-param in a
     * subsequent block in the case of synchronized methods.
     */
    method.getBlocks().forEachInsn(new Insn.BaseVisitor() {
        @Override
        public void visitPlainCstInsn(PlainCstInsn insn) {
            if (insn.getOpcode().getOpcode()== RegOps.MOVE_PARAM) {
                int param =
                    ((CstInteger) insn.getConstant()).getValue();

                paramsAreInOrder[0] = paramsAreInOrder[0]
                        && ((initialRegCount - paramSize + param)
                            == insn.getResult().getReg());
            }
        }
    });

    return paramsAreInOrder[0];
}
 
开发者ID:JLLK,项目名称:multidex-maker,代码行数:37,代码来源:RopTranslator.java


示例6: addIntroductionIfNecessary

import com.android.dx.rop.code.Insn; //导入依赖的package包/类
/**
 * Adds a {@link LocalStart} to the output if the given
 * instruction in fact introduces a local variable.
 *
 * @param insn {@code non-null;} instruction in question
 */
public void addIntroductionIfNecessary(Insn insn) {
    RegisterSpec spec = locals.getAssignment(insn);

    if (spec != null) {
        addOutput(new LocalStart(insn.getPosition(), spec));
    }
}
 
开发者ID:JLLK,项目名称:multidex-maker,代码行数:14,代码来源:RopTranslator.java


示例7: filterMoveReturnAddressInsns

import com.android.dx.rop.code.Insn; //导入依赖的package包/类
/**
 * Removes all {@code move-return-address} instructions, returning a new
 * {@code InsnList} if necessary. The {@code move-return-address}
 * insns are dead code after subroutines have been inlined.
 *
 * @param insns {@code InsnList} that may contain
 * {@code move-return-address} insns
 * @return {@code InsnList} with {@code move-return-address} removed
 */
private InsnList filterMoveReturnAddressInsns(InsnList insns) {
    int sz;
    int newSz = 0;

    // First see if we need to filter, and if so what the new size will be
    sz = insns.size();
    for (int i = 0; i < sz; i++) {
        if (insns.get(i).getOpcode() != Rops.MOVE_RETURN_ADDRESS) {
            newSz++;
        }
    }

    if (newSz == sz) {
        return insns;
    }

    // Make a new list without the MOVE_RETURN_ADDRESS insns
    InsnList newInsns = new InsnList(newSz);

    int newIndex = 0;
    for (int i = 0; i < sz; i++) {
        Insn insn = insns.get(i);
        if (insn.getOpcode() != Rops.MOVE_RETURN_ADDRESS) {
            newInsns.set(newIndex++, insn);
        }
    }

    newInsns.setImmutable();
    return newInsns;
}
 
开发者ID:JLLK,项目名称:multidex-maker,代码行数:40,代码来源:Ropper.java


示例8: RopperMachine

import com.android.dx.rop.code.Insn; //导入依赖的package包/类
/**
 * Constructs an instance.
 *
 * @param ropper {@code non-null;} ropper controlling this instance
 * @param method {@code non-null;} method being converted
 * @param advice {@code non-null;} translation advice to use
 * @param methods {@code non-null;} list of methods defined by the class
 *     that defines {@code method}.
 */
public RopperMachine(Ropper ropper, ConcreteMethod method,
        TranslationAdvice advice, MethodList methods) {
    super(method.getEffectiveDescriptor());

    if (methods == null) {
        throw new NullPointerException("methods == null");
    }

    if (ropper == null) {
        throw new NullPointerException("ropper == null");
    }

    if (advice == null) {
        throw new NullPointerException("advice == null");
    }

    this.ropper = ropper;
    this.method = method;
    this.methods = methods;
    this.advice = advice;
    this.maxLocals = method.getMaxLocals();
    this.insns = new ArrayList<Insn>(25);
    this.catches = null;
    this.catchesUsed = false;
    this.returns = false;
    this.primarySuccessorIndex = -1;
    this.extraBlockCount = 0;
    this.blockCanThrow = false;
    this.returnOp = null;
    this.returnPosition = null;
}
 
开发者ID:JLLK,项目名称:multidex-maker,代码行数:41,代码来源:RopperMachine.java


示例9: replaceBranches

import com.android.dx.rop.code.Insn; //导入依赖的package包/类
/**
 * Replaces branches that have constant conditions with gotos
 */
private void replaceBranches() {
    for (SsaInsn insn : branchWorklist) {
        // Find if a successor block is never executed
        int oldSuccessor = -1;
        SsaBasicBlock block = insn.getBlock();
        int successorSize = block.getSuccessorList().size();
        for (int i = 0; i < successorSize; i++) {
            int successorBlock = block.getSuccessorList().get(i);
            if (!executableBlocks.get(successorBlock)) {
                oldSuccessor = successorBlock;
            }
        }

        /*
         * Prune branches that have already been handled and ones that no
         * longer have constant conditions (no nonexecutable successors)
         */
        if (successorSize != 2 || oldSuccessor == -1) continue;

        // Replace branch with goto
        Insn originalRopInsn = insn.getOriginalRopInsn();
        block.replaceLastInsn(new PlainInsn(Rops.GOTO,
            originalRopInsn.getPosition(), null, RegisterSpecList.EMPTY));
        block.removeSuccessor(oldSuccessor);
    }
}
 
开发者ID:JLLK,项目名称:multidex-maker,代码行数:30,代码来源:SCCP.java


示例10: tryReplacingWithConstant

import com.android.dx.rop.code.Insn; //导入依赖的package包/类
/**
 * Tries to replace an instruction with a const instruction. The given
 * instruction must have a constant result for it to be replaced.
 *
 * @param insn {@code non-null;} instruction to try to replace
 * @return true if the instruction was replaced
 */
private boolean tryReplacingWithConstant(NormalSsaInsn insn) {
    Insn originalRopInsn = insn.getOriginalRopInsn();
    Rop opcode = originalRopInsn.getOpcode();
    RegisterSpec result = insn.getResult();

    if (result != null && !ssaMeth.isRegALocal(result) &&
            opcode.getOpcode() != RegOps.CONST) {
        TypeBearer type = insn.getResult().getTypeBearer();
        if (type.isConstant() && type.getBasicType() == Type.BT_INT) {
            // Replace the instruction with a constant
            replacePlainInsn(insn, RegisterSpecList.EMPTY,
                    RegOps.CONST, (Constant) type);

            // Remove the source as well if this is a move-result-pseudo
            if (opcode.getOpcode() == RegOps.MOVE_RESULT_PSEUDO) {
                int pred = insn.getBlock().getPredecessors().nextSetBit(0);
                ArrayList<SsaInsn> predInsns =
                        ssaMeth.getBlocks().get(pred).getInsns();
                NormalSsaInsn sourceInsn =
                        (NormalSsaInsn) predInsns.get(predInsns.size()-1);
                replacePlainInsn(sourceInsn, RegisterSpecList.EMPTY,
                        RegOps.GOTO, null);
            }
            return true;
        }
    }
    return false;
}
 
开发者ID:JLLK,项目名称:multidex-maker,代码行数:36,代码来源:LiteralOpUpgrader.java


示例11: replaceLastInsn

import com.android.dx.rop.code.Insn; //导入依赖的package包/类
/**
 * Replaces the last insn in this block. The provided insn must have
 * some branchingness.
 *
 * @param insn {@code non-null;} rop-form insn to add, which must branch.
 */
public void replaceLastInsn(Insn insn) {
    if (insn.getOpcode().getBranchingness() == Rop.BRANCH_NONE) {
        throw new IllegalArgumentException("last insn must branch");
    }

    SsaInsn oldInsn = insns.get(insns.size() - 1);
    SsaInsn newInsn = SsaInsn.makeFromRop(insn, this);

    insns.set(insns.size() - 1, newInsn);

    parent.onInsnRemoved(oldInsn);
    parent.onInsnAdded(newInsn);
}
 
开发者ID:JLLK,项目名称:multidex-maker,代码行数:20,代码来源:SsaBasicBlock.java


示例12: deleteInsns

import com.android.dx.rop.code.Insn; //导入依赖的package包/类
/**
 * Deletes all insns in the set from this method.
 *
 * @param deletedInsns {@code non-null;} insns to delete
 */
public void deleteInsns(Set<SsaInsn> deletedInsns) {
    for (SsaBasicBlock block : getBlocks()) {
        ArrayList<SsaInsn> insns = block.getInsns();

        for (int i = insns.size() - 1; i >= 0; i--) {
            SsaInsn insn = insns.get(i);

            if (deletedInsns.contains(insn)) {
                onInsnRemoved(insn);
                insns.remove(i);
            }
        }

        // Check to see if we need to add a GOTO

        int insnsSz = insns.size();
        SsaInsn lastInsn = (insnsSz == 0) ? null : insns.get(insnsSz - 1);

        if (block != getExitBlock() && (insnsSz == 0
                || lastInsn.getOriginalRopInsn() == null
                || lastInsn.getOriginalRopInsn().getOpcode()
                    .getBranchingness() == Rop.BRANCH_NONE)) {
            // We managed to eat a throwable insn

            Insn gotoInsn = new PlainInsn(Rops.GOTO,
                    SourcePosition.NO_INFO, null, RegisterSpecList.EMPTY);
            insns.add(SsaInsn.makeFromRop(gotoInsn, block));

            // Remove secondary successors from this block
            BitSet succs = block.getSuccessors();
            for (int i = succs.nextSetBit(0); i >= 0;
                     i = succs.nextSetBit(i + 1)) {
                if (i != block.getPrimarySuccessorIndex()) {
                    block.removeSuccessor(i);
                }
            }
        }
    }
}
 
开发者ID:JLLK,项目名称:multidex-maker,代码行数:45,代码来源:SsaMethod.java


示例13: RopperMachine

import com.android.dx.rop.code.Insn; //导入依赖的package包/类
/**
 * Constructs an instance.
 *
 * @param ropper {@code non-null;} ropper controlling this instance
 * @param method {@code non-null;} method being converted
 * @param advice {@code non-null;} translation advice to use
 */
public RopperMachine(Ropper ropper, ConcreteMethod method,
        TranslationAdvice advice) {
    super(method.getEffectiveDescriptor());

    if (ropper == null) {
        throw new NullPointerException("ropper == null");
    }

    if (advice == null) {
        throw new NullPointerException("advice == null");
    }

    this.ropper = ropper;
    this.method = method;
    this.advice = advice;
    this.maxLocals = method.getMaxLocals();
    this.insns = new ArrayList<Insn>(25);
    this.catches = null;
    this.catchesUsed = false;
    this.returns = false;
    this.primarySuccessorIndex = -1;
    this.extraBlockCount = 0;
    this.blockCanThrow = false;
    this.returnOp = null;
    this.returnPosition = null;
}
 
开发者ID:AndreJCL,项目名称:JCL,代码行数:34,代码来源:RopperMachine.java



注:本文中的com.android.dx.rop.code.Insn类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java HttpClient类代码示例发布时间:2022-05-22
下一篇:
Java CreationReference类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap