RFR: 8330161: RISC-V: Don't use C for Labels jumps
Robbin Ehn
rehn at openjdk.org
Mon Apr 15 06:40:41 UTC 2024
On Mon, 15 Apr 2024 01:19:31 GMT, Fei Yang <fyang 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 rarely uses `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.
> 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
Ah, now I understand.
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/18761#discussion_r1565244525
More information about the hotspot-dev
mailing list