当前位置: 首页>>代码示例>>Java>>正文


Java Rops类代码示例

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


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

示例1: removeEmptyGotos

import com.android.dx.rop.code.Rops; //导入依赖的package包/类
/**
 * Removes all blocks containing only GOTOs from the control flow.
 * Although much of this work will be done later when converting
 * from rop to dex, not all simplification cases can be handled
 * there. Furthermore, any no-op block between the exit block and
 * blocks containing the real return or throw statements must be
 * removed.
 */
private void removeEmptyGotos() {
    final ArrayList<SsaBasicBlock> blocks = ssaMeth.getBlocks();

    ssaMeth.forEachBlockDepthFirst(false, new SsaBasicBlock.Visitor() {
        public void visitBlock(SsaBasicBlock b, SsaBasicBlock parent) {
            ArrayList<SsaInsn> insns = b.getInsns();

            if ((insns.size() == 1)
                    && (insns.get(0).getOpcode() == Rops.GOTO)) {
                BitSet preds = (BitSet) b.getPredecessors().clone();

                for (int i = preds.nextSetBit(0); i >= 0;
                        i = preds.nextSetBit(i + 1)) {
                    SsaBasicBlock pb = blocks.get(i);
                    pb.replaceSuccessor(b.getIndex(),
                            b.getPrimarySuccessorIndex());
                }
            }
        }
    });
}
 
开发者ID:JLLK,项目名称:multidex-maker,代码行数:30,代码来源:SsaToRop.java

示例2: filterMoveReturnAddressInsns

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

示例3: replaceBranches

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

示例4: fixLocalAssignment

import com.android.dx.rop.code.Rops; //导入依赖的package包/类
/**
 * Inserts mark-locals if necessary when changing a register. If
 * the definition of {@code origReg} is associated with a local
 * variable, then insert a mark-local for {@code newReg} just below
 * it. We expect the definition of  {@code origReg} to ultimately
 * be removed by the dead code eliminator
 *
 * @param origReg {@code non-null;} original register
 * @param newReg {@code non-null;} new register that will replace
 * {@code origReg}
 */
private void fixLocalAssignment(RegisterSpec origReg,
        RegisterSpec newReg) {
    for (SsaInsn use : ssaMeth.getUseListForRegister(origReg.getReg())) {
        RegisterSpec localAssignment = use.getLocalAssignment();
        if (localAssignment == null) {
            continue;
        }

        if (use.getResult() == null) {
            /*
             * This is a mark-local. it will be updated when all uses
             * are updated.
             */
            continue;
        }

        LocalItem local = localAssignment.getLocalItem();

        // Un-associate original use.
        use.setResultLocal(null);

        // Now add a mark-local to the new reg immediately after.
        newReg = newReg.withLocalItem(local);

        SsaInsn newInsn
                = SsaInsn.makeFromRop(
                    new PlainInsn(Rops.opMarkLocal(newReg),
                    SourcePosition.NO_INFO, null,
                            RegisterSpecList.make(newReg)),
                use.getBlock());

        ArrayList<SsaInsn> insns = use.getBlock().getInsns();

        insns.add(insns.indexOf(use) + 1, newInsn);
    }
}
 
开发者ID:JLLK,项目名称:multidex-maker,代码行数:48,代码来源:ConstCollector.java

示例5: verifyValidExitPredecessor

import com.android.dx.rop.code.Rops; //导入依赖的package包/类
/**
 * Validates that a basic block is a valid end predecessor. It must
 * end in a RETURN or a THROW. Throws a runtime exception on error.
 *
 * @param b {@code non-null;} block to validate
 * @throws RuntimeException on error
 */
private void verifyValidExitPredecessor(SsaBasicBlock b) {
    ArrayList<SsaInsn> insns = b.getInsns();
    SsaInsn lastInsn = insns.get(insns.size() - 1);
    Rop opcode = lastInsn.getOpcode();

    if (opcode.getBranchingness() != Rop.BRANCH_RETURN
            && opcode != Rops.THROW) {
        throw new RuntimeException("Exit predecessor must end"
                + " in valid exit statement.");
    }
}
 
开发者ID:JLLK,项目名称:multidex-maker,代码行数:19,代码来源:SsaToRop.java

示例6: addMoveToBeginning

import com.android.dx.rop.code.Rops; //导入依赖的package包/类
/**
 * Adds a move instruction after the phi insn block.
 *
 * @param result move destination
 * @param source move source
 */
