com.android.dx.rop.cst.Constant Java Examples

The following examples show how to use com.android.dx.rop.cst.Constant. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ProtoIdsSection.java    From Box with Apache License 2.0 6 votes vote down vote up
/** {@inheritDoc} */
@Override
public IndexedItem get(Constant cst) {
    if (cst == null) {
        throw new NullPointerException("cst == null");
    }

    if (!(cst instanceof CstProtoRef)) {
        throw new IllegalArgumentException("cst not instance of CstProtoRef");
    }

    throwIfNotPrepared();
    CstProtoRef protoRef = (CstProtoRef) cst;
    IndexedItem result = protoIds.get(protoRef.getPrototype());
    if (result == null) {
        throw new IllegalArgumentException("not found");
    }

    return result;
}
 
Example #2
Source File: ValueEncoder.java    From Box with Apache License 2.0 6 votes vote down vote up
/**
 * Writes out the encoded form of the given array, that is, as
 * an {@code encoded_array} and not including a
 * {@code value_type} prefix. If the output stream keeps
 * (debugging) annotations and {@code topLevel} is
 * {@code true}, then this method will write (debugging)
 * annotations.
 *
 * @param array {@code non-null;} array instance to write
 * @param topLevel {@code true} iff the given annotation is the
 * top-level annotation or {@code false} if it is a sub-annotation
 * of some other annotation
 */
public void writeArray(CstArray array, boolean topLevel) {
    boolean annotates = topLevel && out.annotates();
    CstArray.List list = ((CstArray) array).getList();
    int size = list.size();

    if (annotates) {
        out.annotate("  size: " + Hex.u4(size));
    }

    out.writeUleb128(size);

    for (int i = 0; i < size; i++) {
        Constant cst = list.get(i);
        if (annotates) {
            out.annotate("  [" + Integer.toHexString(i) + "] " +
                    constantToHuman(cst));
        }
        writeConstant(cst);
    }

    if (annotates) {
        out.endAnnotation();
    }
}
 
Example #3
Source File: Form11n.java    From Box with Apache License 2.0 6 votes vote down vote up
/** {@inheritDoc} */
@Override
public boolean isCompatible(DalvInsn insn) {
    RegisterSpecList regs = insn.getRegisters();

    if (!((insn instanceof CstInsn) &&
          (regs.size() == 1) &&
          unsignedFitsInNibble(regs.get(0).getReg()))) {
        return false;
    }

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

    if (!(cst instanceof CstLiteralBits)) {
        return false;
    }

    CstLiteralBits cb = (CstLiteralBits) cst;

    return cb.fitsInInt() && signedFitsInNibble(cb.getIntBits());
}
 
Example #4
Source File: Form21s.java    From Box with Apache License 2.0 6 votes vote down vote up
/** {@inheritDoc} */
@Override
public boolean isCompatible(DalvInsn insn) {
    RegisterSpecList regs = insn.getRegisters();
    if (!((insn instanceof CstInsn) &&
          (regs.size() == 1) &&
          unsignedFitsInByte(regs.get(0).getReg()))) {
        return false;
    }

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

    if (!(cst instanceof CstLiteralBits)) {
        return false;
    }

    CstLiteralBits cb = (CstLiteralBits) cst;

    return cb.fitsInInt() && signedFitsInShort(cb.getIntBits());
}
 
Example #5
Source File: Form22c.java    From Box with Apache License 2.0 6 votes vote down vote up
/** {@inheritDoc} */
@Override
public boolean isCompatible(DalvInsn insn) {
    RegisterSpecList regs = insn.getRegisters();
    if (!((insn instanceof CstInsn) &&
          (regs.size() == 2) &&
          unsignedFitsInNibble(regs.get(0).getReg()) &&
          unsignedFitsInNibble(regs.get(1).getReg()))) {
        return false;
    }

    CstInsn ci = (CstInsn) insn;
    int cpi = ci.getIndex();

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

    Constant cst = ci.getConstant();
    return (cst instanceof CstType) ||
        (cst instanceof CstFieldRef);
}
 
