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

Reviewed-by: chegar, mcimadamore, psandoz
This commit is contained in:
Per Minborg 2023-11-07 09:46:45 +00:00
parent e1cae72036
commit 74f1889b58
12 changed files with 459 additions and 60 deletions

View file

@ -25,10 +25,16 @@
package jdk.incubator.vector;
import java.lang.foreign.MemorySegment;
import jdk.internal.foreign.AbstractMemorySegmentImpl;
import jdk.internal.foreign.Utils;
import jdk.internal.vm.annotation.ForceInline;
import jdk.internal.vm.vector.VectorSupport;
import java.lang.foreign.ValueLayout;
import java.lang.reflect.Array;
import java.nio.ByteOrder;
import java.util.Objects;
import java.util.function.IntUnaryOperator;
import static jdk.incubator.vector.VectorOperators.*;

View file

@ -2845,7 +2845,7 @@ public abstract class ByteVector extends AbstractVector<Byte> {
*
* @param i the lane index
* @return the lane element at lane index {@code i}
* @throws IllegalArgumentException if the index is is out of range
* @throws IllegalArgumentException if the index is out of range
* ({@code < 0 || >= length()})
*/
public abstract byte lane(int i);
@ -2863,7 +2863,7 @@ public abstract class ByteVector extends AbstractVector<Byte> {
* @param e the value to be placed
* @return the result of replacing the lane element of this vector at lane
* index {@code i} with value {@code e}.
* @throws IllegalArgumentException if the index is is out of range
* @throws IllegalArgumentException if the index is out of range
* ({@code < 0 || >= length()})
*/
public abstract ByteVector withLane(int i, byte e);
@ -3281,8 +3281,6 @@ public abstract class ByteVector extends AbstractVector<Byte> {
* if {@code offset+N*1 < 0}
* or {@code offset+N*1 >= ms.byteSize()}
* for any lane {@code N} in the vector
* @throws IllegalArgumentException if the memory segment is a heap segment that is
* not backed by a {@code byte[]} array.
* @throws IllegalStateException if the memory segment's session is not alive,
* or if access occurs from a thread other than the thread owning the session.
* @since 19
@ -3333,8 +3331,6 @@ public abstract class ByteVector extends AbstractVector<Byte> {
* or {@code offset+N*1 >= ms.byteSize()}
* for any lane {@code N} in the vector
* where the mask is set
* @throws IllegalArgumentException if the memory segment is a heap segment that is
* not backed by a {@code byte[]} array.
* @throws IllegalStateException if the memory segment's session is not alive,
* or if access occurs from a thread other than the thread owning the session.
* @since 19

View file

@ -2659,7 +2659,7 @@ public abstract class DoubleVector extends AbstractVector<Double> {
*
* @param i the lane index
* @return the lane element at lane index {@code i}
* @throws IllegalArgumentException if the index is is out of range
* @throws IllegalArgumentException if the index is out of range
* ({@code < 0 || >= length()})
*/
public abstract double lane(int i);
@ -2677,7 +2677,7 @@ public abstract class DoubleVector extends AbstractVector<Double> {
* @param e the value to be placed
* @return the result of replacing the lane element of this vector at lane
* index {@code i} with value {@code e}.
* @throws IllegalArgumentException if the index is is out of range
* @throws IllegalArgumentException if the index is out of range
* ({@code < 0 || >= length()})
*/
public abstract DoubleVector withLane(int i, double e);
@ -2964,8 +2964,6 @@ public abstract class DoubleVector extends AbstractVector<Double> {
* if {@code offset+N*8 < 0}
* or {@code offset+N*8 >= ms.byteSize()}
* for any lane {@code N} in the vector
* @throws IllegalArgumentException if the memory segment is a heap segment that is
* not backed by a {@code byte[]} array.
* @throws IllegalStateException if the memory segment's session is not alive,
* or if access occurs from a thread other than the thread owning the session.
* @since 19
@ -3021,8 +3019,6 @@ public abstract class DoubleVector extends AbstractVector<Double> {
* or {@code offset+N*8 >= ms.byteSize()}
* for any lane {@code N} in the vector
* where the mask is set
* @throws IllegalArgumentException if the memory segment is a heap segment that is
* not backed by a {@code byte[]} array.
* @throws IllegalStateException if the memory segment's session is not alive,
* or if access occurs from a thread other than the thread owning the session.
* @since 19

View file

@ -2679,7 +2679,7 @@ public abstract class FloatVector extends AbstractVector<Float> {
*
* @param i the lane index
* @return the lane element at lane index {@code i}
* @throws IllegalArgumentException if the index is is out of range
* @throws IllegalArgumentException if the index is out of range
* ({@code < 0 || >= length()})
*/
public abstract float lane(int i);
@ -2697,7 +2697,7 @@ public abstract class FloatVector extends AbstractVector<Float> {
* @param e the value to be placed
* @return the result of replacing the lane element of this vector at lane
* index {@code i} with value {@code e}.
* @throws IllegalArgumentException if the index is is out of range
* @throws IllegalArgumentException if the index is out of range
* ({@code < 0 || >= length()})
*/
public abstract FloatVector withLane(int i, float e);
@ -2970,8 +2970,6 @@ public abstract class FloatVector extends AbstractVector<Float> {
* if {@code offset+N*4 < 0}
* or {@code offset+N*4 >= ms.byteSize()}
* for any lane {@code N} in the vector
* @throws IllegalArgumentException if the memory segment is a heap segment that is
* not backed by a {@code byte[]} array.
* @throws IllegalStateException if the memory segment's session is not alive,
* or if access occurs from a thread other than the thread owning the session.
* @since 19
@ -3027,8 +3025,6 @@ public abstract class FloatVector extends AbstractVector<Float> {
* or {@code offset+N*4 >= ms.byteSize()}
* for any lane {@code N} in the vector
* where the mask is set
* @throws IllegalArgumentException if the memory segment is a heap segment that is
* not backed by a {@code byte[]} array.
* @throws IllegalStateException if the memory segment's session is not alive,
* or if access occurs from a thread other than the thread owning the session.
* @since 19

View file

@ -2830,7 +2830,7 @@ public abstract class IntVector extends AbstractVector<Integer> {
*
* @param i the lane index
* @return the lane element at lane index {@code i}
* @throws IllegalArgumentException if the index is is out of range
* @throws IllegalArgumentException if the index is out of range
* ({@code < 0 || >= length()})
*/
public abstract int lane(int i);
@ -2848,7 +2848,7 @@ public abstract class IntVector extends AbstractVector<Integer> {
* @param e the value to be placed
* @return the result of replacing the lane element of this vector at lane
* index {@code i} with value {@code e}.
* @throws IllegalArgumentException if the index is is out of range
* @throws IllegalArgumentException if the index is out of range
* ({@code < 0 || >= length()})
*/
public abstract IntVector withLane(int i, int e);
@ -3126,8 +3126,6 @@ public abstract class IntVector extends AbstractVector<Integer> {
* if {@code offset+N*4 < 0}
* or {@code offset+N*4 >= ms.byteSize()}
* for any lane {@code N} in the vector
* @throws IllegalArgumentException if the memory segment is a heap segment that is
* not backed by a {@code byte[]} array.
* @throws IllegalStateException if the memory segment's session is not alive,
* or if access occurs from a thread other than the thread owning the session.
* @since 19
@ -3183,8 +3181,6 @@ public abstract class IntVector extends AbstractVector<Integer> {
* or {@code offset+N*4 >= ms.byteSize()}
* for any lane {@code N} in the vector
* where the mask is set
* @throws IllegalArgumentException if the memory segment is a heap segment that is
* not backed by a {@code byte[]} array.
* @throws IllegalStateException if the memory segment's session is not alive,
* or if access occurs from a thread other than the thread owning the session.
* @since 19

View file

@ -2696,7 +2696,7 @@ public abstract class LongVector extends AbstractVector<Long> {
*
* @param i the lane index
* @return the lane element at lane index {@code i}
* @throws IllegalArgumentException if the index is is out of range
* @throws IllegalArgumentException if the index is out of range
* ({@code < 0 || >= length()})
*/
public abstract long lane(int i);
@ -2714,7 +2714,7 @@ public abstract class LongVector extends AbstractVector<Long> {
* @param e the value to be placed
* @return the result of replacing the lane element of this vector at lane
* index {@code i} with value {@code e}.
* @throws IllegalArgumentException if the index is is out of range
* @throws IllegalArgumentException if the index is out of range
* ({@code < 0 || >= length()})
*/
public abstract LongVector withLane(int i, long e);
@ -3005,8 +3005,6 @@ public abstract class LongVector extends AbstractVector<Long> {
* if {@code offset+N*8 < 0}
* or {@code offset+N*8 >= ms.byteSize()}
* for any lane {@code N} in the vector
* @throws IllegalArgumentException if the memory segment is a heap segment that is
* not backed by a {@code byte[]} array.
* @throws IllegalStateException if the memory segment's session is not alive,
* or if access occurs from a thread other than the thread owning the session.
* @since 19
@ -3062,8 +3060,6 @@ public abstract class LongVector extends AbstractVector<Long> {
* or {@code offset+N*8 >= ms.byteSize()}
* for any lane {@code N} in the vector
* where the mask is set
* @throws IllegalArgumentException if the memory segment is a heap segment that is
* not backed by a {@code byte[]} array.
* @throws IllegalStateException if the memory segment's session is not alive,
* or if access occurs from a thread other than the thread owning the session.
* @since 19

View file

@ -2846,7 +2846,7 @@ public abstract class ShortVector extends AbstractVector<Short> {
*
* @param i the lane index
* @return the lane element at lane index {@code i}
* @throws IllegalArgumentException if the index is is out of range
* @throws IllegalArgumentException if the index is out of range
* ({@code < 0 || >= length()})
*/
public abstract short lane(int i);
@ -2864,7 +2864,7 @@ public abstract class ShortVector extends AbstractVector<Short> {
* @param e the value to be placed
* @return the result of replacing the lane element of this vector at lane
* index {@code i} with value {@code e}.
* @throws IllegalArgumentException if the index is is out of range
* @throws IllegalArgumentException if the index is out of range
* ({@code < 0 || >= length()})
*/
public abstract ShortVector withLane(int i, short e);
@ -3275,8 +3275,6 @@ public abstract class ShortVector extends AbstractVector<Short> {
* if {@code offset+N*2 < 0}
* or {@code offset+N*2 >= ms.byteSize()}
* for any lane {@code N} in the vector
* @throws IllegalArgumentException if the memory segment is a heap segment that is
* not backed by a {@code byte[]} array.
* @throws IllegalStateException if the memory segment's session is not alive,
* or if access occurs from a thread other than the thread owning the session.
* @since 19
@ -3332,8 +3330,6 @@ public abstract class ShortVector extends AbstractVector<Short> {
* or {@code offset+N*2 >= ms.byteSize()}
* for any lane {@code N} in the vector
* where the mask is set
* @throws IllegalArgumentException if the memory segment is a heap segment that is
* not backed by a {@code byte[]} array.
* @throws IllegalStateException if the memory segment's session is not alive,
* or if access occurs from a thread other than the thread owning the session.
* @since 19

View file

@ -3358,7 +3358,7 @@ public abstract class $abstractvectortype$ extends AbstractVector<$Boxtype$> {
*
* @param i the lane index
* @return the lane element at lane index {@code i}
* @throws IllegalArgumentException if the index is is out of range
* @throws IllegalArgumentException if the index is out of range
* ({@code < 0 || >= length()})
*/
public abstract $type$ lane(int i);
@ -3376,7 +3376,7 @@ public abstract class $abstractvectortype$ extends AbstractVector<$Boxtype$> {
* @param e the value to be placed
* @return the result of replacing the lane element of this vector at lane
* index {@code i} with value {@code e}.
* @throws IllegalArgumentException if the index is is out of range
* @throws IllegalArgumentException if the index is out of range
* ({@code < 0 || >= length()})
*/
public abstract $abstractvectortype$ withLane(int i, $type$ e);
@ -4077,8 +4077,6 @@ public abstract class $abstractvectortype$ extends AbstractVector<$Boxtype$> {
* if {@code offset+N*$sizeInBytes$ < 0}
* or {@code offset+N*$sizeInBytes$ >= ms.byteSize()}
* for any lane {@code N} in the vector
* @throws IllegalArgumentException if the memory segment is a heap segment that is
* not backed by a {@code byte[]} array.
* @throws IllegalStateException if the memory segment's session is not alive,
* or if access occurs from a thread other than the thread owning the session.
* @since 19
@ -4138,8 +4136,6 @@ public abstract class $abstractvectortype$ extends AbstractVector<$Boxtype$> {
* or {@code offset+N*$sizeInBytes$ >= ms.byteSize()}
* for any lane {@code N} in the vector
* where the mask is set
* @throws IllegalArgumentException if the memory segment is a heap segment that is
* not backed by a {@code byte[]} array.
* @throws IllegalStateException if the memory segment's session is not alive,
* or if access occurs from a thread other than the thread owning the session.
* @since 19