public void addMoveToBeginning (RegisterSpec result, RegisterSpec source) {
    if (result.getReg() == source.getReg()) {
        // Sometimes we end up with no-op moves. Ignore them here.
        return;
    }

    RegisterSpecList sources = RegisterSpecList.make(source);
    NormalSsaInsn toAdd = new NormalSsaInsn(
            new PlainInsn(Rops.opMove(result.getType()),
                    SourcePosition.NO_INFO, result, sources), this);

    insns.add(getCountPhiInsns(), toAdd);
    movesFromPhisAtBeginning++;
}
 
开发者ID:JLLK,项目名称:multidex-maker,代码行数:21,代码来源:SsaBasicBlock.java

示例7: deleteInsns

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

示例8: loadConstant

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

示例9: compareFloatingPoint

import com.android.dx.rop.code.Rops; //导入依赖的package包/类
/**
 * Compare floats or doubles. This stores -1 in {@code target} if {@code
 * a < b}, 0 in {@code target} if {@code a == b} and 1 in target if {@code
 * a > b}. This stores {@code nanValue} in {@code target} if either value
 * is {@code NaN}.
 */
public <T extends Number> void compareFloatingPoint(
        Local<Integer> target, Local<T> a, Local<T> b, int nanValue) {
    Rop rop;
    if (nanValue == 1) {
        rop = Rops.opCmpg(a.type.ropType);
    } else if (nanValue == -1) {
        rop = Rops.opCmpl(a.type.ropType);
    } else {
        throw new IllegalArgumentException("expected 1 or -1 but was " + nanValue);
    }
    addInstruction(new PlainInsn(rop, sourcePosition, target.spec(),
            RegisterSpecList.make(a.spec(), b.spec())));
}
 
开发者ID:linkedin,项目名称:dexmaker,代码行数:20,代码来源:Code.java

示例10: newInstance

import com.android.dx.rop.code.Rops; //导入依赖的package包/类
/**
 * Calls the constructor {@code constructor} using {@code args} and assigns
 * the new instance to {@code target}.
 */
public <T> void newInstance(Local<T> target, MethodId<T, Void> constructor, Local<?>... args) {
    if (target == null) {
        throw new IllegalArgumentException();
    }
    addInstruction(new ThrowingCstInsn(Rops.NEW_INSTANCE, sourcePosition,
            RegisterSpecList.EMPTY, catches, constructor.declaringType.constant));
    moveResult(target, true);
    invokeDirect(constructor, null, target, args);
}
 
开发者ID:linkedin,项目名称:dexmaker,代码行数:14,代码来源:Code.java

示例11: getCastRop

import com.android.dx.rop.code.Rops; //导入依赖的package包/类
private Rop getCastRop(com.android.dx.rop.type.Type sourceType,
        com.android.dx.rop.type.Type targetType) {
    if (sourceType.getBasicType() == BT_INT) {
        switch (targetType.getBasicType()) {
        case BT_SHORT:
            return Rops.TO_SHORT;
        case BT_CHAR:
            return Rops.TO_CHAR;
        case BT_BYTE:
            return Rops.TO_BYTE;
        }
    }
    return Rops.opConv(targetType, sourceType);
}
 
开发者ID:linkedin,项目名称:dexmaker,代码行数:15,代码来源:Code.java

示例12: returnVoid

import com.android.dx.rop.code.Rops; //导入依赖的package包/类
/**
 * Returns from a {@code void} method. After a return it is an error to
 * define further instructions after a return without first {@link #mark
 * marking} an existing unmarked label.
 */
public void returnVoid() {
    if (!method.returnType.equals(TypeId.VOID)) {
        throw new IllegalArgumentException("declared " + method.returnType
                + " but returned void");
    }
    addInstruction(new PlainInsn(Rops.RETURN_VOID, sourcePosition, null,
            RegisterSpecList.EMPTY));
}
 
开发者ID:linkedin,项目名称:dexmaker,代码行数:14,代码来源:Code.java

示例13: returnValue

import com.android.dx.rop.code.Rops; //导入依赖的package包/类
/**
 * Returns the value in {@code result} to the calling method. After a return
 * it is an error to define further instructions after a return without
 * first {@link #mark marking} an existing unmarked label.
 */
public void returnValue(Local<?> result) {
    if (!result.type.equals(method.returnType)) {
        // TODO: this is probably too strict.
        throw new IllegalArgumentException("declared " + method.returnType
                + " but returned " + result.type);
    }
    addInstruction(new PlainInsn(Rops.opReturn(result.type.ropType), sourcePosition,
            null, RegisterSpecList.make(result.spec())));
}
 
开发者ID:linkedin,项目名称:dexmaker,代码行数:15,代码来源:Code.java


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