private void scalarReplacement() {
    // Iterate through lattice, looking for non-escaping replaceable arrays
    for (EscapeSet escSet : latticeValues) {
      if (!escSet.replaceableArray || escSet.escape != EscapeState.NONE) {
        continue;
      }

      // Get the instructions for the definition and move of the array
      int e = escSet.regSet.nextSetBit(0);
      SsaInsn def = ssaMeth.getDefinitionForRegister(e);
      SsaInsn prev = getInsnForMove(def);

      // Create a map for the new registers that will be created
      TypeBearer lengthReg = prev.getSources().get(0).getTypeBearer();
      int length = ((CstLiteralBits) lengthReg).getIntBits();
      ArrayList<RegisterSpec> newRegs = new ArrayList<RegisterSpec>(length);
      HashSet<SsaInsn> deletedInsns = new HashSet<SsaInsn>();

      // Replace the definition of the array with registers
      replaceDef(def, prev, length, newRegs);

      // Mark definition instructions for deletion
      deletedInsns.add(prev);
      deletedInsns.add(def);

      // Go through all uses of the array
      List<SsaInsn> useList = ssaMeth.getUseListForRegister(e);
      for (SsaInsn use : useList) {
        // Replace the use with scalars and then mark it for deletion
        replaceUse(use, prev, newRegs, deletedInsns);
        deletedInsns.add(use);
      }

      // Delete all marked instructions
      ssaMeth.deleteInsns(deletedInsns);
      ssaMeth.onInsnsChanged();

      // Convert the method back to SSA form
      SsaConverter.updateSsaMethod(ssaMeth, regCount);

      // Propagate and remove extra moves added by scalar replacement
      movePropagate();
    }
  }
Performs scalar replacement on all eligible arrays.
android/android_framework/dex-maker/src/main/java/com/android/dx/ssa/EscapeAnalysis.java