code: private void layout(Output dest) {
          Instruction instr;
          int instrSize, varSize;
          IntArrayList vars;  // indexes of instructions with variable length
          IntArrayList lens;  // lengths of var-len instructions
          int i, j, k, ofs;
          int shrink, len;
          boolean changes;
  
          instrSize = instructions.size();
          vars = new IntArrayList();
          lens = new IntArrayList();
          ofs = 0;
          for (i = 0; i < instrSize; i++) {
              instr = instructions.get(i);
              instr.ofs = ofs;
              len = instr.getMaxLength(dest);
              ofs += len;
              if (instr.type.isVariable()) {
                  vars.add(i);
                  lens.add(len);
              }
          }
          codeSize = ofs;
          varSize = vars.size();
          do {
              changes = false;
              shrink = 0;
              for (i = 0; i < varSize; i++) {
                  j = vars.get(i);
                  instr = instructions.get(j);
                  len = instr.getVariableLength(this);
                  if (len < lens.get(i)) {
                      changes = true;
                      shrink += (lens.get(i) - len);
                      lens.set(i, len);
                  }
                  if (shrink > 0) {
                      // relocate up to end or next var-instr
                      for (k = (i + 1 == varSize)? instrSize - 1 : vars.get(i + 1);  k > j; k--) {
                          instructions.get(k).ofs -= shrink;
                      }
                  }
              }
              codeSize -= shrink;
          } while (changes);
      }
docs: compute ofs for all instructions.