RFR: 8362193: Re-work MacOS/AArch64 SpinPause to handle SB [v3]

Andrew Dinn adinn at openjdk.org
Wed Jul 23 13:38:57 UTC 2025


On Wed, 23 Jul 2025 11:49:53 GMT, Fredrik Bredberg <fbredberg at openjdk.org> wrote:

>> I think the differences might be smaller on the real hardware. Maybe everything will be around 200 clocks.
>> If we need code easy to maintain then this is `switch`. If we need performance then this is `tbz`.
>
> @eastig
> I would prefer your `tbz` version for reasons stated earlier, but most notably to make it stable across toolchains.
> But maybe it's best to just integrate it as is since there are other problems ([JDK-8361032](https://bugs.openjdk.org/browse/JDK-8361032) and [JDK-8360936](https://bugs.openjdk.org/browse/JDK-8360936)) that are waiting for this to be fixed.
> 
> Time will tell if this implementation will make performance better or worse. The debate of how to best implement `SpinPause()` will surely not end today. :)

Andrew Haley is right. This is a backoff routine. Making it back off that little bit faster or slower is a pointless micro-optimization.

Of course, making the implementation a lot slower could well upset the dynamics of the backoff but that's a different order of magnitude to what is at stake in the various hand-written or generated assembly routines being discussed here. A key thing to note in that regard is that any branching that happens is going to always be followed the same way and hence will be very accurately predicted.

And in other news . . . Rome is burning . . .

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

PR Review Comment: https://git.openjdk.org/jdk/pull/26387#discussion_r2225642394


More information about the hotspot-dev mailing list