void initializeLocals() {
    if (localsInitialized) {
      throw new AssertionError();
    }
    localsInitialized = true;

    int reg = 0;
    for (Local<?> local : locals) {
      reg += local.initialize(reg);
    }
    int firstParamReg = reg;
    List<Insn> moveParameterInstructions = new ArrayList<Insn>();
    for (Local<?> local : parameters) {
      CstInteger paramConstant = CstInteger.make(reg - firstParamReg);
      reg += local.initialize(reg);
      moveParameterInstructions.add(
          new PlainCstInsn(
              Rops.opMoveParam(local.type.ropType),
              sourcePosition,
              local.spec(),
              RegisterSpecList.EMPTY,
              paramConstant));
    }
    labels.get(0).instructions.addAll(0, moveParameterInstructions);
  }
Assigns registers to locals. From the spec: "the N arguments to a method land in the last N
registers of the method's invocation frame, in order. Wide arguments consume two registers.
Instance methods are passed a this reference as their first argument."

<p>In addition to assigning registers to each of the locals, this creates instructions to move
parameters into their initial registers. These instructions are inserted before the code's
first real instruction.
android/android_framework/dex-maker/src/main/java/com/android/dx/Code.java