RFR: 8139457: Array bases are aligned at HeapWord granularity [v45]

Aleksey Shipilev shade at openjdk.org
Thu Jul 6 12:54:20 UTC 2023


On Thu, 6 Jul 2023 12:42:26 GMT, Roman Kennke <rkennke at openjdk.org> wrote:

>> See [JDK-8139457](https://bugs.openjdk.org/browse/JDK-8139457) for details.
>> 
>> Basically, when running with -XX:-UseCompressedClassPointers, arrays will have a gap between the length field and the first array element, because array elements will only start at word-aligned offsets. This is not necessary for smaller-than-word elements.
>> 
>> Also, while it is not very important now, it will become very important with Lilliput, which eliminates the Klass field and would always put the length field at offset 8, and leave a gap between offset 12 and 16.
>> 
>> Testing:
>>  - [x] runtime/FieldLayout/ArrayBaseOffsets.java (x86_64, x86_32, aarch64, arm, riscv, s390)
>>  - [x] bootcycle (x86_64, x86_32, aarch64, arm, riscv, s390)
>>  - [x] tier1 (x86_64, x86_32, aarch64, riscv)
>>  - [x] tier2 (x86_64, aarch64, riscv)
>>  - [x] tier3 (x86_64, riscv)
>
> Roman Kennke has updated the pull request incrementally with one additional commit since the last revision:
> 
>   More copyright fixes

I like how much smaller this changeset got! 
I have no other comments, except a few stylistic nits:

src/hotspot/cpu/aarch64/c1_MacroAssembler_aarch64.cpp line 196:

> 194:   if (len->is_valid()) {
> 195:     strw(len, Address(obj, arrayOopDesc::length_offset_in_bytes()));
> 196:     if (!is_aligned(arrayOopDesc::header_size_in_bytes(), BytesPerLong)) {

`BytesPerLong` or `BytesPerWord`? Later code aligns for `BytesPerWord`.

src/hotspot/cpu/x86/c1_MacroAssembler_x86.cpp line 182:

> 180:     movl(Address(obj, arrayOopDesc::length_offset_in_bytes()), len);
> 181: #ifdef _LP64
> 182:     if (!is_aligned(arrayOopDesc::header_size_in_bytes(), BytesPerLong)) {

`BytesPerWord` here, to be consistent with other assemblers?

-------------

Marked as reviewed by shade (Reviewer).

PR Review: https://git.openjdk.org/jdk/pull/11044#pullrequestreview-1516467837
PR Review Comment: https://git.openjdk.org/jdk/pull/11044#discussion_r1254390868
PR Review Comment: https://git.openjdk.org/jdk/pull/11044#discussion_r1254388809


More information about the hotspot-dev mailing list