Example #6
Source File: Form31i.java    From buck with Apache License 2.0 6 votes vote down vote up
/** {@inheritDoc} */
@Override
public boolean isCompatible(DalvInsn insn) {
    RegisterSpecList regs = insn.getRegisters();
    if (!((insn instanceof CstInsn) &&
          (regs.size() == 1) &&
          unsignedFitsInByte(regs.get(0).getReg()))) {
        return false;
    }

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

    if (!(cst instanceof CstLiteralBits)) {
        return false;
    }

    return ((CstLiteralBits) cst).fitsInInt();
}
 
Example #7
Source File: EscapeAnalysis.java    From J2ME-Loader with Apache License 2.0 6 votes vote down vote up
/**
 * Replaces the instructions that define an array with equivalent registers.
 * For each entry in the array, a register is created, initialized to zero.
 * A mapping between this register and the corresponding array index is
 * added.
 *
 * @param def {@code non-null;} move result instruction for array
 * @param prev {@code non-null;} instruction for instantiating new array
 * @param length size of the new array
 * @param newRegs {@code non-null;} mapping of array indices to new
 * registers to be populated
 */
private void replaceDef(SsaInsn def, SsaInsn prev, int length,
                            ArrayList<RegisterSpec> newRegs) {
    Type resultType = def.getResult().getType();

    // Create new zeroed out registers for each element in the array
    for (int i = 0; i < length; i++) {
        Constant newZero = Zeroes.zeroFor(resultType.getComponentType());
        TypedConstant typedZero = (TypedConstant) newZero;
        RegisterSpec newReg =
            RegisterSpec.make(ssaMeth.makeNewSsaReg(), typedZero);
        newRegs.add(newReg);
        insertPlainInsnBefore(def, RegisterSpecList.EMPTY, newReg,
                                  RegOps.CONST, newZero);
    }
}
 
Example #8
Source File: AnnotationId.java    From lua-for-android with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
/**
 * Convert a value of an element to a {@code Constant}.
 * <p><strong>Warning:</strong> Array or TypeId value is not supported yet.
 *
 * @param value an annotation element value.
 * @return a Constant
 */
static Constant toConstant(Object value) {
    Class clazz = value.getClass();
    if (clazz.isEnum()) {
        CstString descriptor = new CstString(TypeId.get(clazz).getName());
        CstString name = new CstString(((Enum) value).name());
        CstNat cstNat = new CstNat(name, descriptor);
        return new CstEnumRef(cstNat);
    } else if (clazz.isArray()) {
        throw new UnsupportedOperationException("Array is not supported yet");
    } else if (value instanceof TypeId) {
        throw new UnsupportedOperationException("TypeId is not supported yet");
    } else {
        return Constants.getConstant(value);
    }
}
 
Example #9
Source File: OutputFinisher.java    From buck with Apache License 2.0 6 votes vote down vote up
/**
 * Helper for {@link #getAllConstants} which adds all the info for
 * a single instruction.
 *
 * @param result {@code non-null;} result set to add to
 * @param insn {@code non-null;} instruction to scrutinize
 */
private static void addConstants(HashSet<Constant> result,
        DalvInsn insn) {
    if (insn instanceof CstInsn) {
        Constant cst = ((CstInsn) insn).getConstant();
        result.add(cst);
    } else if (insn instanceof LocalSnapshot) {
        RegisterSpecSet specs = ((LocalSnapshot) insn).getLocals();
        int size = specs.size();
        for (int i = 0; i < size; i++) {
            addConstants(result, specs.get(i));
        }
    } else if (insn instanceof LocalStart) {
        RegisterSpec spec = ((LocalStart) insn).getLocal();
        addConstants(result, spec);
    }
}
 
Example #10
Source File: RopTranslator.java    From J2ME-Loader with Apache License 2.0 6 votes vote down vote up
/** {@inheritDoc} */
@Override
public void visitInvokePolymorphicInsn(InvokePolymorphicInsn insn) {
    SourcePosition pos = insn.getPosition();
    Dop opcode = RopToDop.dopFor(insn);
    Rop rop = insn.getOpcode();

    if (rop.getBranchingness() != Rop.BRANCH_THROW) {
        throw new RuntimeException("Expected BRANCH_THROW got " + rop.getBranchingness());
    } else if (!rop.isCallLike()) {
        throw new RuntimeException("Expected call-like operation");
    }

    addOutput(lastAddress);

    RegisterSpecList regs = insn.getSources();
    Constant[] constants = new Constant[] {
        insn.getInvokeMethod(),
        insn.getCallSiteProto()
        };
    DalvInsn di = new MultiCstInsn(opcode, pos, regs, constants);

    addOutput(di);
}
 
