RFR: 8356173: Remove ThreadCritical [v2]

Kim Barrett kbarrett at openjdk.org
Fri May 9 21:01:54 UTC 2025


On Fri, 9 May 2025 20:41:07 GMT, Coleen Phillimore <coleenp at openjdk.org> wrote:

>> @tstuefe We can't rely on PlatformMutex being initialized that way, because the Windows implementation
>> requires a _call_ to `InitializeCriticalSection`.
>
> I didn't know this about Windows.  The Windows code seemed fine with the static PlatformMutex.  The posix code calls pthread_mutex_init with an parameter that's initialized in os::init() -> pthread_init_common();
> 
> If I call pthread_init_common() in all the places that  _mutexAttr and condAttr are used, the macosx platform is happier.  And I can make PlatformMutex static and remove that initialize_chunk_pool() function.  I don't think this is a nice change though.

For Windows, a static PlatformMutex introduces a global variable with a non-trivial constructor,
which we avoid because of ye old "static initialization order fiasco".  I don't think we should
make this PlatformMutex statically allocated.  We should retain initialize_chunk_pool().
(Especially because the lock-free chunk-pool idea that @jdksjolen  and I have discussed likely
wants an initialization function.)

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

PR Review Comment: https://git.openjdk.org/jdk/pull/25072#discussion_r2082480327


More information about the hotspot-dev mailing list