The performance of the `MemorySegment::fil` can be improved by replacing the 
`checkAccess()` method call with calling `checkReadOnly()` instead (as the 
bounds of the segment itself do not need to be checked).

Also, smaller segments can be handled directly by Java code rather than 
transitioning to native code.

Here is how the `MemorySegment::fill` performance is improved by this PR:

![image](https://github.com/user-attachments/assets/92a0bcf2-f5b0-4a91-9c02-39423f870209)

Operations involving 8 or more bytes are delegated to native code whereas 
smaller segments are handled via a switch rake.

It should be noted that `Arena::allocate` is using `MemorySegment::fil`. Hence, 
this PR will also have a positive effect on memory allocation performance.

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

Commit messages:
 - Reduce kick-in size and add test
 - Initial implementation

Changes: https://git.openjdk.org/jdk/pull/20712/files
  Webrev: https://webrevs.openjdk.org/?repo=jdk&pr=20712&range=00
  Issue: https://bugs.openjdk.org/browse/JDK-8338967
  Stats: 235 lines in 3 files changed: 231 ins; 0 del; 4 mod
  Patch: https://git.openjdk.org/jdk/pull/20712.diff
  Fetch: git fetch https://git.openjdk.org/jdk.git pull/20712/head:pull/20712

PR: https://git.openjdk.org/jdk/pull/20712

Reply via email to