Example #11
Source File: DexFile.java    From Box with Apache License 2.0 6 votes vote down vote up
/**
 * Interns the given constant in the appropriate section of this
 * instance, or do nothing if the given constant isn't the sort
 * that should be interned.
 *
 * @param cst {@code non-null;} constant to possibly intern
 */
/*package*/ void internIfAppropriate(Constant cst) {
    if (cst == null) {
        throw new NullPointerException("cst == null");
    }

    if (cst instanceof CstString) {
        stringIds.intern((CstString) cst);
    } else if (cst instanceof CstType) {
        typeIds.intern((CstType) cst);
    } else if (cst instanceof CstBaseMethodRef) {
        methodIds.intern((CstBaseMethodRef) cst);
    } else if (cst instanceof CstFieldRef) {
        fieldIds.intern((CstFieldRef) cst);
    } else if (cst instanceof CstEnumRef) {
        fieldIds.intern(((CstEnumRef) cst).getFieldRef());
    } else if (cst instanceof CstProtoRef) {
        protoIds.intern(((CstProtoRef) cst).getPrototype());
    } else if (cst instanceof CstMethodHandle) {
        methodHandles.intern((CstMethodHandle) cst);
    }
}
 
Example #12
Source File: SCCP.java    From Box with Apache License 2.0 6 votes vote down vote up
private SCCP(SsaMethod ssaMeth) {
    this.ssaMeth = ssaMeth;
    this.regCount = ssaMeth.getRegCount();
    this.latticeValues = new int[this.regCount];
    this.latticeConstants = new Constant[this.regCount];
    this.cfgWorklist = new ArrayList<SsaBasicBlock>();
    this.cfgPhiWorklist = new ArrayList<SsaBasicBlock>();
    this.executableBlocks = new BitSet(ssaMeth.getBlocks().size());
    this.ssaWorklist = new ArrayList<SsaInsn>();
    this.varyingWorklist = new ArrayList<SsaInsn>();
    this.branchWorklist = new ArrayList<SsaInsn>();
    for (int i = 0; i < this.regCount; i++) {
        latticeValues[i] = TOP;
        latticeConstants[i] = null;
    }
}
 
Example #13
Source File: StringIdsSection.java    From Box with Apache License 2.0 6 votes vote down vote up
/** {@inheritDoc} */
@Override
public IndexedItem get(Constant cst) {
    if (cst == null) {
        throw new NullPointerException("cst == null");
    }

    throwIfNotPrepared();

    IndexedItem result = strings.get((CstString) cst);

    if (result == null) {
        throw new IllegalArgumentException("not found");
    }

    return result;
}
 
Example #14
Source File: DexFile.java    From J2ME-Loader with Apache License 2.0 6 votes vote down vote up
/**
 * Interns the given constant in the appropriate section of this
 * instance, or do nothing if the given constant isn't the sort
 * that should be interned.
 *
 * @param cst {@code non-null;} constant to possibly intern
 */
/*package*/ void internIfAppropriate(Constant cst) {
    if (cst instanceof CstString) {
        stringIds.intern((CstString) cst);
    } else if (cst instanceof CstType) {
        typeIds.intern((CstType) cst);
    } else if (cst instanceof CstBaseMethodRef) {
        methodIds.intern((CstBaseMethodRef) cst);
    } else if (cst instanceof CstFieldRef) {
        fieldIds.intern((CstFieldRef) cst);
    } else if (cst instanceof CstEnumRef) {
        fieldIds.intern(((CstEnumRef) cst).getFieldRef());
    } else if (cst == null) {
        throw new NullPointerException("cst == null");
    }
}
 
