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


Java RegisterSpec.getReg方法代码示例

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


在下文中一共展示了RegisterSpec.getReg方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getRegs

import com.android.dx.rop.code.RegisterSpec; //导入方法依赖的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:johnlee175,项目名称:dex,代码行数:35,代码来源:RopTranslator.java

示例2: addMapping

import com.android.dx.rop.code.RegisterSpec; //导入方法依赖的package包/类
/**
 * Adds a mapping from an SSA register to a rop register.
 * {@link #canMapReg} should have already been called.
 *
 * @param ssaSpec {@code non-null;} SSA register to map from
 * @param ropReg {@code >=0;} rop register to map to
 */
private void addMapping(RegisterSpec ssaSpec, int ropReg) {
    int ssaReg = ssaSpec.getReg();

    // An assertion.
    if (ssaRegsMapped.get(ssaReg) || !canMapReg(ssaSpec, ropReg)) {
        throw new RuntimeException(
                "attempt to add invalid register mapping");
    }

    if (DEBUG) {
        System.out.printf("Add mapping s%d -> v%d c:%d\n",
                ssaSpec.getReg(), ropReg, ssaSpec.getCategory());
    }

    int category = ssaSpec.getCategory();
    mapper.addMapping(ssaSpec.getReg(), ropReg, category);
    ssaRegsMapped.set(ssaReg);
    usedRopRegs.set(ropReg, ropReg + category);
}
 
开发者ID:johnlee175,项目名称:dex,代码行数:27,代码来源:FirstFitLocalCombiningAllocator.java

示例3: processResultReg

import com.android.dx.rop.code.RegisterSpec; //导入方法依赖的package包/类
/**
 * Renames the result register of this insn and updates the
 * current register mapping. Does nothing if this insn has no result.
 * Applied to all non-move insns.
 *
 * @param insn insn to process.
 */
void processResultReg(SsaInsn insn) {
    RegisterSpec ropResult = insn.getResult();

    if (ropResult == null) {
        return;
    }

    int ropReg = ropResult.getReg();
    if (isBelowThresholdRegister(ropReg)) {
        return;
    }

    insn.changeResultReg(nextSsaReg);
    addMapping(ropReg, insn.getResult());

    if (DEBUG) {
        ssaRegToRopReg.add(ropReg);
    }

    nextSsaReg++;
}
 
开发者ID:JLLK,项目名称:multidex-maker,代码行数:29,代码来源:SsaRenamer.java

示例4: map

import com.android.dx.rop.code.RegisterSpec; //导入方法依赖的package包/类
/** {@inheritDoc} */
@Override
public RegisterSpec map(RegisterSpec registerSpec) {
    if (registerSpec == null) return null;

    int reg = registerSpec.getReg();

    // For debugging: assert that the mapped types are compatible.
    if (DEBUG) {
        RegisterSpec newVersion = currentMapping[reg];
        if (newVersion.getBasicType() != Type.BT_VOID
                && registerSpec.getBasicFrameType()
                    != newVersion.getBasicFrameType()) {

            throw new RuntimeException(
                    "mapping registers of incompatible types! "
                    + registerSpec
                    + " " + currentMapping[reg]);
        }
    }

    return registerSpec.withReg(currentMapping[reg].getReg());
}
 
开发者ID:JLLK,项目名称:multidex-maker,代码行数:24,代码来源:SsaRenamer.java

示例5: processInsn

import com.android.dx.rop.code.RegisterSpec; //导入方法依赖的package包/类
/**
 * Process a single instruction, looking for new objects resulting from
 * move result or move param.
 *
 * @param insn {@code non-null;} instruction to process
 */
private void processInsn(SsaInsn insn) {
    int op = insn.getOpcode().getOpcode();
    RegisterSpec result = insn.getResult();
    EscapeSet escSet;

    // Identify new objects
    if (op == RegOps.MOVE_RESULT_PSEUDO &&
            result.getTypeBearer().getBasicType() == Type.BT_OBJECT) {
        // Handle objects generated through move_result_pseudo
        escSet = processMoveResultPseudoInsn(insn);
        processRegister(result, escSet);
    } else if (op == RegOps.MOVE_PARAM &&
                  result.getTypeBearer().getBasicType() == Type.BT_OBJECT) {
        // Track method arguments that are objects
        escSet = new EscapeSet(result.getReg(), regCount, EscapeState.NONE);
        latticeValues.add(escSet);
        processRegister(result, escSet);
    } else if (op == RegOps.MOVE_RESULT &&
            result.getTypeBearer().getBasicType() == Type.BT_OBJECT) {
        // Track method return values that are objects
        escSet = new EscapeSet(result.getReg(), regCount, EscapeState.NONE);
        latticeValues.add(escSet);
        processRegister(result, escSet);
    }
}
 
