RFR: 8321371: SpinPause() not implemented for bsd_aarch64/macOS

Evgeny Astigeevich eastigeevich at openjdk.org
Wed Dec 13 10:38:40 UTC 2023


On Wed, 6 Dec 2023 14:01:49 GMT, Fredrik Bredberg <fbredberg at openjdk.org> wrote:

> The SpinPause() function only returns 0 on bsd_aarch64 (i.e. macOS)
> 
> This PR initially meant to implement SpinPause() for macOS on AArch64 by copying the source from linux_aarch64, but after having some internal discussions, it seems like the most reasonable thing to do is to implement SpinPause() using a single inline yield instruction.
> 
> Tested successfully on macosx-aarch64 tier1-tier5.

Hi @fbredber,

If you want to implement `SpinPause` for  bsd_aarch64/macOS, you need:
- Copy the implementation of `SpinPause` from https://github.com/openjdk/jdk/blob/master/src/hotspot/os_cpu/linux_aarch64/os_linux_aarch64.cpp#L412 to your `SpinPause`. We can consider to extract it and to put it in cpu/aarch64, e.g. in https://github.com/openjdk/jdk/blob/master/src/hotspot/cpu/aarch64/spin_wait_aarch64.hpp.
- In [VM_Version::initialize](https://github.com/openjdk/jdk/blob/master/src/hotspot/cpu/aarch64/vm_version_aarch64.cpp#L70), you need to initialize `OnSpinWaitInst` and `OnSpinWaitInstCount` for Apple M CPUs. If you want to use one `yield`,  the code would be:

    if (FLAG_IS_DEFAULT(OnSpinWaitInst)) {
      FLAG_SET_DEFAULT(OnSpinWaitInst, "yield");
    }

    if (FLAG_IS_DEFAULT(OnSpinWaitInstCount)) {
      FLAG_SET_DEFAULT(OnSpinWaitInstCount, 1);
    }

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

PR Comment: https://git.openjdk.org/jdk/pull/16994#issuecomment-1853663036


More information about the hotspot-runtime-dev mailing list