Example #15
Source File: Form22c.java    From J2ME-Loader with Apache License 2.0 6 votes vote down vote up
/** {@inheritDoc} */
@Override
public boolean isCompatible(DalvInsn insn) {
    RegisterSpecList regs = insn.getRegisters();
    if (!((insn instanceof CstInsn) &&
          (regs.size() == 2) &&
          unsignedFitsInNibble(regs.get(0).getReg()) &&
          unsignedFitsInNibble(regs.get(1).getReg()))) {
        return false;
    }

    CstInsn ci = (CstInsn) insn;
    int cpi = ci.getIndex();

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

    Constant cst = ci.getConstant();
    return (cst instanceof CstType) ||
        (cst instanceof CstFieldRef);
}
 
Example #16
Source File: SCCP.java    From buck with Apache License 2.0 6 votes vote down vote up
private SCCP(SsaMethod ssaMeth) {
    this.ssaMeth = ssaMeth;
    this.regCount = ssaMeth.getRegCount();
    this.latticeValues = new int[this.regCount];
    this.latticeConstants = new Constant[this.regCount];
    this.cfgWorklist = new ArrayList<SsaBasicBlock>();
    this.cfgPhiWorklist = new ArrayList<SsaBasicBlock>();
    this.executableBlocks = new BitSet(ssaMeth.getBlocks().size());
    this.ssaWorklist = new ArrayList<SsaInsn>();
    this.varyingWorklist = new ArrayList<SsaInsn>();
    this.branchWorklist = new ArrayList<SsaInsn>();
    for (int i = 0; i < this.regCount; i++) {
        latticeValues[i] = TOP;
        latticeConstants[i] = null;
    }
}
 
Example #17
Source File: ClassDataItem.java    From Box with Apache License 2.0 6 votes vote down vote up
/**
 * Constructs an instance. Its sets of members are initially
 * empty.
 *
 * @param thisClass {@code non-null;} what class this data is for, just
 * for listing generation
 */
public ClassDataItem(CstType thisClass) {
    super(1, -1);

    if (thisClass == null) {
        throw new NullPointerException("thisClass == null");
    }

    this.thisClass = thisClass;
    this.staticFields = new ArrayList<EncodedField>(20);
    this.staticValues = new HashMap<EncodedField, Constant>(40);
    this.instanceFields = new ArrayList<EncodedField>(20);
    this.directMethods = new ArrayList<EncodedMethod>(20);
    this.virtualMethods = new ArrayList<EncodedMethod>(20);
    this.staticValuesConstant = null;
}
 
Example #18
Source File: ValueEncoder.java    From J2ME-Loader with Apache License 2.0 6 votes vote down vote up
/**
 * Gets the colloquial type name and human form of the type of the
 * given constant, when used as an encoded value.
 *
 * @param cst {@code non-null;} the constant
 * @return {@code non-null;} its type name and human form
 */
public static String constantToHuman(Constant cst) {
    int type = constantToValueType(cst);

    if (type == VALUE_NULL) {
        return "null";
    }

    StringBuilder sb = new StringBuilder();

    sb.append(cst.typeName());
    sb.append(' ');
    sb.append(cst.toHuman());

    return sb.toString();
}
 
Example #19
Source File: OutputFinisher.java    From Box with Apache License 2.0 6 votes vote down vote up
/**
 * Helper for {@link #getAllConstants} which adds all the info for
 * a single instruction.
 *
 * @param result {@code non-null;} result set to add to
 * @param insn {@code non-null;} instruction to scrutinize
 */
private static void addConstants(HashSet<Constant> result,
        DalvInsn insn) {
    if (insn instanceof CstInsn) {
        Constant cst = ((CstInsn) insn).getConstant();
        result.add(cst);
    } else if (insn instanceof MultiCstInsn) {
        MultiCstInsn m = (MultiCstInsn) insn;
        for (int i = 0; i < m.getNumberOfConstants(); i++) {
            result.add(m.getConstant(i));
        }
    } else if (insn instanceof LocalSnapshot) {
        RegisterSpecSet specs = ((LocalSnapshot) insn).getLocals();
        int size = specs.size();
        for (int i = 0; i < size; i++) {
            addConstants(result, specs.get(i));
        }
    } else if (insn instanceof LocalStart) {
        RegisterSpec spec = ((LocalStart) insn).getLocal();
        addConstants(result, spec);
    }
}
 
