RFR: 8309502: RISC-V: String.indexOf intrinsic may produce misaligned memory loads

Fei Yang fyang at openjdk.org
Wed Jun 7 07:56:59 UTC 2023


On Wed, 7 Jun 2023 07:41:15 GMT, Vladimir Kempik <vkempik at openjdk.org> wrote:

> > Hi, I searched and found that we have four direct callers of `C2_MacroAssembler::string_indexof_linearscan`: three in file riscv.ad (by string_indexof_conUU, string_indexof_conLL and string_indexof_conUL) and one by `C2_MacroAssembler::string_indexof`. Did you check which one is triggering these unaligned accesses? I am not sure but it looks to me that the three direct callers in file riscv.ad are less likely to have such an issue. If that is true, we might need some distinugish among those callers for better performance.
> 
> Originally, when I found this misaligned load, this code `(this->*load_2chr)(ch2, Address(tmp3), noreg);` was corresponding to `lhu t1, 0(t4)`. So I can say the isLL variable was true.

Can we simply change the two conditions `if (AvoidUnalignedAccesses) {` added in `C2_MacroAssembler::string_indexof_linearscan` into something like `if (needle_con_cnt == -1 && AvoidUnalignedAccesses) {` and see if this could also resolve the problem?

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

PR Comment: https://git.openjdk.org/jdk/pull/14320#issuecomment-1580129550


More information about the hotspot-compiler-dev mailing list