8271515: Integration of JEP 417: Vector API (Third Incubator)

Co-authored-by: Sandhya Viswanathan <sviswanathan@openjdk.org>
Co-authored-by: Jatin Bhateja <jbhateja@openjdk.org>
Co-authored-by: Ningsheng Jian <njian@openjdk.org>
Co-authored-by: Xiaohong Gong <xgong@openjdk.org>
Co-authored-by: Eric Liu <eliu@openjdk.org>
Co-authored-by: Jie Fu <jiefu@openjdk.org>
Co-authored-by: Vladimir Ivanov <vlivanov@openjdk.org>
Co-authored-by: John R Rose <jrose@openjdk.org>
Co-authored-by: Paul Sandoz <psandoz@openjdk.org>
Co-authored-by: Rado Smogura <mail@smogura.eu>
Reviewed-by: kvn, sviswanathan, ngasson
This commit is contained in:
Paul Sandoz 2021-11-15 21:48:38 +00:00
parent 9326eb1461
commit a59c9b2ac2
104 changed files with 20106 additions and 5976 deletions

View file

@ -353,6 +353,9 @@ public class ScopedMemoryAccess {
static final long BYTE_BUFFER_HB
= UNSAFE.objectFieldOffset(ByteBuffer.class, "hb");
static final long BYTE_BUFFER_IS_READ_ONLY
= UNSAFE.objectFieldOffset(ByteBuffer.class, "isReadOnly");
@ForceInline
static Object bufferBase(ByteBuffer bb) {
return UNSAFE.getReference(bb, BYTE_BUFFER_HB);
@ -373,13 +376,18 @@ public class ScopedMemoryAccess {
}
}
@ForceInline
public static boolean isReadOnly(ByteBuffer bb) {
return UNSAFE.getBoolean(bb, BufferAccess.BYTE_BUFFER_IS_READ_ONLY);
}
@ForceInline
public static
<V extends VectorSupport.Vector<E>, E, S extends VectorSupport.VectorSpecies<E>>
V loadFromByteBuffer(Class<? extends V> vmClass, Class<E> e, int length,
ByteBuffer bb, int offset,
S s,
VectorSupport.LoadOperation<ByteBuffer, V, E, S> defaultImpl) {
VectorSupport.LoadOperation<ByteBuffer, V, S> defaultImpl) {
try {
return loadFromByteBufferScoped(
BufferAccess.scope(bb),
@ -400,14 +408,59 @@ public class ScopedMemoryAccess {
Class<? extends V> vmClass, Class<E> e, int length,
ByteBuffer bb, int offset,
S s,
VectorSupport.LoadOperation<ByteBuffer, V, E, S> defaultImpl) {
VectorSupport.LoadOperation<ByteBuffer, V, S> defaultImpl) {
try {
if (scope != null) {
scope.checkValidState();
}
final byte[] base = (byte[]) BufferAccess.bufferBase(bb);
return VectorSupport.load(vmClass, e, length,
BufferAccess.bufferBase(bb), BufferAccess.bufferAddress(bb, offset),
base, BufferAccess.bufferAddress(bb, offset),
bb, offset, s,
defaultImpl);
} finally {
Reference.reachabilityFence(scope);
}
}
@ForceInline
public static
<V extends VectorSupport.Vector<E>, E, S extends VectorSupport.VectorSpecies<E>,
M extends VectorSupport.VectorMask<E>>
V loadFromByteBufferMasked(Class<? extends V> vmClass, Class<M> maskClass, Class<E> e,
int length, ByteBuffer bb, int offset, M m, S s,
VectorSupport.LoadVectorMaskedOperation<ByteBuffer, V, S, M> defaultImpl) {
try {
return loadFromByteBufferMaskedScoped(
BufferAccess.scope(bb),
vmClass, maskClass, e, length,
bb, offset, m,
s,
defaultImpl);
} catch (ScopedMemoryAccess.Scope.ScopedAccessError ex) {
throw new IllegalStateException("This segment is already closed");
}
}
@Scoped
@ForceInline
private static
<V extends VectorSupport.Vector<E>, E, S extends VectorSupport.VectorSpecies<E>,
M extends VectorSupport.VectorMask<E>>
V loadFromByteBufferMaskedScoped(ScopedMemoryAccess.Scope scope, Class<? extends V> vmClass,
Class<M> maskClass, Class<E> e, int length,
ByteBuffer bb, int offset, M m,
S s,
VectorSupport.LoadVectorMaskedOperation<ByteBuffer, V, S, M> defaultImpl) {
try {
if (scope != null) {
scope.checkValidState();
}
return VectorSupport.loadMasked(vmClass, maskClass, e, length,
BufferAccess.bufferBase(bb), BufferAccess.bufferAddress(bb, offset), m,
bb, offset, s,
defaultImpl);
} finally {
@ -448,9 +501,54 @@ public class ScopedMemoryAccess {
scope.checkValidState();
}
final byte[] base = (byte[]) BufferAccess.bufferBase(bb);
VectorSupport.store(vmClass, e, length,
base, BufferAccess.bufferAddress(bb, offset),
v,
bb, offset,
defaultImpl);
} finally {
Reference.reachabilityFence(scope);
}
}
@ForceInline
public static
<V extends VectorSupport.Vector<E>, E, M extends VectorSupport.VectorMask<E>>
void storeIntoByteBufferMasked(Class<? extends V> vmClass, Class<M> maskClass, Class<E> e,
int length, V v, M m,
ByteBuffer bb, int offset,
VectorSupport.StoreVectorMaskedOperation<ByteBuffer, V, M> defaultImpl) {
try {
storeIntoByteBufferMaskedScoped(
BufferAccess.scope(bb),
vmClass, maskClass, e, length,
v, m,
bb, offset,
defaultImpl);
} catch (ScopedMemoryAccess.Scope.ScopedAccessError ex) {
throw new IllegalStateException("This segment is already closed");
}
}
@Scoped
@ForceInline
private static
<V extends VectorSupport.Vector<E>, E, M extends VectorSupport.VectorMask<E>>
void storeIntoByteBufferMaskedScoped(ScopedMemoryAccess.Scope scope,
Class<? extends V> vmClass, Class<M> maskClass,
Class<E> e, int length, V v, M m,
ByteBuffer bb, int offset,
VectorSupport.StoreVectorMaskedOperation<ByteBuffer, V, M> defaultImpl) {
try {
if (scope != null) {
scope.checkValidState();
}
VectorSupport.storeMasked(vmClass, maskClass, e, length,
BufferAccess.bufferBase(bb), BufferAccess.bufferAddress(bb, offset),
v,
v, m,
bb, offset,
defaultImpl);
} finally {
@ -458,7 +556,6 @@ public class ScopedMemoryAccess {
}
}
// typed-ops here
// Note: all the accessor methods defined below take advantage of argument type profiling

View file

@ -69,10 +69,11 @@ public class VectorSupport {
public static final int VECTOR_OP_MASK_TRUECOUNT = 19;
public static final int VECTOR_OP_MASK_FIRSTTRUE = 20;
public static final int VECTOR_OP_MASK_LASTTRUE = 21;
public static final int VECTOR_OP_MASK_TOLONG = 22;
// Rotate operations
public static final int VECTOR_OP_LROTATE = 22;
public static final int VECTOR_OP_RROTATE = 23;
public static final int VECTOR_OP_LROTATE = 23;
public static final int VECTOR_OP_RROTATE = 24;
// Math routines
public static final int VECTOR_OP_TAN = 101;
@ -156,274 +157,84 @@ public class VectorSupport {
}
/* ============================================================================ */
public interface BroadcastOperation<VM, E, S extends VectorSpecies<E>> {
public interface BroadcastOperation<VM extends VectorPayload,
S extends VectorSpecies<?>> {
VM broadcast(long l, S s);
}
@IntrinsicCandidate
public static
<VM, E, S extends VectorSpecies<E>>
VM broadcastCoerced(Class<? extends VM> vmClass, Class<E> E, int length,
long bits, S s,
BroadcastOperation<VM, E, S> defaultImpl) {
<VM extends VectorPayload,
S extends VectorSpecies<E>,
E>
VM broadcastCoerced(Class<? extends VM> vmClass, Class<E> eClass,
int length,
long bits, S s,
BroadcastOperation<VM, S> defaultImpl) {
assert isNonCapturingLambda(defaultImpl) : defaultImpl;
return defaultImpl.broadcast(bits, s);
}
/* ============================================================================ */
public interface ShuffleIotaOperation<E, S extends VectorSpecies<E>> {
VectorShuffle<E> apply(int length, int start, int step, S s);
public interface ShuffleIotaOperation<S extends VectorSpecies<?>,
SH extends VectorShuffle<?>> {
SH apply(int length, int start, int step, S s);
}
@IntrinsicCandidate
public static
<E, S extends VectorSpecies<E>>
VectorShuffle<E> shuffleIota(Class<?> E, Class<?> ShuffleClass, S s, int length,
int start, int step, int wrap, ShuffleIotaOperation<E, S> defaultImpl) {
<E,
S extends VectorSpecies<E>,
SH extends VectorShuffle<E>>
SH shuffleIota(Class<E> eClass, Class<? extends SH> shClass, S s,
int length,
int start, int step, int wrap,
ShuffleIotaOperation<S, SH> defaultImpl) {
assert isNonCapturingLambda(defaultImpl) : defaultImpl;
return defaultImpl.apply(length, start, step, s);
}
public interface ShuffleToVectorOperation<VM, Sh, E> {
VM apply(Sh s);
public interface ShuffleToVectorOperation<V extends Vector<?>,
SH extends VectorShuffle<?>> {
V apply(SH sh);
}
@IntrinsicCandidate
public static
<VM ,Sh extends VectorShuffle<E>, E>
VM shuffleToVector(Class<?> VM, Class<?>E , Class<?> ShuffleClass, Sh s, int length,
ShuffleToVectorOperation<VM,Sh,E> defaultImpl) {
<V extends Vector<E>,
SH extends VectorShuffle<E>,
E>
V shuffleToVector(Class<? extends Vector<E>> vClass, Class<E> eClass, Class<? extends SH> shClass, SH sh,
int length,
ShuffleToVectorOperation<V, SH> defaultImpl) {
assert isNonCapturingLambda(defaultImpl) : defaultImpl;
return defaultImpl.apply(s);
return defaultImpl.apply(sh);
}
/* ============================================================================ */
public interface IndexOperation<V extends Vector<E>, E, S extends VectorSpecies<E>> {
public interface IndexOperation<V extends Vector<?>,
S extends VectorSpecies<?>> {
V index(V v, int step, S s);
}
//FIXME @IntrinsicCandidate
public static
<V extends Vector<E>, E, S extends VectorSpecies<E>>
V indexVector(Class<? extends V> vClass, Class<E> E, int length,
<V extends Vector<E>,
E,
S extends VectorSpecies<E>>
V indexVector(Class<? extends V> vClass, Class<E> eClass,
int length,
V v, int step, S s,
IndexOperation<V, E, S> defaultImpl) {
IndexOperation<V, S> defaultImpl) {
assert isNonCapturingLambda(defaultImpl) : defaultImpl;
return defaultImpl.index(v, step, s);
}
/* ============================================================================ */
@IntrinsicCandidate
public static
<V extends Vector<?>>
long reductionCoerced(int oprId, Class<?> vectorClass, Class<?> elementType, int length,
V v,
Function<V,Long> defaultImpl) {
assert isNonCapturingLambda(defaultImpl) : defaultImpl;
return defaultImpl.apply(v);
}
/* ============================================================================ */
public interface VecExtractOp<V> {
long apply(V v1, int idx);
}
@IntrinsicCandidate
public static
<V extends Vector<?>>
long extract(Class<?> vectorClass, Class<?> elementType, int vlen,
V vec, int ix,
VecExtractOp<V> defaultImpl) {
assert isNonCapturingLambda(defaultImpl) : defaultImpl;
return defaultImpl.apply(vec, ix);
}
/* ============================================================================ */
public interface VecInsertOp<V> {
V apply(V v1, int idx, long val);
}
@IntrinsicCandidate
public static
<V extends Vector<?>>
V insert(Class<? extends V> vectorClass, Class<?> elementType, int vlen,
V vec, int ix, long val,
VecInsertOp<V> defaultImpl) {
assert isNonCapturingLambda(defaultImpl) : defaultImpl;
return defaultImpl.apply(vec, ix, val);
}
/* ============================================================================ */
@IntrinsicCandidate
public static
<VM>
VM unaryOp(int oprId, Class<? extends VM> vmClass, Class<?> elementType, int length,
VM vm,
Function<VM, VM> defaultImpl) {
assert isNonCapturingLambda(defaultImpl) : defaultImpl;
return defaultImpl.apply(vm);
}
/* ============================================================================ */
@IntrinsicCandidate
public static
<VM>
VM binaryOp(int oprId, Class<? extends VM> vmClass, Class<?> elementType, int length,
VM vm1, VM vm2,
BiFunction<VM, VM, VM> defaultImpl) {
assert isNonCapturingLambda(defaultImpl) : defaultImpl;
return defaultImpl.apply(vm1, vm2);
}
/* ============================================================================ */
public interface TernaryOperation<V> {
V apply(V v1, V v2, V v3);
}
@IntrinsicCandidate
public static
<VM>
VM ternaryOp(int oprId, Class<? extends VM> vmClass, Class<?> elementType, int length,
VM vm1, VM vm2, VM vm3,
TernaryOperation<VM> defaultImpl) {
assert isNonCapturingLambda(defaultImpl) : defaultImpl;
return defaultImpl.apply(vm1, vm2, vm3);
}
/* ============================================================================ */
// Memory operations
public interface LoadOperation<C, V, E, S extends VectorSpecies<E>> {
V load(C container, int index, S s);
}
@IntrinsicCandidate
public static
<C, VM, E, S extends VectorSpecies<E>>
VM load(Class<? extends VM> vmClass, Class<E> E, int length,
Object base, long offset, // Unsafe addressing
C container, int index, S s, // Arguments for default implementation
LoadOperation<C, VM, E, S> defaultImpl) {
assert isNonCapturingLambda(defaultImpl) : defaultImpl;
return defaultImpl.load(container, index, s);
}
/* ============================================================================ */
public interface LoadVectorOperationWithMap<C, V extends Vector<?>, E, S extends VectorSpecies<E>> {
V loadWithMap(C container, int index, int[] indexMap, int indexM, S s);
}
@IntrinsicCandidate
public static
<C, V extends Vector<?>, W extends Vector<Integer>, E, S extends VectorSpecies<E>>
V loadWithMap(Class<?> vectorClass, Class<E> E, int length, Class<?> vectorIndexClass,
Object base, long offset, // Unsafe addressing
W index_vector,
C container, int index, int[] indexMap, int indexM, S s, // Arguments for default implementation
LoadVectorOperationWithMap<C, V, E, S> defaultImpl) {
assert isNonCapturingLambda(defaultImpl) : defaultImpl;
return defaultImpl.loadWithMap(container, index, indexMap, indexM, s);
}
/* ============================================================================ */
public interface StoreVectorOperation<C, V extends Vector<?>> {
void store(C container, int index, V v);
}
@IntrinsicCandidate
public static
<C, V extends Vector<?>>
void store(Class<?> vectorClass, Class<?> elementType, int length,
Object base, long offset, // Unsafe addressing
V v,
C container, int index, // Arguments for default implementation
StoreVectorOperation<C, V> defaultImpl) {
assert isNonCapturingLambda(defaultImpl) : defaultImpl;
defaultImpl.store(container, index, v);
}
/* ============================================================================ */
public interface StoreVectorOperationWithMap<C, V extends Vector<?>> {
void storeWithMap(C container, int index, V v, int[] indexMap, int indexM);
}
@IntrinsicCandidate
public static
<C, V extends Vector<?>, W extends Vector<Integer>>
void storeWithMap(Class<?> vectorClass, Class<?> elementType, int length, Class<?> vectorIndexClass,
Object base, long offset, // Unsafe addressing
W index_vector, V v,
C container, int index, int[] indexMap, int indexM, // Arguments for default implementation
StoreVectorOperationWithMap<C, V> defaultImpl) {
assert isNonCapturingLambda(defaultImpl) : defaultImpl;
defaultImpl.storeWithMap(container, index, v, indexMap, indexM);
}
/* ============================================================================ */
@IntrinsicCandidate
public static
<VM>
boolean test(int cond, Class<?> vmClass, Class<?> elementType, int length,
VM vm1, VM vm2,
BiFunction<VM, VM, Boolean> defaultImpl) {
assert isNonCapturingLambda(defaultImpl) : defaultImpl;
return defaultImpl.apply(vm1, vm2);
}
/* ============================================================================ */
public interface VectorCompareOp<V,M> {
M apply(int cond, V v1, V v2);
}
@IntrinsicCandidate
public static <V extends Vector<E>,
M extends VectorMask<E>,
E>
M compare(int cond, Class<? extends V> vectorClass, Class<M> maskClass, Class<?> elementType, int length,
V v1, V v2,
VectorCompareOp<V,M> defaultImpl) {
assert isNonCapturingLambda(defaultImpl) : defaultImpl;
return defaultImpl.apply(cond, v1, v2);
}
/* ============================================================================ */
public interface VectorRearrangeOp<V extends Vector<E>,
Sh extends VectorShuffle<E>,
E> {
V apply(V v1, Sh shuffle);
}
@IntrinsicCandidate
public static
<V extends Vector<E>,
Sh extends VectorShuffle<E>,
E>
V rearrangeOp(Class<? extends V> vectorClass, Class<Sh> shuffleClass, Class<?> elementType, int vlen,
V v1, Sh sh,
VectorRearrangeOp<V,Sh, E> defaultImpl) {
assert isNonCapturingLambda(defaultImpl) : defaultImpl;
return defaultImpl.apply(v1, sh);
}
/* ============================================================================ */
public interface VectorBlendOp<V extends Vector<E>,
M extends VectorMask<E>,
E> {
V apply(V v1, V v2, M mask);
public interface ReductionOperation<V extends Vector<?>,
M extends VectorMask<?>> {
long apply(V v, M m);
}
@IntrinsicCandidate
@ -431,33 +242,364 @@ public class VectorSupport {
<V extends Vector<E>,
M extends VectorMask<E>,
E>
V blend(Class<? extends V> vectorClass, Class<M> maskClass, Class<?> elementType, int length,
V v1, V v2, M m,
VectorBlendOp<V,M, E> defaultImpl) {
long reductionCoerced(int oprId,
Class<? extends V> vClass, Class<? extends M> mClass, Class<E> eClass,
int length,
V v, M m,
ReductionOperation<V, M> defaultImpl) {
assert isNonCapturingLambda(defaultImpl) : defaultImpl;
return defaultImpl.apply(v, m);
}
/* ============================================================================ */
public interface VecExtractOp<V extends Vector<?>> {
long apply(V v, int i);
}
@IntrinsicCandidate
public static
<V extends Vector<E>,
E>
long extract(Class<? extends V> vClass, Class<E> eClass,
int length,
V v, int i,
VecExtractOp<V> defaultImpl) {
assert isNonCapturingLambda(defaultImpl) : defaultImpl;
return defaultImpl.apply(v, i);
}
/* ============================================================================ */
public interface VecInsertOp<V extends Vector<?>> {
V apply(V v, int i, long val);
}
@IntrinsicCandidate
public static
<V extends Vector<E>,
E>
V insert(Class<? extends V> vClass, Class<E> eClass,
int length,
V v, int i, long val,
VecInsertOp<V> defaultImpl) {
assert isNonCapturingLambda(defaultImpl) : defaultImpl;
return defaultImpl.apply(v, i, val);
}
/* ============================================================================ */
public interface UnaryOperation<V extends Vector<?>,
M extends VectorMask<?>> {
V apply(V v, M m);
}
@IntrinsicCandidate
public static
<V extends Vector<E>,
M extends VectorMask<E>,
E>
V unaryOp(int oprId,
Class<? extends V> vClass, Class<? extends M> mClass, Class<E> eClass,
int length,
V v, M m,
UnaryOperation<V, M> defaultImpl) {
assert isNonCapturingLambda(defaultImpl) : defaultImpl;
return defaultImpl.apply(v, m);
}
/* ============================================================================ */
public interface BinaryOperation<VM extends VectorPayload,
M extends VectorMask<?>> {
VM apply(VM v1, VM v2, M m);
}
@IntrinsicCandidate
public static
<VM extends VectorPayload,
M extends VectorMask<E>,
E>
VM binaryOp(int oprId,
Class<? extends VM> vmClass, Class<? extends M> mClass, Class<E> eClass,
int length,
VM v1, VM v2, M m,
BinaryOperation<VM, M> defaultImpl) {
assert isNonCapturingLambda(defaultImpl) : defaultImpl;
return defaultImpl.apply(v1, v2, m);
}
/* ============================================================================ */
public interface VectorBroadcastIntOp<V extends Vector<?>> {
V apply(V v, int n);
public interface TernaryOperation<V extends Vector<?>,
M extends VectorMask<?>> {
V apply(V v1, V v2, V v3, M m);
}
@IntrinsicCandidate
public static
<V extends Vector<?>>
V broadcastInt(int opr, Class<? extends V> vectorClass, Class<?> elementType, int length,
V v, int n,
VectorBroadcastIntOp<V> defaultImpl) {
<V extends Vector<E>,
M extends VectorMask<E>,
E>
V ternaryOp(int oprId,
Class<? extends V> vClass, Class<? extends M> mClass, Class<E> eClass,
int length,
V v1, V v2, V v3, M m,
TernaryOperation<V, M> defaultImpl) {
assert isNonCapturingLambda(defaultImpl) : defaultImpl;
return defaultImpl.apply(v, n);
return defaultImpl.apply(v1, v2, v3, m);
}
/* ============================================================================ */
public interface VectorConvertOp<VOUT, VIN, S> {
VOUT apply(VIN v, S species);
// Memory operations
public interface LoadOperation<C,
VM extends VectorPayload,
S extends VectorSpecies<?>> {
VM load(C container, int index, S s);
}
@IntrinsicCandidate
public static
<C,
VM extends VectorPayload,
E,
S extends VectorSpecies<E>>
VM load(Class<? extends VM> vmClass, Class<E> eClass,
int length,
Object base, long offset,
C container, int index, S s,
LoadOperation<C, VM, S> defaultImpl) {
assert isNonCapturingLambda(defaultImpl) : defaultImpl;
return defaultImpl.load(container, index, s);
}
/* ============================================================================ */
public interface LoadVectorMaskedOperation<C,
V extends Vector<?>,
S extends VectorSpecies<?>,
M extends VectorMask<?>> {
V load(C container, int index, S s, M m);
}
@IntrinsicCandidate
public static
<C,
V extends Vector<?>,
E,
S extends VectorSpecies<E>,
M extends VectorMask<E>>
V loadMasked(Class<? extends V> vClass, Class<M> mClass, Class<E> eClass,
int length,
Object base, long offset,
M m, C container, int index, S s,
LoadVectorMaskedOperation<C, V, S, M> defaultImpl) {
assert isNonCapturingLambda(defaultImpl) : defaultImpl;
return defaultImpl.load(container, index, s, m);
}
/* ============================================================================ */
public interface LoadVectorOperationWithMap<C,
V extends Vector<?>,
S extends VectorSpecies<?>,
M extends VectorMask<?>> {
V loadWithMap(C container, int index, int[] indexMap, int indexM, S s, M m);
}
@IntrinsicCandidate
public static
<C,
V extends Vector<?>,
W extends Vector<Integer>,
S extends VectorSpecies<E>,
M extends VectorMask<E>,
E>
V loadWithMap(Class<? extends V> vClass, Class<M> mClass, Class<E> eClass,
int length,
Class<? extends Vector<Integer>> vectorIndexClass,
Object base, long offset,
W index_vector,
M m, C container, int index, int[] indexMap, int indexM, S s,
LoadVectorOperationWithMap<C, V, S, M> defaultImpl) {
assert isNonCapturingLambda(defaultImpl) : defaultImpl;
return defaultImpl.loadWithMap(container, index, indexMap, indexM, s, m);
}
/* ============================================================================ */
public interface StoreVectorOperation<C,
V extends Vector<?>> {
void store(C container, int index, V v);
}
@IntrinsicCandidate
public static
<C,
V extends Vector<?>>
void store(Class<?> vClass, Class<?> eClass,
int length,
Object base, long offset,
V v, C container, int index,
StoreVectorOperation<C, V> defaultImpl) {
assert isNonCapturingLambda(defaultImpl) : defaultImpl;
defaultImpl.store(container, index, v);
}
public interface StoreVectorMaskedOperation<C,
V extends Vector<?>,
M extends VectorMask<?>> {
void store(C container, int index, V v, M m);
}
@IntrinsicCandidate
public static
<C,
V extends Vector<E>,
M extends VectorMask<E>,
E>
void storeMasked(Class<? extends V> vClass, Class<M> mClass, Class<E> eClass,
int length,
Object base, long offset,
V v, M m, C container, int index,
StoreVectorMaskedOperation<C, V, M> defaultImpl) {
assert isNonCapturingLambda(defaultImpl) : defaultImpl;
defaultImpl.store(container, index, v, m);
}
/* ============================================================================ */
public interface StoreVectorOperationWithMap<C,
V extends Vector<?>,
M extends VectorMask<?>> {
void storeWithMap(C container, int index, V v, int[] indexMap, int indexM, M m);
}
@IntrinsicCandidate
public static
<C,
V extends Vector<E>,
W extends Vector<Integer>,
M extends VectorMask<E>,
E>
void storeWithMap(Class<? extends V> vClass, Class<M> mClass, Class<E> eClass,
int length,
Class<? extends Vector<Integer>> vectorIndexClass,
Object base, long offset,
W index_vector,
V v, M m, C container, int index, int[] indexMap, int indexM,
StoreVectorOperationWithMap<C, V, M> defaultImpl) {
assert isNonCapturingLambda(defaultImpl) : defaultImpl;
defaultImpl.storeWithMap(container, index, v, indexMap, indexM, m);
}
/* ============================================================================ */
@IntrinsicCandidate
public static
<M extends VectorMask<E>,
E>
boolean test(int cond,
Class<?> mClass, Class<?> eClass,
int length,
M m1, M m2,
BiFunction<M, M, Boolean> defaultImpl) {
assert isNonCapturingLambda(defaultImpl) : defaultImpl;
return defaultImpl.apply(m1, m2);
}
/* ============================================================================ */
public interface VectorCompareOp<V extends Vector<?>,
M extends VectorMask<?>> {
M apply(int cond, V v1, V v2, M m);
}
@IntrinsicCandidate
public static
<V extends Vector<E>,
M extends VectorMask<E>,
E>
M compare(int cond,
Class<? extends V> vectorClass, Class<M> mClass, Class<E> eClass,
int length,
V v1, V v2, M m,
VectorCompareOp<V, M> defaultImpl) {
assert isNonCapturingLambda(defaultImpl) : defaultImpl;
return defaultImpl.apply(cond, v1, v2, m);
}
/* ============================================================================ */
public interface VectorRearrangeOp<V extends Vector<?>,
SH extends VectorShuffle<?>,
M extends VectorMask<?>> {
V apply(V v, SH sh, M m);
}
@IntrinsicCandidate
public static
<V extends Vector<E>,
SH extends VectorShuffle<E>,
M extends VectorMask<E>,
E>
V rearrangeOp(Class<? extends V> vClass, Class<SH> shClass, Class<M> mClass, Class<E> eClass,
int length,
V v, SH sh, M m,
VectorRearrangeOp<V, SH, M> defaultImpl) {
assert isNonCapturingLambda(defaultImpl) : defaultImpl;
return defaultImpl.apply(v, sh, m);
}
/* ============================================================================ */
public interface VectorBlendOp<V extends Vector<?>,
M extends VectorMask<?>> {
V apply(V v1, V v2, M m);
}
@IntrinsicCandidate
public static
<V extends Vector<E>,
M extends VectorMask<E>,
E>
V blend(Class<? extends V> vClass, Class<M> mClass, Class<E> eClass,
int length,
V v1, V v2, M m,
VectorBlendOp<V, M> defaultImpl) {
assert isNonCapturingLambda(defaultImpl) : defaultImpl;
return defaultImpl.apply(v1, v2, m);
}
/* ============================================================================ */
public interface VectorBroadcastIntOp<V extends Vector<?>,
M extends VectorMask<?>> {
V apply(V v, int n, M m);
}
@IntrinsicCandidate
public static
<V extends Vector<E>,
M extends VectorMask<E>,
E>
V broadcastInt(int opr,
Class<? extends V> vClass, Class<? extends M> mClass, Class<E> eClass,
int length,
V v, int n, M m,
VectorBroadcastIntOp<V, M> defaultImpl) {
assert isNonCapturingLambda(defaultImpl) : defaultImpl;
return defaultImpl.apply(v, n, m);
}
/* ============================================================================ */
public interface VectorConvertOp<VOUT extends VectorPayload,
VIN extends VectorPayload,
S extends VectorSpecies<?>> {
VOUT apply(VIN v, S s);
}
// Users of this intrinsic assume that it respects
@ -469,8 +611,8 @@ public class VectorSupport {
VIN extends VectorPayload,
S extends VectorSpecies<?>>
VOUT convert(int oprId,
Class<?> fromVectorClass, Class<?> fromElementType, int fromVLen,
Class<?> toVectorClass, Class<?> toElementType, int toVLen,
Class<?> fromVectorClass, Class<?> fromeClass, int fromVLen,
Class<?> toVectorClass, Class<?> toeClass, int toVLen,
VIN v, S s,
VectorConvertOp<VOUT, VIN, S> defaultImpl) {
assert isNonCapturingLambda(defaultImpl) : defaultImpl;
@ -480,7 +622,9 @@ public class VectorSupport {
/* ============================================================================ */
@IntrinsicCandidate
public static <V> V maybeRebox(V v) {
public static
<VP extends VectorPayload>
VP maybeRebox(VP v) {
// The fence is added here to avoid memory aliasing problems in C2 between scalar & vector accesses.
// TODO: move the fence generation into C2. Generate only when reboxing is taking place.
U.loadFence();
@ -488,15 +632,19 @@ public class VectorSupport {
}
/* ============================================================================ */
public interface VectorMaskOp<M> {
int apply(M m);
public interface VectorMaskOp<M extends VectorMask<?>> {
long apply(M m);
}
@IntrinsicCandidate
public static
<E, M>
int maskReductionCoerced(int oper, Class<? extends M> maskClass, Class<?> elemClass, int length, M m,
VectorMaskOp<M> defaultImpl) {
<M extends VectorMask<E>,
E>
long maskReductionCoerced(int oper,
Class<? extends M> mClass, Class<?> eClass,
int length,
M m,
VectorMaskOp<M> defaultImpl) {
assert isNonCapturingLambda(defaultImpl) : defaultImpl;
return defaultImpl.apply(m);
}