开发者ID:JLLK,项目名称:multidex-maker,代码行数:32,代码来源:EscapeAnalysis.java

示例6: add

import com.android.dx.rop.code.RegisterSpec; //导入方法依赖的package包/类
/**
 * Adds an entry to the result, updating the adjunct tables
 * accordingly.
 *
 * @param address {@code >= 0;} the address
 * @param disposition {@code non-null;} the disposition
 * @param spec {@code non-null;} spec representing the local
 */
private void add(int address, Disposition disposition,
        RegisterSpec spec) {
    int regNum = spec.getReg();

    result.add(new Entry(address, disposition, spec));

    if (disposition == Disposition.START) {
        regs.put(spec);
        endIndices[regNum] = -1;
    } else {
        regs.remove(spec);
        endIndices[regNum] = result.size() - 1;
    }
}
 
开发者ID:AndreJCL,项目名称:JCL,代码行数:23,代码来源:LocalList.java

示例7: isCompatible

import com.android.dx.rop.code.RegisterSpec; //导入方法依赖的package包/类
/** {@inheritDoc} */
@Override
public boolean isCompatible(DalvInsn insn) {
    if (!(insn instanceof SimpleInsn)) {
        return false;
    }

    RegisterSpecList regs = insn.getRegisters();
    RegisterSpec rs1;
    RegisterSpec rs2;

    switch (regs.size()) {
        case 2: {
            rs1 = regs.get(0);
            rs2 = regs.get(1);
            break;
        }
        case 3: {
            /*
             * This format is allowed for ops that are effectively
             * 3-arg but where the first two args are identical.
             */
            rs1 = regs.get(1);
            rs2 = regs.get(2);
            if (rs1.getReg() != regs.get(0).getReg()) {
                return false;
            }
            break;
        }
        default: {
            return false;
        }
    }

    return unsignedFitsInNibble(rs1.getReg()) &&
        unsignedFitsInNibble(rs2.getReg());
}
 
开发者ID:JLLK,项目名称:multidex-maker,代码行数:38,代码来源:Form12x.java

示例8: if

import com.android.dx.rop.code.RegisterSpec; //导入方法依赖的package包/类
/**
 * Removes an instruction from use and def lists. For use during
 * instruction removal.
 *
 * @param insn {@code non-null;} insn to remove
 */
/*package*/ void onInsnRemoved(SsaInsn insn) {
    if (useList != null) {
        removeFromUseList(insn, insn.getSources());
    }

    RegisterSpec resultReg = insn.getResult();
    if (definitionList != null && resultReg != null) {
        definitionList[resultReg.getReg()] = null;
    }
}
 
开发者ID:johnlee175,项目名称:dex,代码行数:17,代码来源:SsaMethod.java

示例9: handleLocalAssociatedParams

import com.android.dx.rop.code.RegisterSpec; //导入方法依赖的package包/类
/**
 * Maps all local-associated parameters to rop registers.
 */
private void handleLocalAssociatedParams() {
    for (ArrayList<RegisterSpec> ssaRegs : localVariables.values()) {
        int sz = ssaRegs.size();
        int paramIndex = -1;
        int paramCategory = 0;

        // First, find out if this local variable is a parameter.
        for (int i = 0; i < sz; i++) {
            RegisterSpec ssaSpec = ssaRegs.get(i);
            int ssaReg = ssaSpec.getReg();

            paramIndex = getParameterIndexForReg(ssaReg);

            if (paramIndex >= 0) {
                paramCategory = ssaSpec.getCategory();
                addMapping(ssaSpec, paramIndex);
                break;
            }
        }

        if (paramIndex < 0) {
            // This local wasn't a parameter.
            continue;
        }

        // Any remaining local-associated registers will be mapped later.
        tryMapRegs(ssaRegs, paramIndex, paramCategory, true);
    }
}
 
