RFR: 8316566: RISC-V: Zero extended narrow oop passed to Atomic::cmpxchg

Robbin Ehn rehn at openjdk.org
Tue Sep 26 11:39:37 UTC 2023


Hi, please consider!

There is bug in gcc < 12 where __synch_synchronize() in some corner-cases don't enforce the compiler barrier.
This causes some code to be placed after the __synch_synchronize(), and in this case causing a word to to be not be sign extended as a collateral issue of the bug.
You can see the 'bad' assembly in JBS, where a branch is moved over the compiler barrier.

Trying to get information from gcc folks.

It seems like either adding a extra compiler barrier, or use  __atomic_thread_fence(__ATOMIC_SEQ_CST) fixes it.

Tested https://bugs.openjdk.org/browse/JDK-8316186 with this fix.
Manually verified assembly, with this fix we generate the same as gcc 12.

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

Commit messages:
 - Use atomic_thread_fence

Changes: https://git.openjdk.org/jdk/pull/15917/files
 Webrev: https://webrevs.openjdk.org/?repo=jdk&pr=15917&range=00
  Issue: https://bugs.openjdk.org/browse/JDK-8316566
  Stats: 1 line in 1 file changed: 0 ins; 0 del; 1 mod
  Patch: https://git.openjdk.org/jdk/pull/15917.diff
  Fetch: git fetch https://git.openjdk.org/jdk.git pull/15917/head:pull/15917

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


More information about the hotspot-runtime-dev mailing list