예제 #1
0
  protected void writeInvokeRangeRegisters(IndentingWriter writer) throws IOException {
    RegisterRangeInstruction instruction = (RegisterRangeInstruction) this.instruction;

    int regCount = instruction.getRegisterCount();
    if (regCount == 0) {
      writer.write("{}");
    } else {
      int startRegister = instruction.getStartRegister();
      methodDef.registerFormatter.writeRegisterRange(
          writer, startRegister, startRegister + regCount - 1);
    }
  }
예제 #2
0
  public boolean setsRegister(int registerNumber) {
    // When constructing a new object, the register type will be an uninitialized reference after
    // the new-instance
    // instruction, but becomes an initialized reference once the <init> method is called. So even
    // though invoke
    // instructions don't normally change any registers, calling an <init> method will change the
    // type of its
    // object register. If the uninitialized reference has been copied to other registers, they will
    // be initialized
    // as well, so we need to check for that too
    if (isInvokeInit()) {
      int destinationRegister;
      if (instruction instanceof FiveRegisterInstruction) {
        destinationRegister = ((FiveRegisterInstruction) instruction).getRegisterC();
      } else {
        assert instruction instanceof RegisterRangeInstruction;
        RegisterRangeInstruction rangeInstruction = (RegisterRangeInstruction) instruction;
        assert rangeInstruction.getRegisterCount() > 0;
        destinationRegister = rangeInstruction.getStartRegister();
      }

      if (registerNumber == destinationRegister) {
        return true;
      }
      RegisterType preInstructionDestRegisterType = getPreInstructionRegisterType(registerNumber);
      if (preInstructionDestRegisterType.category != RegisterType.UNINIT_REF
          && preInstructionDestRegisterType.category != RegisterType.UNINIT_THIS) {

        return false;
      }
      // check if the uninit ref has been copied to another register
      return getPreInstructionRegisterType(registerNumber).equals(preInstructionDestRegisterType);
    }

    if (!setsRegister()) {
      return false;
    }
    int destinationRegister = getDestinationRegister();

    if (registerNumber == destinationRegister) {
      return true;
    }
    return setsWideRegister() && registerNumber == (destinationRegister + 1);
  }