JDK-8318678 : Vector access on heap MemorySegments only works for byte[]
  • Type: Bug
  • Component: core-libs
  • Affected Version: 19,20,21,22
  • Priority: P3
  • Status: Closed
  • Resolution: Fixed
  • Submitted: 2023-10-23
  • Updated: 2024-03-07
  • Resolved: 2023-11-07
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 22
22 b23Fixed
Related Reports
Blocks :  
CSR :  
Relates :  
Description
Vector access of `MemorySegment`s was added in JDK 19. For heap segments access was restricted to `byte[]`. This was a conservative approach, aligning with that of ByteBuffer support.

As a result it is not possible to uniformly use memory segments for vector access, wrapping say a `float[]` in a segment, then accessing using `Vector<Float>`.

The FFM API allows for more general access to heap segments for any primitive array type if the value layout is appropriately unaligned.

We can update the specification and implementation of the vector access of memory segments methods to operate on any heap array for any given species. The species + byte order is a proxy for an unaligned value layout of the species element type with that byte order.
Comments
Changeset: 74f1889b Author: Per Minborg <pminborg@openjdk.org> Date: 2023-11-07 09:46:45 +0000 URL: https://git.openjdk.org/jdk/commit/74f1889b58c6ad1cdc7401e7cbb9f614acf0c171
07-11-2023

We also need to review the intrinsic for load/store found here to ensure, when the hardware supports it, that mixed access is optimized: https://github.com/openjdk/jdk/blob/master/src/hotspot/share/opto/vectorIntrinsics.cpp#L967
26-10-2023

A pull request was submitted for review. URL: https://git.openjdk.org/jdk/pull/16360 Date: 2023-10-25 13:08:06 +0000
25-10-2023

A pull request was submitted for review. URL: https://git.openjdk.org/panama-vector/pull/218 Date: 2023-10-25 12:26:55 +0000
25-10-2023