RFR: 8343249: [Windows] Implement SpinPause

Julian Waters jwaters at openjdk.org
Thu Oct 31 07:12:27 UTC 2024


On Wed, 30 Oct 2024 06:29:29 GMT, Julian Waters <jwaters at openjdk.org> wrote:

> SpinPause is currently not implemented on any Windows platforms, due to a lack of access to assembly in the Microsoft compiler. The YieldProcessor macro can act as a stand in for this purpose, as it compiles down to a single pause instruction on x64 (Which seems to be all that one needs to implement SpinPause in HotSpot). I am less certain about the Windows/ARM64 implementation. There, YieldProcessor compiles down to dmb ishst; yield and I am unsure whether that is a correct SpinPause implementation. If need be, I can retract the ARM64 implementation and only have this for x86

Hmm, in practice the macro for x86 reliably expands to either _mm_pause or __asm { rep nop } as mentioned in the docs (__yield is for ARM64 to my knowledge). Since the 32 bit Windows Port is no more (Or at least is going to die once Magnus commits the removal PR), the only relevant one is __mm_pause, which is basically just the pause instruction. I'm a little skeptical that it would break anything, since the docs do say that it safely has no effect on processors that do not support it, such as non hyperthreaded processors, after all. It seems the main concern here is that YieldProcessor might expand to something that isn't pause, in which case, it technically could be entirely replaced with __mm_pause itself. I simply chose the macro since it is technically more portable

No comment one the ARM64 one, I don't have any ARM assembly knowledge unfortunately. It's likely that I'll have to drop support for SpinPause for ARM64 entirely if this is to go forward, if it even does at all, unless someone with ARM64 knowledge steps in

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

PR Comment: https://git.openjdk.org/jdk/pull/21781#issuecomment-2449174001


More information about the hotspot-runtime-dev mailing list