RFR: 8330161: RISC-V: Don't use C for Labels jumps
Fei Yang
fyang at openjdk.org
Mon Apr 15 01:23:49 UTC 2024
On Fri, 12 Apr 2024 13:03:27 GMT, Robbin Ehn <rehn at openjdk.org> wrote:
> Hi please consider!
>
> jal do not have C switch, we always use the full length instructions.
> But jalr have, in case of an unbound Label which is to far for jal we can emit c_jalr.
> When we bind the Label we can't patch the c_jalr.
>
> Sanity tested.
src/hotspot/cpu/riscv/macroAssembler_riscv.cpp line 926:
> 924: assert_different_registers(Rd, temp); \
> 925: /* We can't patch C, i.e. if Label wasn't bound we need to patch this jump.*/ \
> 926: IncompressibleRegion ir(this); \
Seems that we have rare uses of `jal` with unbound label. Here is what I see it.
For unbound label, we set `dest` to pc() at [1]. So the `distance` calculated at [2] will always be zero for this case.
After that we emit a simple `Assembler::jal(Rd, 0);` at [3] which is there for patching. So no `jalr` involved.
I think this means that possible future callers of `jal` with unbound label have to ensure that the target is not far.
[1] https://github.com/openjdk/jdk/blob/master/src/hotspot/cpu/riscv/macroAssembler_riscv.cpp#L947
[2] https://github.com/openjdk/jdk/blob/master/src/hotspot/cpu/riscv/macroAssembler_riscv.cpp#L913
[3] https://github.com/openjdk/jdk/blob/master/src/hotspot/cpu/riscv/macroAssembler_riscv.cpp#L915
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/18761#discussion_r1565034635
More information about the hotspot-dev
mailing list