RFR: 8318678: Vector access on heap MemorySegments only works for byte[]
Maurizio Cimadamore
mcimadamore at openjdk.org
Wed Oct 25 14:03:38 UTC 2023
On Wed, 25 Oct 2023 13:08:06 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.
test/jdk/jdk/incubator/vector/AbstractVectorLoadStoreTest.java line 118:
> 116: private static boolean canBeConverted(IntFunction<MemorySegment> function, ValueLayout elementLayout) {
> 117: // Create a sample to analyze
> 118: MemorySegment s = function.apply(Long.BYTES);
I believe that a good way to test this is the following:
* each vector type operates as having a given element layout - for instance, you can imagine the layout for IntVector to be `JAVA_INT` and so forth
* asking whether you load a segment into a vector is the same as asking whether you can access the segment, at offset 0L, with the layout associated with the vector (see above) - that is if MS::get throws, then vector load should also throw (and viceversa)
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/16360#discussion_r1371817499
More information about the core-libs-dev
mailing list