RFR: 8364235: Fix for JDK-8361447 breaks the alignment requirements for GuardedMemory [v2]
Axel Boldt-Christmas
aboldtch at openjdk.org
Tue Jul 29 08:33:05 UTC 2025
On Tue, 29 Jul 2025 07:48:14 GMT, David Holmes <dholmes at openjdk.org> wrote:
>> src/hotspot/share/memory/guardedMemory.hpp line 144:
>>
>>> 142:
>>> 143: void* padding; // Ensures 16-byte alignment
>>> 144:
>>
>> The right thing to do is to do:
>>
>> ```c++
>> class alignas(16) GuardHeader : Guard {
>> // NO void* padding
>> };
>
> That aligns the `GuardHeader` (something already done by `malloc`) but doesn't guarantee the alignment of the `_base_addr` field which is the user-data ptr.
Forcing `alignas(16)` alignment on `GuardHeader` directly implies `sizeof(GuardHeader) % 16 == 0` without the need of a padding field. And C++ will be required to insert 8 byte padding after `_tag2`.
If it is important that the padding occurs after the header and before the size keep the current solution.
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/26524#discussion_r2238965325
More information about the hotspot-runtime-dev
mailing list