RFR: JDK-8304723: Statically allocate global mutexes

Justin King jcking at openjdk.org
Wed Mar 22 17:31:24 UTC 2023


On Wed, 22 Mar 2023 17:17:57 GMT, Thomas Stuefe <stuefe at openjdk.org> wrote:

> Like Coleen I don't like the invasiveness of this patch, esp. considering what it is doing. Pls try to simplify. You could probably keep the outside semantics, and do without templates. Eg define the mutexes in a compilation unit and export pointers to them to the outside?

I did that initially, but it still has the unnecessary indirection potentially causing more cache misses. Additionally as I mentioned above, this has now caught two existing bugs where just raw pointers would not have caught them, since a nullptr is perfectly valid for `MutexLocker`. It doesn't catch the fact that the lock was never created. `StaticLock` asserts that the lock has been initialized when its accessed and can never return `nullptr`.  It also ensures it is never initialized twice, which `Heap_lock` was.

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

PR Comment: https://git.openjdk.org/jdk/pull/13143#issuecomment-1479980274


More information about the hotspot-dev mailing list