private void massageInstructions(Dop[] opcodes) {
    if (reservedCount == 0) {
      /*
       * The easy common case: No registers were reserved, so we
       * merely need to replace any instructions whose format
       * (and hence whose opcode) changed during the reservation
       * pass, but all instructions will stay at their original
       * indices, and the instruction list doesn't grow.
       */
      int size = insns.size();

      for (int i = 0; i < size; i++) {
        DalvInsn insn = insns.get(i);
        Dop originalOpcode = insn.getOpcode();
        Dop currentOpcode = opcodes[i];

        if (originalOpcode != currentOpcode) {
          insns.set(i, insn.withOpcode(currentOpcode));
        }
      }
    } else {
      /*
       * The difficult uncommon case: Some instructions have to be
       * expanded to deal with high registers.
       */
      insns = performExpansion(opcodes);
    }
  }
Helper for {@link #finishProcessingAndGetList}, which goes through each instruction in the
output, making sure its opcode can accomodate its arguments. In cases where the opcode is
unable to do so, this replaces the instruction with a larger instruction with identical
semantics that <i>will</i> work.

<p>This method may also reserve a number of low-numbered registers, renumbering the
instructions' original registers, in order to have register space available in which to move
very-high registers when expanding instructions into multi-instruction sequences. This
expansion is done when no simple instruction format can be found for a given instruction that
is able to accomodate that instruction's registers.

<p>This method ignores issues of branch target size, since final addresses aren't known at the
point that this method is called.

@param opcodes {@code non-null;} array of per-instruction opcode selections
android/android_framework/dex-maker/src/main/java/com/android/dx/dex/code/OutputFinisher.java