Example #20
Source File: DexFile.java    From J2ME-Loader with Apache License 2.0 6 votes vote down vote up
/**
 * Gets the {@link IndexedItem} corresponding to the given constant,
 * if it is a constant that has such a correspondence, or return
 * {@code null} if it isn't such a constant. This will throw
 * an exception if the given constant <i>should</i> have been found
 * but wasn't.
 *
 * @param cst {@code non-null;} the constant to look up
 * @return {@code null-ok;} its corresponding item, if it has a corresponding
 * item, or {@code null} if it's not that sort of constant
 */
/*package*/ IndexedItem findItemOrNull(Constant cst) {

    if (cst instanceof CstString) {
        return stringIds.get(cst);
    } else if (cst instanceof CstType) {
        return typeIds.get(cst);
    } else if (cst instanceof CstBaseMethodRef) {
        return methodIds.get(cst);
    } else if (cst instanceof CstFieldRef) {
        return fieldIds.get(cst);
    } else if (cst instanceof CstProtoRef) {
        return protoIds.get(cst);
    } else {
        return null;
    }
}
 
Example #21
Source File: Form31i.java    From J2ME-Loader with Apache License 2.0 6 votes vote down vote up
/** {@inheritDoc} */
@Override
public boolean isCompatible(DalvInsn insn) {
    RegisterSpecList regs = insn.getRegisters();
    if (!((insn instanceof CstInsn) &&
          (regs.size() == 1) &&
          unsignedFitsInByte(regs.get(0).getReg()))) {
        return false;
    }

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

    if (!(cst instanceof CstLiteralBits)) {
        return false;
    }

    return ((CstLiteralBits) cst).fitsInInt();
}
 
Example #22
Source File: DexFile.java    From buck with Apache License 2.0 6 votes vote down vote up
/**
 * Interns the given constant in the appropriate section of this
 * instance, or do nothing if the given constant isn't the sort
 * that should be interned.
 *
 * @param cst {@code non-null;} constant to possibly intern
 */
/*package*/ void internIfAppropriate(Constant cst) {
    if (cst instanceof CstString) {
        stringIds.intern((CstString) cst);
    } else if (cst instanceof CstType) {
        typeIds.intern((CstType) cst);
    } else if (cst instanceof CstBaseMethodRef) {
        methodIds.intern((CstBaseMethodRef) cst);
    } else if (cst instanceof CstFieldRef) {
        fieldIds.intern((CstFieldRef) cst);
    } else if (cst instanceof CstEnumRef) {
        fieldIds.intern(((CstEnumRef) cst).getFieldRef());
    } else if (cst == null) {
        throw new NullPointerException("cst == null");
    }
}
 
Example #23
Source File: RopTranslator.java    From Box with Apache License 2.0 6 votes vote down vote up
/** {@inheritDoc} */
@Override
public void visitInvokePolymorphicInsn(InvokePolymorphicInsn insn) {
    SourcePosition pos = insn.getPosition();
    Dop opcode = RopToDop.dopFor(insn);
    Rop rop = insn.getOpcode();

    if (rop.getBranchingness() != Rop.BRANCH_THROW) {
        throw new RuntimeException("Expected BRANCH_THROW got " + rop.getBranchingness());
    } else if (!rop.isCallLike()) {
        throw new RuntimeException("Expected call-like operation");
    }

    addOutput(lastAddress);

    RegisterSpecList regs = insn.getSources();
    Constant[] constants = new Constant[] {
        insn.getPolymorphicMethod(),
        insn.getCallSiteProto()
        };
    DalvInsn di = new MultiCstInsn(opcode, pos, regs, constants);

    addOutput(di);
}
 
Example #24
Source File: ThrowingCstInsn.java    From buck with Apache License 2.0 6 votes vote down vote up
/**
 * Constructs an instance.
 *
 * @param opcode {@code non-null;} the opcode
 * @param position {@code non-null;} source position
 * @param sources {@code non-null;} specs for all the sources
 * @param catches {@code non-null;} list of exceptions caught
 * @param cst {@code non-null;} the constant
 */
