[master] RFR: Relax array elements alignment [v5]

Roman Kennke rkennke at openjdk.java.net
Tue Apr 26 12:35:26 UTC 2022


On Tue, 26 Apr 2022 05:58:48 GMT, Thomas Stuefe <stuefe at openjdk.org> wrote:

>> Roman Kennke has updated the pull request incrementally with one additional commit since the last revision:
>> 
>>   Use correct array element type to determine header size in TypeAryPtr::dump2()
>
> src/hotspot/cpu/aarch64/c1_MacroAssembler_aarch64.cpp line 187:
> 
>> 185: 
>> 186:   // Zero first 4 bytes, if start offset is not 64bit aligned.
>> 187:   if ((hdr_size_in_bytes & (BytesPerWord - 1)) != 0) {
> 
> Does not do what the comment says, since BytesPerWord=4 on 32-bit.
> 
> On 32-bit I believe this condition is always false.
> 
> Maybe use BytesPerLong instead? Also, maybe use is_aligned()?
> 
> 
> !is_aligned(hdr_size_in_bytes, BytesPerLong)

There is no 32bit in AArch64.
Also, even if there were, the fast loop afterwards zeroes word-sized chunks, which would be 32bit, so always being false would be correct?
Good suggestion about using is_aligned(), will do.

> src/hotspot/cpu/x86/macroAssembler_x86.cpp line 3791:
> 
>> 3789:   xorptr(temp, temp);    // use _zero reg to clear memory (shorter code)
>> 3790: #ifdef _LP64
>> 3791:   if ((offset_in_bytes & (BytesPerWord - 1)) != 0) {
> 
> Did the old code ever bother to zero out the gap between array size and first element address in compressed class pointers off mode?
> 
> I'd prefer BytesPerLong here too.

Nope, but it was dead 4 bytes, vs now the first 4 live elements of the arrays. I think BytesPerWord is correct, see comment above.

> test/hotspot/jtreg/gc/g1/plab/TestPLABPromotion.java line 76:
> 
>> 74:     private static final int OBJECT_SIZE_SMALL = 10;
>> 75:     private static final int OBJECT_SIZE_MEDIUM = 100;
>> 76:     private static final int OBJECT_SIZE_HIGH = Platform.is64bit() ? 3266 : 3258;
> 
> why this difference?

I believe the value was carefully chosen to hit exactly a PLAB boundary. PLABs required some extra wiggle room so that we could fill them with the smallest possible object, which used to be 2 words. Now we can fill any remaining space, even if it's just 1 word, so we need to allocate 1 more word to exactly hit the PLAB boundary in the test.

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

PR: https://git.openjdk.java.net/lilliput/pull/41


More information about the lilliput-dev mailing list