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

Evgeny Astigeevich eastigeevich at openjdk.org
Tue Jul 22 22:32:55 UTC 2025


On Tue, 22 Jul 2025 22:14:23 GMT, Evgeny Astigeevich <eastigeevich at openjdk.org> wrote:

>> I have not run benchmarks. Do we have any of them in OpenJDK?
>> 
>> For the current default YIELD, compiled switch: https://godbolt.org/z/fo71nfPb6
>> 
>> SpinPause(SpinWait::Inst):
>>         cmp     w0, #3
>>         b.eq    .LBB0_3
>>         cmp     w0, #2
>>         b.ne    .LBB0_4
>>         yield
>>         ret
>> .LBB0_3:
>>         nop
>> .LBB0_4:
>>         ret
>> 
>> 
>> 
>> Iterations:        100
>> Instructions:      800
>> Total Cycles:      203
>
> For my hand written assembly with the current default YIELD: https://godbolt.org/z/3YjxzW4sW
> 
> SpinPause(SpinWait::Inst):
>         mov     w8, w0
>         tbz     w8, #0, .Ltmp0
>         yield
>         b       .Ltmp1
> .Ltmp0:
> .Ltmp1:
> 
>         ret
> 
> 
> 
> Iterations:        100
> Instructions:      500
> Total Cycles:      152

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

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

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


More information about the hotspot-dev mailing list