Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8341471

Reversed field layout caused by unstable sorting

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: P4 P4
    • 24
    • None
    • hotspot
    • b20
    • aarch64
    • os_x

      When I was debugging the case in JDK-8340646, I found the offset layout of class `TestConvertImplicitNullCheck ` on macOS_aarch64 is different from the layout on linux.

      With the debug vm flag `-XX:+PrintFieldLayout`, on macOS_aarch64, I watched:

      Instance fields:
       @0 12/- RESERVED
       @12 "afff" C 2/2 REGULAR
       @14 "a001" C 2/2 REGULAR
       @16 "a002" C 2/2 REGULAR
       @18 "a003" C 2/2 REGULAR
       @20 "a004" C 2/2 REGULAR
       @22 "a005" C 2/2 REGULAR
       ...
       @8196 "affc" C 2/2 REGULAR
       @8198 "affd" C 2/2 REGULAR
       @8200 "affe" C 2/2 REGULAR
       @8202 "a000" C 2/2 REGULAR

      But on Linux, I watched:

      Instance fields:
       @0 12/- RESERVED
       @12 "a000" C 2/2 REGULAR
       @14 "a001" C 2/2 REGULAR
       @16 "a002" C 2/2 REGULAR
       @18 "a003" C 2/2 REGULAR
       @20 "a004" C 2/2 REGULAR
      ...
       @8196 "affc" C 2/2 REGULAR
       @8198 "affd" C 2/2 REGULAR
       @8200 "affe" C 2/2 REGULAR
       @8202 "afff" C 2/2 REGULAR

      `afff` and `a000` have different orders here.

      The fields do get sorted according to size, see `FieldGroup::sort_by_size()` in `share/classfile/fieldLayoutBuilder.cpp`. Perhaps the sorting algorithm is not stable on macOS when reordering items with the same size.

            fgao Fei Gao
            fgao Fei Gao
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated:
              Resolved: