RFR: JDK-8304723: Statically allocate global mutexes

Justin King jcking at openjdk.org
Wed Mar 22 16:26:49 UTC 2023


On Wed, 22 Mar 2023 15:51:12 GMT, Coleen Phillimore <coleenp at openjdk.org> wrote:

> I have to say that I don't like this change. I don't want to see the noisy .get() everywhere. Can you do this without .get()?

It's possible, but would require a little more work. The compilers don't like a ternary where one of the branches is `nullptr`. One option would be to come up with something where the mutex or lock returned itself if it is not owned by the calling thread otherwise nullptr. Or introduce something like `MutexLockerIf` which takes a bool as its first constructor argument and makes the mutex `nullptr` if the condition is not true. Opinions?

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

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


More information about the hotspot-dev mailing list