RFR: 8304293: RISC-V: JDK-8276799 missed atomic intrinsic support for C1

Feilong Jiang fjiang at openjdk.org
Thu Mar 16 03:53:16 UTC 2023


The following intrinsics in C1 are controlled by supports_atomic_xxx, but they are not set properly on RISC-V:
- _getAndAddInt
- _getAndAddLong
- _getAndSetInt
- _getAndSetLong
- _getAndSetReference

RISC-V provides a set of atomic instructions [1], these intrinsics could be enabled by default.

Here is the HIR output of C1:

before:


B18 (V) [189, 196] -> B20 pred: B8 B17 
empty stack
inlining depth 0
__bci__use__tid____instr____________________________________
  0    0    a251   <instance 0x00000040a802fb98 klass=jdk/internal/misc/Unsafe>
  3    0    a252   null   
  4    0    l254   274954985816L
  7    0    l255   1L
. 8    0    l256   a251.invokespecial(a252, l254, l255)
                   jdk/internal/misc/Unsafe.getAndAddLong(Ljava/lang/Object;JJ)J
. 193  0    l258   a42._24 := l256 (J) tid
. 196  0     259   goto B20


after:


B18 (V) [189, 196] -> B20 pred: B8 B17 
empty stack
inlining depth 0
__bci__use__tid____instr____________________________________
  0    0    a251   <instance 0x00000040a802fb98 klass=jdk/internal/misc/Unsafe>
  3    0    a252   null   
  4    0    l254   274954985816L
  7    0    l255   1L
. 8    0    l256   UnsafeGetAndSet (add)(a252, l254, value l255)
. 193  0    l258   a42._24 := l256 (J) tid
. 196  0     259   goto B20


1. https://github.com/riscv/riscv-isa-manual/blob/8b9047d8d20ef548f7996efee1550760d7bc1279/src/a.tex#L416-L422

Testing:

- [ ] tier1 on Unmatched board (release build)

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

Commit messages:
 - missed atomic intrinsic support for c1

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

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


More information about the hotspot-dev mailing list