RFR: JDK-8304820: Statically allocate ObjectSynchronizer mutexes [v4]
Axel Boldt-Christmas
aboldtch at openjdk.org
Wed Mar 29 11:25:23 UTC 2023
On Wed, 29 Mar 2023 02:41:32 GMT, David Holmes <dholmes at openjdk.org> wrote:
>> Justin King has updated the pull request incrementally with one additional commit since the last revision:
>>
>> Remove unnecessary align_up
>>
>> Signed-off-by: Justin King <jcking at google.com>
>
> src/hotspot/share/runtime/synchronizer.cpp line 253:
>
>> 251:
>> 252: // Static storage for an array of PlatformMutex.
>> 253: alignas(PlatformMutex) static uint8_t _inflation_locks[inflation_lock_count()][sizeof(PlatformMutex)];
>
> Sorry I am still not understanding why this can't just be:
>
> alignas(PlatformMutex) static PlatformMutex _inflation_locks[inflation_lock_count()];
>
> ??? (And is the alignas even needed?)
`alignas` is not needed in your example.
I guess we do not do this because we want to control the initialization of these objects and not rely on C++ dynamic initialization.
You could solve this in different ways. Some containing struct, which was rejected in the #13143. Or rewriting PlatformMutex to be constant initializable.
Having a byte blob as backing storage does seem like the simplest least intrusive solution.
When we move to C++17 then this could be a candidate use for `std::optional`.
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/13160#discussion_r1151783335
More information about the hotspot-runtime-dev
mailing list