< prev index next >

src/jdk.incubator.vector/share/classes/jdk/incubator/vector/Short64Vector.java

Print this page
rev 55589 : 8221816: [vector] IndexOutOfBoundsException for fromArray/intoArray with unset mask lanes
Reviewed-by: duke


 820     @ForceInline
 821     public Shuffle<Short> toShuffle() {
 822         short[] a = toArray();
 823         int[] sa = new int[a.length];
 824         for (int i = 0; i < a.length; i++) {
 825             sa[i] = (int) a[i];
 826         }
 827         return ShortVector.shuffleFromArray(SPECIES, sa, 0);
 828     }
 829 
 830     // Memory operations
 831 
 832     private static final int ARRAY_SHIFT         = 31 - Integer.numberOfLeadingZeros(Unsafe.ARRAY_SHORT_INDEX_SCALE);
 833     private static final int BOOLEAN_ARRAY_SHIFT = 31 - Integer.numberOfLeadingZeros(Unsafe.ARRAY_BOOLEAN_INDEX_SCALE);
 834 
 835     @Override
 836     @ForceInline
 837     public void intoArray(short[] a, int ix) {
 838         Objects.requireNonNull(a);
 839         ix = VectorIntrinsics.checkIndex(ix, a.length, LENGTH);





 840         VectorIntrinsics.store(Short64Vector.class, short.class, LENGTH,
 841                                a, (((long) ix) << ARRAY_SHIFT) + Unsafe.ARRAY_SHORT_BASE_OFFSET,
 842                                this,
 843                                a, ix,
 844                                (arr, idx, v) -> v.forEach((i, e) -> arr[idx + i] = e));
 845     }
 846 
 847     @Override
 848     @ForceInline
 849     public final void intoArray(short[] a, int ax, Mask<Short> m) {
 850         ShortVector oldVal = ShortVector.fromArray(SPECIES, a, ax);


 851         ShortVector newVal = oldVal.blend(this, m);
 852         newVal.intoArray(a, ax);



 853     }
 854 
 855     @Override
 856     @ForceInline
 857     public void intoByteArray(byte[] a, int ix) {
 858         Objects.requireNonNull(a);
 859         ix = VectorIntrinsics.checkIndex(ix, a.length, bitSize() / Byte.SIZE);
 860         VectorIntrinsics.store(Short64Vector.class, short.class, LENGTH,
 861                                a, ((long) ix) + Unsafe.ARRAY_BYTE_BASE_OFFSET,
 862                                this,
 863                                a, ix,
 864                                (c, idx, v) -> {
 865                                    ByteBuffer bbc = ByteBuffer.wrap(c, idx, c.length - idx).order(ByteOrder.nativeOrder());
 866                                    ShortBuffer tb = bbc.asShortBuffer();
 867                                    v.forEach((i, e) -> tb.put(e));
 868                                });
 869     }
 870 
 871     @Override
 872     @ForceInline




 820     @ForceInline
 821     public Shuffle<Short> toShuffle() {
 822         short[] a = toArray();
 823         int[] sa = new int[a.length];
 824         for (int i = 0; i < a.length; i++) {
 825             sa[i] = (int) a[i];
 826         }
 827         return ShortVector.shuffleFromArray(SPECIES, sa, 0);
 828     }
 829 
 830     // Memory operations
 831 
 832     private static final int ARRAY_SHIFT         = 31 - Integer.numberOfLeadingZeros(Unsafe.ARRAY_SHORT_INDEX_SCALE);
 833     private static final int BOOLEAN_ARRAY_SHIFT = 31 - Integer.numberOfLeadingZeros(Unsafe.ARRAY_BOOLEAN_INDEX_SCALE);
 834 
 835     @Override
 836     @ForceInline
 837     public void intoArray(short[] a, int ix) {
 838         Objects.requireNonNull(a);
 839         ix = VectorIntrinsics.checkIndex(ix, a.length, LENGTH);
 840         intoArrayWithoutCheck(a, ix);
 841     }
 842 
 843     @ForceInline
 844     private void intoArrayWithoutCheck(short[] a, int ix) {
 845         VectorIntrinsics.store(Short64Vector.class, short.class, LENGTH,
 846                                a, (((long) ix) << ARRAY_SHIFT) + Unsafe.ARRAY_SHORT_BASE_OFFSET,
 847                                this,
 848                                a, ix,
 849                                (arr, idx, v) -> v.forEach((i, e) -> arr[idx + i] = e));
 850     }
 851 
 852     @Override
 853     @ForceInline
 854     public final void intoArray(short[] a, int ax, Mask<Short> m) {
 855         Objects.requireNonNull(a);
 856         if (ax + LENGTH <= a.length) {
 857             ShortVector oldVal = ShortVector.fromArrayWithoutCheck(SPECIES, a, ax);
 858             ShortVector newVal = oldVal.blend(this, m);
 859             ((Short64Vector)newVal).intoArrayWithoutCheck(a, ax);
 860         } else {
 861             forEach(m, (i, e) -> a[ax + i] = e);
 862         }
 863     }
 864 
 865     @Override
 866     @ForceInline
 867     public void intoByteArray(byte[] a, int ix) {
 868         Objects.requireNonNull(a);
 869         ix = VectorIntrinsics.checkIndex(ix, a.length, bitSize() / Byte.SIZE);
 870         VectorIntrinsics.store(Short64Vector.class, short.class, LENGTH,
 871                                a, ((long) ix) + Unsafe.ARRAY_BYTE_BASE_OFFSET,
 872                                this,
 873                                a, ix,
 874                                (c, idx, v) -> {
 875                                    ByteBuffer bbc = ByteBuffer.wrap(c, idx, c.length - idx).order(ByteOrder.nativeOrder());
 876                                    ShortBuffer tb = bbc.asShortBuffer();
 877                                    v.forEach((i, e) -> tb.put(e));
 878                                });
 879     }
 880 
 881     @Override
 882     @ForceInline


< prev index next >