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

Java PlainCstInsn类代码示例

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

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



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

示例1: calculateParamsAreInOrder

import com.android.dx.rop.code.PlainCstInsn; //导入依赖的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


示例2: visitPlainCstInsn

import com.android.dx.rop.code.PlainCstInsn; //导入依赖的package包/类
/** {@inheritDoc} */
public void visitPlainCstInsn(PlainCstInsn insn) {
    SourcePosition pos = insn.getPosition();
    Dop opcode = RopToDop.dopFor(insn);
    Rop rop = insn.getOpcode();
    int ropOpcode = rop.getOpcode();
    DalvInsn di;

    if (rop.getBranchingness() != Rop.BRANCH_NONE) {
        throw new RuntimeException("shouldn't happen");
    }

    if (ropOpcode == RegOps.MOVE_PARAM) {
        if (!paramsAreInOrder) {
            /*
             * Parameters are not in order at the top of the reg space.
             * We need to add moves.
             */

            RegisterSpec dest = insn.getResult();
            int param =
                ((CstInteger) insn.getConstant()).getValue();
            RegisterSpec source =
                RegisterSpec.make(regCount - paramSize + param,
                        dest.getType());
            di = new SimpleInsn(opcode, pos,
                                RegisterSpecList.make(dest, source));
            addOutput(di);
        }
    } else {
        // No moves required for the parameters
        RegisterSpecList regs = getRegs(insn);
        di = new CstInsn(opcode, pos, regs, insn.getConstant());
        addOutput(di);
    }
}
 
开发者ID:JLLK,项目名称:multidex-maker,代码行数:37,代码来源:RopTranslator.java


示例3: loadConstant

import com.android.dx.rop.code.PlainCstInsn; //导入依赖的package包/类
/**
 * Copies the constant value {@code value} to {@code target}. The constant
 * must be a primitive, String, Class, TypeId, or null.
 */
public <T> void loadConstant(Local<T> target, T value) {
    Rop rop = value == null
            ? Rops.CONST_OBJECT_NOTHROW
            : Rops.opConst(target.type.ropType);
    if (rop.getBranchingness() == BRANCH_NONE) {
        addInstruction(new PlainCstInsn(rop, sourcePosition, target.spec(),
                RegisterSpecList.EMPTY, Constants.getConstant(value)));
    } else {
        addInstruction(new ThrowingCstInsn(rop, sourcePosition,
                RegisterSpecList.EMPTY, catches, Constants.getConstant(value)));
        moveResult(target, true);
    }
}
 
开发者ID:linkedin,项目名称:dexmaker,代码行数:18,代码来源:Code.java


示例4: run

import com.android.dx.rop.code.PlainCstInsn; //导入依赖的package包/类
/**
 * Applies the optimization.
 */
private void run() {
    int regSz = ssaMeth.getRegCount();

    ArrayList<TypedConstant> constantList
            = getConstsSortedByCountUse();

    int toCollect = Math.min(constantList.size(), MAX_COLLECTED_CONSTANTS);

    SsaBasicBlock start = ssaMeth.getEntryBlock();

    // Constant to new register containing the constant
    HashMap<TypedConstant, RegisterSpec> newRegs
            = new HashMap<TypedConstant, RegisterSpec> (toCollect);

    for (int i = 0; i < toCollect; i++) {
        TypedConstant cst = constantList.get(i);
        RegisterSpec result
                = RegisterSpec.make(ssaMeth.makeNewSsaReg(), cst);

        Rop constRop = Rops.opConst(cst);

        if (constRop.getBranchingness() == Rop.BRANCH_NONE) {
            start.addInsnToHead(
                    new PlainCstInsn(Rops.opConst(cst),
                            SourcePosition.NO_INFO, result,
                            RegisterSpecList.EMPTY, cst));
        } else {
            // We need two new basic blocks along with the new insn
            SsaBasicBlock entryBlock = ssaMeth.getEntryBlock();
            SsaBasicBlock successorBlock
                    = entryBlock.getPrimarySuccessor();

            // Insert a block containing the const insn.
            SsaBasicBlock constBlock
                    = entryBlock.insertNewSuccessor(successorBlock);

            constBlock.replaceLastInsn(
                    new ThrowingCstInsn(constRop, SourcePosition.NO_INFO,
                            RegisterSpecList.EMPTY,
                            StdTypeList.EMPTY, cst));

            // Insert a block containing the move-result-pseudo insn.

            SsaBasicBlock resultBlock
                    = constBlock.insertNewSuccessor(successorBlock);
            PlainInsn insn
                = new PlainInsn(
                        Rops.opMoveResultPseudo(result.getTypeBearer()),
                        SourcePosition.NO_INFO,
                        result, RegisterSpecList.EMPTY);

            resultBlock.addInsnToHead(insn);
        }

        newRegs.put(cst, result);
    }

    updateConstUses(newRegs, regSz);
}
 
开发者ID:JLLK,项目名称:multidex-maker,代码行数:63,代码来源:ConstCollector.java



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
Java SiteService类代码示例发布时间:2022-05-22
下一篇:
Java Keep类代码示例发布时间: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