RFR: 8318776: Require supports_cx8 to always be true [v5]

Aleksey Shipilev shade at openjdk.org
Wed Nov 22 21:46:09 UTC 2023


On Wed, 22 Nov 2023 18:26:12 GMT, Daniel D. Daugherty <dcubed at openjdk.org> wrote:

>> src/hotspot/cpu/x86/vm_version_x86.cpp line 819:
>> 
>>> 817:   }
>>> 818: 
>>> 819:   _supports_cx8 = supports_cmpxchg8();
>> 
>> I think we should leave the runtime check here (under `ifndef`, like in ARM?). This covers the remaining case of running on legacy x86 without CX8 implemented: the init guarantee would then fire and prevent any other surprises at runtime. Sure, it would be hard to come up with such a platform today, but it would be safer to refuse to run there right away on the off-chance someone actually has it :)
>
> @shipilev - Do you have a particular legacy x86 in mind?

My point is that it is such an easy thing to do: leave the "cx8" flag sensing code in, and keep setting up `_supports_cx8` based on it. This both provides more safety by failing cleanly on non-CX8 platform, and gives other platforms some guidance: if you can check something is supported, check it.

But now that you nerd-sniped me into this... I think non-CX8 platforms would probably predate Pentium. The oldest real machine my lab has is Z530, which already has CX8. But it was easy to also go to my QEMU-driven build-test server, ask for `i486` as platform there, and et voila, no `cx8` in CPU flags:


buildworker-debian12-32:~$ lscpu
Architecture:            i486
  CPU op-mode(s):        32-bit
  Address sizes:         36 bits physical, 32 bits virtual
  Byte Order:            Little Endian
CPU(s):                  4
  On-line CPU(s) list:   0-3
Vendor ID:               GenuineIntel
  Model name:            486 DX/4
    CPU family:          4
    Model:               8
    Thread(s) per core:  4
    Core(s) per socket:  1
    Socket(s):           1
    Stepping:            0
    BogoMIPS:            5699.99
    Flags:               fpu vme pse apic ht cpuid tsc_known_freq x2apic hypervisor cpuid_fault


And mainline JDK even starts there! (with interpreter, there are some asserts firing in compiler code, having to do with odd instruction selection on some paths):


$ jdk/bin/java -Xint -version
openjdk version "22-testing" 2024-03-19
OpenJDK Runtime Environment (fastdebug build 22-testing-builds.shipilev.net-openjdk-jdk-b627-20231121)
OpenJDK Server VM (fastdebug build 22-testing-builds.shipilev.net-openjdk-jdk-b627-20231121, interpreted mode, sharing)

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

PR Review Comment: https://git.openjdk.org/jdk/pull/16625#discussion_r1402738580


More information about the core-libs-dev mailing list