Search in sources :

Example 6 with LocalItem

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

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));
    } else {
        /* If this a "known null", let's use "Object" because that's going to be the
             * resulting type in {@link LocalList.MakeState#filterSpec} */
        result.add(CstType.intern(Type.OBJECT));
    }
    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 7 with LocalItem

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

the class NormalSsaInsn method getLocalAssignment.

/**
 * {@inheritDoc}
 */
@Override
public RegisterSpec getLocalAssignment() {
    RegisterSpec assignment;
    if (insn.getOpcode().getOpcode() == RegOps.MARK_LOCAL) {
        assignment = insn.getSources().get(0);
    } else {
        assignment = getResult();
    }
    if (assignment == null) {
        return null;
    }
    LocalItem local = assignment.getLocalItem();
    if (local == null) {
        return null;
    }
    return assignment;
}
Also used : LocalItem(com.android.dx.rop.code.LocalItem) RegisterSpec(com.android.dx.rop.code.RegisterSpec)

Example 8 with LocalItem

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

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 9 with LocalItem

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

the class ConstCollector method fixLocalAssignment.

/**
     * 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);
    }
}
Also used : PlainInsn(com.android.dx.rop.code.PlainInsn) LocalItem(com.android.dx.rop.code.LocalItem) RegisterSpec(com.android.dx.rop.code.RegisterSpec)

Example 10 with LocalItem

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

the class NormalSsaInsn method getLocalAssignment.

/** {@inheritDoc} */
@Override
public RegisterSpec getLocalAssignment() {
    RegisterSpec assignment;
    if (insn.getOpcode().getOpcode() == RegOps.MARK_LOCAL) {
        assignment = insn.getSources().get(0);
    } else {
        assignment = getResult();
    }
    if (assignment == null) {
        return null;
    }
    LocalItem local = assignment.getLocalItem();
    if (local == null) {
        return null;
    }
    return assignment;
}
Also used : LocalItem(com.android.dx.rop.code.LocalItem) RegisterSpec(com.android.dx.rop.code.RegisterSpec)

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