JDK-8310268 : RISC-V: misaligned memory access in String.Compare intrinsic
  • Type: Enhancement
  • Component: hotspot
  • Sub-Component: compiler
  • Affected Version: 21,22
  • Priority: P4
  • Status: Resolved
  • Resolution: Fixed
  • OS: linux
  • CPU: riscv
  • Submitted: 2023-06-18
  • Updated: 2023-10-17
  • Resolved: 2023-07-28
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
JDK 17 JDK 21 JDK 22
17.0.10Fixed 21.0.1Fixed 22 b09Fixed
Description
String.compare intrinsics:
C2_MacroAssembler::string_compare()
generate_compare_long_string_different_encoding()
generate_compare_long_string_same_encoding()

All do misaligned memory access even when -XX:+AvoidUnalignedAccesses
C2_MacroAssembler::string_compare() and generate_compare_long_string_same_encoding() do it only for the tail.


generate_compare_long_string_different_encoding does it for Latin string ( address is 4 b-bytes aligned but no 8-bytes aligned, and reading 8 bytes on every iteration of the loop).

This results in pretty bad results ( in jmh benches) on platforms without hardware misaligned access support ( like hifive unmatched)

Comments
Fix request (17u) As it's mentioned above this fix improves intrinsic performance. The corresponding benchmark results are attached to PR. It's clean backport related only to RISC-V platform. tier1 tests pass.
13-10-2023

A pull request was submitted for review. URL: https://git.openjdk.org/jdk17u-dev/pull/1876 Date: 2023-10-13 21:24:51 +0000
13-10-2023

Fix Request(21u): I would like to backport this to jdk21u. Significantly improves performance of String.Compare intrinsic in some cases. Risc-v only fix. Risc is low. Testing: tier1/2 on hifive unmatched
03-08-2023

A pull request was submitted for review. URL: https://git.openjdk.org/jdk21u/pull/28 Date: 2023-07-31 10:35:43 +0000
31-07-2023

Changeset: d6245b68 Author: Vladimir Kempik <vkempik@openjdk.org> Date: 2023-07-28 21:55:33 +0000 URL: https://git.openjdk.org/jdk/commit/d6245b6832ccd1da04616e8ba4b90321b2551971
28-07-2023

A pull request was submitted for review. URL: https://git.openjdk.org/jdk/pull/14534 Date: 2023-06-19 05:57:05 +0000
19-06-2023