RFR: 8304293: RISC-V: JDK-8276799 missed atomic intrinsic support for C1
Feilong Jiang
fjiang at openjdk.org
Mon Mar 20 00:52:29 UTC 2023
On Thu, 16 Mar 2023 09:35:10 GMT, Fei Yang <fyang at openjdk.org> wrote:
>> 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:
>>
>> - [x] `hotspot_tier1` & `jdk_tier1` on Unmatched board (release build)
>
> Looks good. Thanks for finding this.
@RealFYang @yhzhu20 -- Thanks!
-------------
PR: https://git.openjdk.org/jdk/pull/13053
More information about the hotspot-dev
mailing list