RFR: 8320397: RISC-V: Avoid passing t0 as temp register to MacroAssembler:: cmpxchg_obj_header/cmpxchgptr

Gui Cao gcao at openjdk.org
Wed Nov 29 12:04:14 UTC 2023


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.

### Testing:
- [x]  Run tier1-3 tests with qemu 8.1.50 (release)
- [x]  Run tier1 tests with SiFive unmatched (release)

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

Commit messages:
 - RISC-V: Avoid passing t0 as temp register to MacroAssembler::cmpxchg/cmpxchgptr

Changes: https://git.openjdk.org/jdk/pull/16880/files
 Webrev: https://webrevs.openjdk.org/?repo=jdk&pr=16880&range=00
  Issue: https://bugs.openjdk.org/browse/JDK-8320397
  Stats: 41 lines in 5 files changed: 0 ins; 4 del; 37 mod
  Patch: https://git.openjdk.org/jdk/pull/16880.diff
  Fetch: git fetch https://git.openjdk.org/jdk.git pull/16880/head:pull/16880

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


More information about the hotspot-dev mailing list