RFR: 8350095: RISC-V: Refactor string_compare [v6]

Hamlin Li mli at openjdk.org
Wed Feb 26 09:58:59 UTC 2025


On Wed, 26 Feb 2025 00:27:23 GMT, Fei Yang <fyang at openjdk.org> wrote:

>> Previously, we have a `TAIL` label at [1], seems when it get here, it could also exceed the boundary of the string?
>> But seems to me exceeding the boundary should be fine, as we can not exceed the page boundary in this way.
>> [1] https://github.com/openjdk/jdk/blob/master/src/hotspot/cpu/riscv/c2_MacroAssembler_riscv.cpp#L1550
>
>> Previously, we have a `TAIL` label at [1], seems when it get here, it could also exceed the boundary of the string?
> 
> No, it won't. The sub instruction at [1][2][3] will ensure that. Let me know if you have a case that will.
> 
> [1] https://github.com/openjdk/jdk/blob/master/src/hotspot/cpu/riscv/c2_MacroAssembler_riscv.cpp#L1478
> [2] https://github.com/openjdk/jdk/blob/master/src/hotspot/cpu/riscv/c2_MacroAssembler_riscv.cpp#L1492
> [3] https://github.com/openjdk/jdk/blob/master/src/hotspot/cpu/riscv/c2_MacroAssembler_riscv.cpp#L1506
> 
>> But seems to me exceeding the boundary should be fine, as we can not exceed the page boundary in this way. [1] https://github.com/openjdk/jdk/blob/master/src/hotspot/cpu/riscv/c2_MacroAssembler_riscv.cpp#L1550
> 
> But the loaded 64-bit values are compared later at L1435. So I think it will make a difference here.

Consider the code reaches [bltz(cnt2, NEXT_WORD);](https://github.com/openjdk/jdk/blob/master/src/hotspot/cpu/riscv/c2_MacroAssembler_riscv.cpp#L1549), and go to the next line [bind(TAIL);](https://github.com/openjdk/jdk/blob/master/src/hotspot/cpu/riscv/c2_MacroAssembler_riscv.cpp#L1550), the remaining chars/bytes in the string could be 1~7, but we will load 8 or 16 bytes anyway.

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

PR Review Comment: https://git.openjdk.org/jdk/pull/23633#discussion_r1971285704


More information about the hotspot-compiler-dev mailing list