RFR: 8366671: Refactor Thread::SpinAcquire and Thread::SpinRelease [v6]

Anton Artemov aartemov at openjdk.org
Thu Nov 20 10:37:29 UTC 2025


On Thu, 20 Nov 2025 06:08:03 GMT, David Holmes <dholmes at openjdk.org> wrote:

>> I think it's because `bool` is (typically? always? I don't recall) of size 1,
>> and size 1 cmpxchg isn't supported by a lot of hardware, so we emuluate it for
>> those. Mostly we don't worry about that, but this is supposed to be low-level
>> and performance-critical (else why aren't we just using a mutex?). Or maybe it
>> is historical, and the starting point for some of this code is so old that it
>> predates our emulation of 1-byte cmpxchg for some platforms. :)
>
> I think it is because a 32-bit atomic op is mostly likely the most performant variant even if larger and smaller entities are supported by an architecture.

I added a comment about that.

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

PR Review Comment: https://git.openjdk.org/jdk/pull/28264#discussion_r2545361857


More information about the hotspot-dev mailing list