Пример #1
0
 /**
  * Iterates over the predecessors of this instruction, and merges all the post-instruction
  * register types for the given register. Any dead, unreachable, or odexed predecessor is ignored
  *
  * @param registerNumber the register number
  * @return The register type resulting from merging the post-instruction register types from all
  *     predecessors
  */
 protected RegisterType mergePreRegisterTypeFromPredecessors(int registerNumber) {
   RegisterType mergedRegisterType = null;
   for (AnalyzedInstruction predecessor : predecessors) {
     RegisterType predecessorRegisterType = predecessor.postRegisterMap[registerNumber];
     assert predecessorRegisterType != null;
     mergedRegisterType = predecessorRegisterType.merge(mergedRegisterType);
   }
   return mergedRegisterType;
 }
Пример #2
0
  /*
   * Merges the given register type into the specified pre-instruction register, and also sets the post-instruction
   * register type accordingly if it isn't a destination register for this instruction
   * @param registerNumber Which register to set
   * @param registerType The register type
   * @returns true If the post-instruction register type was changed. This might be false if either the specified
   * register is a destination register for this instruction, or if the pre-instruction register type didn't change
   * after merging in the given register type
   */
  protected boolean mergeRegister(
      int registerNumber, RegisterType registerType, BitSet verifiedInstructions) {
    assert registerNumber >= 0 && registerNumber < postRegisterMap.length;
    assert registerType != null;

    RegisterType oldRegisterType = preRegisterMap[registerNumber];
    RegisterType mergedRegisterType = oldRegisterType.merge(registerType);

    if (mergedRegisterType.equals(oldRegisterType)) {
      return false;
    }

    preRegisterMap[registerNumber] = mergedRegisterType;
    verifiedInstructions.clear(instructionIndex);

    if (!setsRegister(registerNumber)) {
      postRegisterMap[registerNumber] = mergedRegisterType;
      return true;
    }

    return false;
  }