RFR: 8369207: _Copy_conjoint_{jshorts,jints,jlongs}_atomic on Linux/BSD AArch64 do not prevent tearing

Justin King jcking at openjdk.org
Mon Oct 6 14:26:27 UTC 2025


Ensure the compiler cannot optimize the copy loops by replacing them with `memcpy` which is allowed to copy byte by byte potentially introducing tearing. Currently there is nothing preventing the compiler from doing this. We add `volatile` which prevents the compiler from making this optimization in the future.

Currently the code generates to `ldp` and `stp`, this change does have the side affect of forcing it to do `ldr` and `str`. If that seems unacceptable from a performance standpoint we can hand-roll assembly to do `ldp` and `stp`.

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

Commit messages:
 - JDK-8369207: _Copy_conjoint_{jshorts,jints,jlongs}_atomic on Linux/BSD AArch64 do not prevent tearing

Changes: https://git.openjdk.org/jdk/pull/27647/files
  Webrev: https://webrevs.openjdk.org/?repo=jdk&pr=27647&range=00
  Issue: https://bugs.openjdk.org/browse/JDK-8369207
  Stats: 20 lines in 2 files changed: 0 ins; 8 del; 12 mod
  Patch: https://git.openjdk.org/jdk/pull/27647.diff
  Fetch: git fetch https://git.openjdk.org/jdk.git pull/27647/head:pull/27647

PR: https://git.openjdk.org/jdk/pull/27647


More information about the hotspot-runtime-dev mailing list