RFR: 8318678: Vector access on heap MemorySegments only works for byte[] [v2]

Maurizio Cimadamore mcimadamore at openjdk.org
Thu Oct 26 16:18:32 UTC 2023


On Thu, 26 Oct 2023 09:17:25 GMT, Per Minborg <pminborg at openjdk.org> wrote:

>> This PR proposes removing the restriction that only heap `MemorySegment` wrapping a `byte` array can be accessed by Vectors. Now any array type can be used provided the element alignment constraints are respected.
>
> Per Minborg has updated the pull request incrementally with one additional commit since the last revision:
> 
>   Allow unaligned array access

Marked as reviewed by mcimadamore (Reviewer).

On a second look, I agree with the comments. Logically, the vector API is accessing elements using `JAVA_XYZ_UNALIGNED` layouts, which should _always_ succeed. E.g. no alignment exception should ever be possible when doing unaligned access, regardless of whether the segment is on/off heap.

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

PR Review: https://git.openjdk.org/jdk/pull/16360#pullrequestreview-1700040222
PR Comment: https://git.openjdk.org/jdk/pull/16360#issuecomment-1781433386


More information about the core-libs-dev mailing list