Search in sources :

Example 1 with LocalItem

use of com.android.dx.rop.code.LocalItem in project buck by facebook.

the class OutputFinisher method addConstants.

/**
     * Helper for {@link #getAllConstants} which adds all the info for
     * a single {@code RegisterSpec}.
     *
     * @param result {@code non-null;} result set to add to
     * @param spec {@code null-ok;} register spec to add
     */
private static void addConstants(HashSet<Constant> result, RegisterSpec spec) {
    if (spec == null) {
        return;
    }
    LocalItem local = spec.getLocalItem();
    CstString name = local.getName();
    CstString signature = local.getSignature();
    Type type = spec.getType();
    if (type != Type.KNOWN_NULL) {
        result.add(CstType.intern(type));
    }
    if (name != null) {
        result.add(name);
    }
    if (signature != null) {
        result.add(signature);
    }
}
Also used : Type(com.android.dx.rop.type.Type) CstType(com.android.dx.rop.cst.CstType) CstString(com.android.dx.rop.cst.CstString) LocalItem(com.android.dx.rop.code.LocalItem)

Example 2 with LocalItem

use of com.android.dx.rop.code.LocalItem in project buck by facebook.

the class SsaRenamer method setNameForSsaReg.

/**
     * Records a debug (local variable) name for a specified register.
     *
     * @param ssaReg non-null named register spec in SSA name space
     */
private void setNameForSsaReg(RegisterSpec ssaReg) {
    int reg = ssaReg.getReg();
    LocalItem local = ssaReg.getLocalItem();
    ssaRegToLocalItems.ensureCapacity(reg + 1);
    while (ssaRegToLocalItems.size() <= reg) {
        ssaRegToLocalItems.add(null);
    }
    ssaRegToLocalItems.set(reg, local);
}
Also used : LocalItem(com.android.dx.rop.code.LocalItem)

Example 3 with LocalItem

use of com.android.dx.rop.code.LocalItem in project buck by facebook.

the class FirstFitLocalCombiningAllocator method adjustAndMapSourceRangeRange.

/**
     * Maps the source registers of the specified instruction such that they
     * will fall in a contiguous range in rop form. Moves are inserted as
     * necessary to allow the range to be allocated.
     *
     * @param insn {@code non-null;} insn whos sources to process
     */
private void adjustAndMapSourceRangeRange(NormalSsaInsn insn) {
    int newRegStart = findRangeAndAdjust(insn);
    RegisterSpecList sources = insn.getSources();
    int szSources = sources.size();
    int nextRopReg = newRegStart;
    for (int i = 0; i < szSources; i++) {
        RegisterSpec source = sources.get(i);
        int sourceReg = source.getReg();
        int category = source.getCategory();
        int curRopReg = nextRopReg;
        nextRopReg += category;
        if (ssaRegsMapped.get(sourceReg)) {
            continue;
        }
        LocalItem localItem = getLocalItemForReg(sourceReg);
        addMapping(source, curRopReg);
        if (localItem != null) {
            markReserved(curRopReg, category);
            ArrayList<RegisterSpec> similarRegisters = localVariables.get(localItem);
            int szSimilar = similarRegisters.size();
            /*
                 * Try to map all SSA registers also associated with
                 * this local.
                 */
            for (int j = 0; j < szSimilar; j++) {
                RegisterSpec similarSpec = similarRegisters.get(j);
                int similarReg = similarSpec.getReg();
                // Don't map anything that's also a source.
                if (-1 != sources.indexOfRegister(similarReg)) {
                    continue;
                }
                // Registers left unmapped will get handled later.
                tryMapReg(similarSpec, curRopReg, category);
            }
        }
    }
}
Also used : LocalItem(com.android.dx.rop.code.LocalItem) RegisterSpecList(com.android.dx.rop.code.RegisterSpecList) RegisterSpec(com.android.dx.rop.code.RegisterSpec)

Example 4 with LocalItem

use of com.android.dx.rop.code.LocalItem in project J2ME-Loader by nikita36078.

the class FirstFitLocalCombiningAllocator method printLocalVars.

/**
 * Dumps local variable table to stdout for debugging.
 */
private void printLocalVars() {
    System.out.println("Printing local vars");
    for (Map.Entry<LocalItem, ArrayList<RegisterSpec>> e : localVariables.entrySet()) {
        StringBuilder regs = new StringBuilder();
        regs.append('{');
        regs.append(' ');
        for (RegisterSpec reg : e.getValue()) {
            regs.append('v');
            regs.append(reg.getReg());
            regs.append(' ');
        }
        regs.append('}');
        System.out.printf("Local: %s Registers: %s\n", e.getKey(), regs);
    }
}
Also used : ArrayList(java.util.ArrayList) LocalItem(com.android.dx.rop.code.LocalItem) TreeMap(java.util.TreeMap) Map(java.util.Map) RegisterSpec(com.android.dx.rop.code.RegisterSpec)

Example 5 with LocalItem

use of com.android.dx.rop.code.LocalItem in project J2ME-Loader by nikita36078.

the class SsaRenamer method setNameForSsaReg.

/**
 * Records a debug (local variable) name for a specified register.
 *
 * @param ssaReg non-null named register spec in SSA name space
 */
private void setNameForSsaReg(RegisterSpec ssaReg) {
    int reg = ssaReg.getReg();
    LocalItem local = ssaReg.getLocalItem();
    ssaRegToLocalItems.ensureCapacity(reg + 1);
    while (ssaRegToLocalItems.size() <= reg) {
        ssaRegToLocalItems.add(null);
    }
    ssaRegToLocalItems.set(reg, local);
}
Also used : LocalItem(com.android.dx.rop.code.LocalItem)

Aggregations

LocalItem (com.android.dx.rop.code.LocalItem)14 RegisterSpec (com.android.dx.rop.code.RegisterSpec)10 RegisterSpecList (com.android.dx.rop.code.RegisterSpecList)4 PlainInsn (com.android.dx.rop.code.PlainInsn)2 CstString (com.android.dx.rop.cst.CstString)2 CstType (com.android.dx.rop.cst.CstType)2 Type (com.android.dx.rop.type.Type)2 TypeBearer (com.android.dx.rop.type.TypeBearer)2 ArrayList (java.util.ArrayList)2 Map (java.util.Map)2 TreeMap (java.util.TreeMap)2