RFR: 8320397: RISC-V: Avoid passing t0 as temp register to MacroAssembler:: cmpxchg_obj_header/cmpxchgptr [v2]
Fei Yang
fyang at openjdk.org
Thu Dec 14 02:55:42 UTC 2023
On Wed, 13 Dec 2023 09:24:58 GMT, Gui Cao <gcao at openjdk.org> wrote:
>> MacroAssembler::cmpxchg/cmpxchgptr/cmpxchg_obj_header is non-trivial on linux-riscv64 platform. Passing t0(aka x5) as temporary register to this functions can also be error prone. As a reserved scratch register, t0 is implicitly clobberred by various assembler functions. @robehn can you help review this PR?
>> This issue is used to track avoid passing t0 as a temporary register in the following cases:
>> 1. avoid passing t0 as temp register to MacroAssembler::cmpxchg/cmpxchgptr/cmpxchg_obj_header.
>> 2. avoid passing t0 as temp register to x_load_barrier and x_load_barrier_slow_path function in x_riscv.ad
>> 3. avoid passing t0 as temp register to z_store_barrier and z_color function in z_riscv.ad
>>
>> Note that I didn't touch MacroAssembler::cmpxchg because it seems to me that this function is designed that it allows t0 to be used as the result register. As the result register will be set on exits, there should be no risk when using t0 for receiving the result.
>> https://github.com/openjdk/jdk/blob/e44d4b24ed794957c47c140ab6f15544efa2b278/src/hotspot/cpu/riscv/macroAssembler_riscv.cpp#L2910-L2925
>>
>> ### Testing:
>> - [x] Run tier1-3 tests on qemu 8.1.50 with UseRVV (release)
>> - [x] Run tier1-3 tests with SiFive unmatched (release)
>
> Gui Cao has updated the pull request incrementally with one additional commit since the last revision:
>
> Add tmpReg to replace the t1 register
src/hotspot/cpu/riscv/gc/x/x_riscv.ad line 78:
> 76: match(Set res (WeakCompareAndSwapP mem (Binary oldval newval)));
> 77: predicate(UseZGC && !ZGenerational && !needs_acquiring_load_reserved(n) && n->as_LoadStore()->barrier_data() == XLoadBarrierStrong);
> 78: effect(KILL cr, TEMP_DEF res, TEMP tmp);
You might want to remove `KILL cr` from `effect` at the same time if `cr` (aka `t1`) is not used anymore after this change.
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/16880#discussion_r1426113364
More information about the hotspot-dev
mailing list