开发者ID:johnlee175,项目名称:dex,代码行数:33,代码来源:FirstFitLocalCombiningAllocator.java

示例10: removePhiRegister

import com.android.dx.rop.code.RegisterSpec; //导入方法依赖的package包/类
/**
 * Removes all operand uses of a register from this phi instruction.
 *
 * @param registerSpec register spec, including type and reg of operand
 */
public void removePhiRegister(RegisterSpec registerSpec) {
    ArrayList<Operand> operandsToRemove = new ArrayList<Operand>();
    for (Operand o : operands) {
        if (o.regSpec.getReg() == registerSpec.getReg()) {
            operandsToRemove.add(o);
        }
    }

    operands.removeAll(operandsToRemove);

    // Un-cache sources, in case someone has already called getSources().
    sources = null;
}
 
开发者ID:johnlee175,项目名称:dex,代码行数:19,代码来源:PhiInsn.java

示例11: addMoveToBeginning

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

示例12: isCompatible

import com.android.dx.rop.code.RegisterSpec; //导入方法依赖的package包/类
/** {@inheritDoc} */
@Override
public boolean isCompatible(DalvInsn insn) {
    if (!(insn instanceof CstInsn)) {
        return false;
    }

    RegisterSpecList regs = insn.getRegisters();
    RegisterSpec reg;

    switch (regs.size()) {
        case 1: {
            reg = regs.get(0);
            break;
        }
        case 2: {
            /*
             * This format is allowed for ops that are effectively
             * 2-arg but where the two args are identical.
             */
            reg = regs.get(0);
            if (reg.getReg() != regs.get(1).getReg()) {
                return false;
            }
            break;
        }
        default: {
            return false;
        }
    }

    if (!unsignedFitsInByte(reg.getReg())) {
        return false;
    }

    CstInsn ci = (CstInsn) insn;
    int cpi = ci.getIndex();
    Constant cst = ci.getConstant();

    if (! unsignedFitsInShort(cpi)) {
        return false;
    }

    return (cst instanceof CstType) ||
        (cst instanceof CstFieldRef) ||
        (cst instanceof CstString);
}
 
开发者ID:JLLK,项目名称:multidex-maker,代码行数:48,代码来源:Form21c.java

示例13: checkForEmptyRange

import com.android.dx.rop.code.RegisterSpec; //导入方法依赖的package包/类
/**
 * Helper for {@link #endLocal}, which handles the cases where
 * and end local is issued at the same address as a start local
 * for the same register. If this case is found, then this
 * method will remove the start (as the local was never actually
 * active), update the {@link #endIndices} to be accurate, and
 * if needed update the newly-active end to reflect an altered
 * disposition.
 *
 * @param address {@code >= 0;} the address
 * @param endedLocal {@code non-null;} spec representing the
 * local being ended
 * @return {@code true} iff this method found the case in question
 * and adjusted things accordingly
 */
private boolean checkForEmptyRange(int address,
        RegisterSpec endedLocal) {
    int at = result.size() - 1;
    Entry entry;

    // Look for a previous entry at the same address.
    for (/*at*/; at >= 0; at--) {
        entry = result.get(at);

        if (entry == null) {
            continue;
        }

        if (entry.getAddress() != address) {
            // We didn't find any match at the same address.
            return false;
        }

        if (entry.matches(endedLocal)) {
            break;
        }
    }

    /*
     * In fact, we found that the endedLocal had started at the
     * same address, so do all the requisite cleanup.
     */

    regs.remove(endedLocal);
    result.set(at, null);
    nullResultCount++;

    int regNum = endedLocal.getReg();
    boolean found = false;
    entry = null;

    // Now look back further to update where the register ended.
    for (at--; at >= 0; at--) {
        entry = result.get(at);

        if (entry == null) {
            continue;
        }

        if (entry.getRegisterSpec().getReg() == regNum) {
            found = true;
            break;
        }
    }

    if (found) {
        // We found an end for the same register.
        endIndices[regNum] = at;

        if (entry.getAddress() == address) {
            /*
             * It's still the same address, so update the
             * disposition.
             */
            result.set(at,
                    entry.withDisposition(Disposition.END_SIMPLY));
        }
    }

    return true;
}
 
