RFR: 8362193: Re-work MacOS/AArch64 SpinPause to handle SB [v3]
Evgeny Astigeevich
eastigeevich at openjdk.org
Tue Jul 22 22:43:55 UTC 2025
On Tue, 22 Jul 2025 22:35:12 GMT, Evgeny Astigeevich <eastigeevich at openjdk.org> wrote:
>> The original assembly with the current default YIELD: https://godbolt.org/z/McWGM4f44
>>
>> SpinPause(SpinWait::Inst):
>> lsl w8, w0, #3
>> sxtw x8, w8
>> adr x9, #20
>> add x9, x9, x8
>> br x9
>> b .Ltmp1
>> nop
>> nop
>> b .Ltmp1
>> nop
>> b .Ltmp1
>> yield
>> .Ltmp1:
>>
>> ret
>>
>>
>>
>> Iterations: 100
>> Instructions: 1300
>> Total Cycles: 254
>
> For the default YIELD we have:
> - Original: ~250 clocks
> - Compiler binary search tree: ~200 clocks (-20%)
> - Optimized with `TBZ`: ~150 clocks (-40%)
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`.
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/26387#discussion_r2223958425
More information about the hotspot-dev
mailing list