private static LocalsArray adjustLocalsForSubroutines(LocalsArray locals, IntList subroutines) {
    if (!(locals instanceof LocalsArraySet)) {
      // nothing to see here
      return locals;
    }

    LocalsArraySet laSet = (LocalsArraySet) locals;

    if (subroutines.size() == 0) {
      /*
       * We've merged from a subroutine context to a non-subroutine
       * context, likely via a throw. Our successor will only need
       * to consider the primary locals state, not the state of
       * all possible subroutine paths.
       */

      return laSet.getPrimary();
    }

    /*
     * It's unclear to me if the locals set needs to be trimmed here.
     * If it does, then I believe it is all of the calling blocks
     * in the subroutine at the end of "subroutines" passed into
     * this method that should be removed.
     */
    return laSet;
  }
Adjusts a locals array to account for a merged subroutines list. If a frame merge results in,
effectively, a subroutine return through a throw then the current locals will be a
LocalsArraySet that will need to be trimmed of all OneLocalsArray elements that relevent to the
subroutine that is returning.

@param locals {@code non-null;} LocalsArray from before a merge
@param subroutines {@code non-null;} a label list of subroutine start blocks representing the
    subroutine nesting of the block being merged into.
@return {@code non-null;} locals set appropriate for merge
android/android_framework/dex-maker/src/main/java/com/android/dx/cf/code/Frame.java