On Wed, 25 Oct 2023 13:08:06 GMT, Per Minborg <pminb...@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.

src/jdk.incubator.vector/share/classes/jdk/incubator/vector/AbstractVector.java 
line 750:

> 748:     AbstractMemorySegmentImpl requireSegmentConvertibleFor(MemorySegment 
> segment, long offset, int elementByteSize)  {
> 749:         AbstractMemorySegmentImpl ams = (AbstractMemorySegmentImpl) 
> segment;
> 750:         if (ams.maxAlignMask() > 1 && !ams.isAlignedForElement(offset, 
> elementByteSize)) {

I don't think we should only check for maxAlignMask > 1 - you also want to 
check native segments, right?

src/jdk.incubator.vector/share/classes/jdk/incubator/vector/AbstractVector.java 
line 755:

> 753:                     .map(Class::componentType)
> 754:                     .map(Object::toString)
> 755:                     .orElse("?");

orElseThrow?

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

PR Review Comment: https://git.openjdk.org/jdk/pull/16360#discussion_r1371805656
PR Review Comment: https://git.openjdk.org/jdk/pull/16360#discussion_r1371806618

Reply via email to