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.
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.
- links to
-
Commit(master) openjdk/jdk/dcac4b0a
-
Review(master) openjdk/jdk/21382