public ThrowingCstInsn(Rop opcode, SourcePosition position,
                       RegisterSpecList sources,
                       TypeList catches, Constant cst) {
    super(opcode, position, null, sources, cst);

    if (opcode.getBranchingness() != Rop.BRANCH_THROW) {
        throw new IllegalArgumentException("bogus branchingness");
    }

    if (catches == null) {
        throw new NullPointerException("catches == null");
    }

    this.catches = catches;
}
 
Example #25
Source File: FieldIdsSection.java    From Box with Apache License 2.0 6 votes vote down vote up
/** {@inheritDoc} */
@Override
public IndexedItem get(Constant cst) {
    if (cst == null) {
        throw new NullPointerException("cst == null");
    }

    throwIfNotPrepared();

    IndexedItem result = fieldIds.get((CstFieldRef) cst);

    if (result == null) {
        throw new IllegalArgumentException("not found");
    }

    return result;
}
 
Example #26
Source File: Form22c.java    From Box with Apache License 2.0 6 votes vote down vote up
/** {@inheritDoc} */
@Override
public boolean isCompatible(DalvInsn insn) {
    RegisterSpecList regs = insn.getRegisters();
    if (!((insn instanceof CstInsn) &&
          (regs.size() == 2) &&
          unsignedFitsInNibble(regs.get(0).getReg()) &&
          unsignedFitsInNibble(regs.get(1).getReg()))) {
        return false;
    }

    CstInsn ci = (CstInsn) insn;
    int cpi = ci.getIndex();

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

    Constant cst = ci.getConstant();
    return (cst instanceof CstType) ||
        (cst instanceof CstFieldRef);
}
 
Example #27
Source File: FieldIdsSection.java    From Box with Apache License 2.0 6 votes vote down vote up
/** {@inheritDoc} */
@Override
public IndexedItem get(Constant cst) {
    if (cst == null) {
        throw new NullPointerException("cst == null");
    }

    throwIfNotPrepared();

    IndexedItem result = fieldIds.get((CstFieldRef) cst);

    if (result == null) {
        throw new IllegalArgumentException("not found");
    }

    return result;
}
 
Example #28
Source File: ClassDataItem.java    From Box with Apache License 2.0 6 votes vote down vote up
/**
 * Constructs an instance. Its sets of members are initially
 * empty.
 *
 * @param thisClass {@code non-null;} what class this data is for, just
 * for listing generation
 */
public ClassDataItem(CstType thisClass) {
    super(1, -1);

    if (thisClass == null) {
        throw new NullPointerException("thisClass == null");
    }

    this.thisClass = thisClass;
    this.staticFields = new ArrayList<EncodedField>(20);
    this.staticValues = new HashMap<EncodedField, Constant>(40);
    this.instanceFields = new ArrayList<EncodedField>(20);
    this.directMethods = new ArrayList<EncodedMethod>(20);
    this.virtualMethods = new ArrayList<EncodedMethod>(20);
    this.staticValuesConstant = null;
}
 
Example #29
Source File: Form22b.java    From Box with Apache License 2.0 6 votes vote down vote up
/** {@inheritDoc} */
@Override
public boolean isCompatible(DalvInsn insn) {
    RegisterSpecList regs = insn.getRegisters();
    if (!((insn instanceof CstInsn) &&
          (regs.size() == 2) &&
          unsignedFitsInByte(regs.get(0).getReg()) &&
          unsignedFitsInByte(regs.get(1).getReg()))) {
        return false;
    }

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

    if (!(cst instanceof CstLiteralBits)) {
        return false;
    }

    CstLiteralBits cb = (CstLiteralBits) cst;

    return cb.fitsInInt() && signedFitsInByte(cb.getIntBits());
}
 
Example #30
Source File: Form35c.java    From Box with Apache License 2.0 6 votes vote down vote up
/** {@inheritDoc} */
@Override
public boolean isCompatible(DalvInsn insn) {
    if (!(insn instanceof CstInsn)) {
        return false;
    }

    CstInsn ci = (CstInsn) insn;
    int cpi = ci.getIndex();

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

    Constant cst = ci.getConstant();
    if (!((cst instanceof CstMethodRef) ||
          (cst instanceof CstType) ||
          (cst instanceof CstCallSiteRef))) {
        return false;
    }

    RegisterSpecList regs = ci.getRegisters();
    return (wordCount(regs) >= 0);
}