开发者ID:AndreJCL,项目名称:JCL,代码行数:82,代码来源:LocalList.java

示例14: isCompatible

import com.android.dx.rop.code.RegisterSpec; //导入方法依赖的package包/类
/** {@inheritDoc} */
@Override
public boolean isCompatible(DalvInsn insn) {
    if (!(insn instanceof CstInsn)) {
        return false;
    }

    RegisterSpecList regs = insn.getRegisters();
    RegisterSpec reg;

    switch (regs.size()) {
        case 1: {
            reg = regs.get(0);
            break;
        }
        case 2: {
            /*
             * This format is allowed for ops that are effectively
             * 2-arg but where the two args are identical.
             */
            reg = regs.get(0);
            if (reg.getReg() != regs.get(1).getReg()) {
                return false;
            }
            break;
        }
        default: {
            return false;
        }
    }

    if (!unsignedFitsInByte(reg.getReg())) {
        return false;
    }

    CstInsn ci = (CstInsn) insn;
    Constant cst = ci.getConstant();

    return (cst instanceof CstType) ||
        (cst instanceof CstFieldRef) ||
        (cst instanceof CstString);
}
 
开发者ID:johnlee175,项目名称:dex,代码行数:43,代码来源:Form31c.java

示例15: processMoveResultPseudoInsn

import com.android.dx.rop.code.RegisterSpec; //导入方法依赖的package包/类
/**
 * Determine the origin of a move result pseudo instruction that generates
 * an object. Creates a new EscapeSet for the new object accordingly.
 *
 * @param insn {@code non-null;} move result pseudo instruction to process
 * @return {@code non-null;} an EscapeSet for the object referred to by the
 * move result pseudo instruction
 */
private EscapeSet processMoveResultPseudoInsn(SsaInsn insn) {
    RegisterSpec result = insn.getResult();
    SsaInsn prevSsaInsn = getInsnForMove(insn);
    int prevOpcode = prevSsaInsn.getOpcode().getOpcode();
    EscapeSet escSet;
    RegisterSpec prevSource;

    switch(prevOpcode) {
       // New instance / Constant
        case RegOps.NEW_INSTANCE:
        case RegOps.CONST:
            escSet = new EscapeSet(result.getReg(), regCount,
                                       EscapeState.NONE);
            break;
        // New array
        case RegOps.NEW_ARRAY:
        case RegOps.FILLED_NEW_ARRAY:
            prevSource = prevSsaInsn.getSources().get(0);
            if (prevSource.getTypeBearer().isConstant()) {
                // New fixed array
                escSet = new EscapeSet(result.getReg(), regCount,
                                           EscapeState.NONE);
                escSet.replaceableArray = true;
            } else {
                // New variable array
                escSet = new EscapeSet(result.getReg(), regCount,
                                           EscapeState.GLOBAL);
            }
            break;
        // Loading a static object
        case RegOps.GET_STATIC:
            escSet = new EscapeSet(result.getReg(), regCount,
                                       EscapeState.GLOBAL);
            break;
        // Type cast / load an object from a field or array
        case RegOps.CHECK_CAST:
        case RegOps.GET_FIELD:
        case RegOps.AGET:
            prevSource = prevSsaInsn.getSources().get(0);
            int setIndex = findSetIndex(prevSource);

            // Set should already exist, try to find it
            if (setIndex != latticeValues.size()) {
                escSet = latticeValues.get(setIndex);
                escSet.regSet.set(result.getReg());
                return escSet;
            }

            // Set not found, must be either null or unknown
            if (prevSource.getType() == Type.KNOWN_NULL) {
                escSet = new EscapeSet(result.getReg(), regCount,
                                           EscapeState.NONE);
           } else {
                escSet = new EscapeSet(result.getReg(), regCount,
                                           EscapeState.GLOBAL);
            }
            break;
        default:
            return null;
    }

    // Add the newly created escSet to the lattice and return it
    latticeValues.add(escSet);
    return escSet;
}
 
开发者ID:JLLK,项目名称:multidex-maker,代码行数:74,代码来源:EscapeAnalysis.java


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