public Frame mergeWithSubroutineCaller(Frame other, int subLabel, int predLabel) {
    LocalsArray resultLocals;
    ExecutionStack resultStack;

    resultLocals = getLocals().mergeWithSubroutineCaller(other.getLocals(), predLabel);
    resultStack = getStack().merge(other.getStack());

    IntList newOtherSubroutines = other.subroutines.mutableCopy();
    newOtherSubroutines.add(subLabel);
    newOtherSubroutines.setImmutable();

    if ((resultLocals == getLocals())
        && (resultStack == getStack())
        && subroutines.equals(newOtherSubroutines)) {
      return this;
    }

    IntList resultSubroutines;

    if (subroutines.equals(newOtherSubroutines)) {
      resultSubroutines = subroutines;
    } else {
      /*
       * The new subroutines list should be the deepest of the two
       * lists being merged, but the postfix of the resultant list
       * must be equal to the shorter list.
       */
      IntList nonResultSubroutines;

      if (subroutines.size() > newOtherSubroutines.size()) {
        resultSubroutines = subroutines;
        nonResultSubroutines = newOtherSubroutines;
      } else {
        resultSubroutines = newOtherSubroutines;
        nonResultSubroutines = subroutines;
      }

      int szResult = resultSubroutines.size();
      int szNonResult = nonResultSubroutines.size();

      for (int i = szNonResult - 1; i >= 0; i--) {
        if (nonResultSubroutines.get(i) != resultSubroutines.get(i + (szResult - szNonResult))) {
          throw new RuntimeException("Incompatible merged subroutines");
        }
      }
    }

    return new Frame(resultLocals, resultStack, resultSubroutines);
  }
Merges this frame with the frame of a subroutine caller at {@code predLabel}. Only called on
the frame at the first block of a subroutine.

@param other {@code non-null;} another frame
@param subLabel label of subroutine start block
@param predLabel label of calling block
@return {@code non-null;} the result of merging the two frames
android/android_framework/dex-maker/src/main/java/com/android/dx/cf/code/Frame.java