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: Closed
  • Resolution: Won't Fix
  • Submitted: 2023-02-02
  • Updated: 2025-06-24
  • Resolved: 2025-06-24
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
Runtime Triage: This is not on our current list of priorities. We will consider this feature if we receive additional customer requirements.
24-06-2025

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