JDK-8301718 : Copy should be using memcpy/memset/memmove for everything bytes or non-atomic
  • Type: Enhancement
  • Component: hotspot
  • Sub-Component: runtime
  • Priority: P4
  • Status: Open
  • Resolution: Unresolved
  • Submitted: 2023-02-02
  • Updated: 2024-01-18
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.
Other
tbdUnresolved
Related Reports
Relates :  
Description
Copy has hand rolled code for lots of platforms. This makes sense when atomicity is required on elements that are not bytes. What doesn't make a whole lot of sense today, maybe it did a decade ago, is the code that uses custom loops for bytes or non-atomic operations instead of calling memcpy, memset, or memmove. Today most compillers treat those as intrinsics, replacing them with optimized code for small sizes when known at compile time otherwise calling libc. Most libc also contain heavily optimized implementations which include specializations for different architecture extensions.

All implementations of Copy that operate on bytes or do not have atomic requirements should probably be updated to use memcpy, memset, or memmove as appropriate.
Comments
Even byte-sized operations may need special treatment for the atomic cases. Remember SPARC BIS, which led to memset_with_concurrent_readers, which really should have been an atomic Copy operation (with appropriate naming for that class). See JDK-8142349. SPARC is no longer supported in mainline. I don't know if there are any similar issues on other platforms.
18-01-2024

You will need to verify this is a performance-neutral change.
03-02-2023