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