< prev index next >

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

Print this page
rev 58165 : Fix the issue that unslice modifies the argument vector
Summary: Change the name of getElements() to vec() and clone argument value to
avoid it being modified


  40 
  41 // -- This file was mechanically generated: Do not edit! -- //
  42 
  43 @SuppressWarnings("cast")  // warning: redundant cast
  44 final class ByteMaxVector extends ByteVector {
  45     static final ByteSpecies VSPECIES =
  46         (ByteSpecies) ByteVector.SPECIES_MAX;
  47 
  48     static final VectorShape VSHAPE =
  49         VSPECIES.vectorShape();
  50 
  51     static final Class<ByteMaxVector> VCLASS = ByteMaxVector.class;
  52 
  53     static final int VSIZE = VSPECIES.vectorBitSize();
  54 
  55     static final int VLENGTH = VSPECIES.laneCount();
  56 
  57     static final Class<Byte> ETYPE = byte.class;
  58 
  59     // The JVM expects to find the state here.
  60     private final byte[] vec; // Don't access directly, use getElements() instead.
  61 
  62     ByteMaxVector(byte[] v) {
  63         vec = v;
  64     }
  65 
  66     // For compatibility as ByteMaxVector::new,
  67     // stored into species.vectorFactory.
  68     ByteMaxVector(Object v) {
  69         this((byte[]) v);
  70     }
  71 
  72     static final ByteMaxVector ZERO = new ByteMaxVector(new byte[VLENGTH]);
  73     static final ByteMaxVector IOTA = new ByteMaxVector(VSPECIES.iotaArray());
  74 
  75     static {
  76         // Warm up a few species caches.
  77         // If we do this too much we will
  78         // get NPEs from bootstrap circularity.
  79         VSPECIES.dummyVector();
  80         VSPECIES.withLanes(LaneType.BYTE);


 101 
 102     @ForceInline
 103     @Override
 104     public final VectorShape shape() { return VSHAPE; }
 105 
 106     @ForceInline
 107     @Override
 108     public final int length() { return VLENGTH; }
 109 
 110     @ForceInline
 111     @Override
 112     public final int bitSize() { return VSIZE; }
 113 
 114     @ForceInline
 115     @Override
 116     public final int byteSize() { return VSIZE / Byte.SIZE; }
 117 
 118     /*package-private*/
 119     @ForceInline
 120     final @Override
 121     byte[] getElements() {
 122         return VectorIntrinsics.maybeRebox(this).vec;
 123     }
 124 
 125     // Virtualized constructors
 126 
 127     @Override
 128     @ForceInline
 129     public final ByteMaxVector broadcast(byte e) {
 130         return (ByteMaxVector) super.broadcastTemplate(e);  // specialize
 131     }
 132 
 133     @Override
 134     @ForceInline
 135     public final ByteMaxVector broadcast(long e) {
 136         return (ByteMaxVector) super.broadcastTemplate(e);  // specialize
 137     }
 138 
 139     @Override
 140     @ForceInline
 141     ByteMaxMask maskFromArray(boolean[] bits) {


 460 
 461     @Override
 462     @ForceInline
 463     public ByteMaxVector selectFrom(Vector<Byte> v,
 464                                    VectorMask<Byte> m) {
 465         return (ByteMaxVector)
 466             super.selectFromTemplate((ByteMaxVector) v,
 467                                      (ByteMaxMask) m);  // specialize
 468     }
 469 
 470 
 471     @Override
 472     public byte lane(int i) {
 473         if (i < 0 || i >= VLENGTH) {
 474             throw new IllegalArgumentException("Index " + i + " must be zero or positive, and less than " + VLENGTH);
 475         }
 476         return (byte) VectorIntrinsics.extract(
 477                                 VCLASS, ETYPE, VLENGTH,
 478                                 this, i,
 479                                 (vec, ix) -> {
 480                                     byte[] vecarr = vec.getElements();
 481                                     return (long)vecarr[ix];
 482                                 });
 483     }
 484 
 485     @Override
 486     public ByteMaxVector withLane(int i, byte e) {
 487         if (i < 0 || i >= VLENGTH) {
 488             throw new IllegalArgumentException("Index " + i + " must be zero or positive, and less than " + VLENGTH);
 489         }
 490         return VectorIntrinsics.insert(
 491                                 VCLASS, ETYPE, VLENGTH,
 492                                 this, i, (long)e,
 493                                 (v, ix, bits) -> {
 494                                     byte[] res = v.getElements().clone();
 495                                     res[ix] = (byte)bits;
 496                                     return v.vectorFactory(res);
 497                                 });
 498     }
 499 
 500     // Mask
 501 
 502     static final class ByteMaxMask extends AbstractMask<Byte> {
 503 
 504         private final boolean[] bits; // Don't access directly, use getBits() instead.
 505 
 506         public ByteMaxMask(boolean[] bits) {
 507             this(bits, 0);
 508         }
 509 
 510         public ByteMaxMask(boolean[] bits, int offset) {
 511             boolean[] a = new boolean[vspecies().laneCount()];
 512             for (int i = 0; i < a.length; i++) {
 513                 a[i] = bits[offset + i];
 514             }




  40 
  41 // -- This file was mechanically generated: Do not edit! -- //
  42 
  43 @SuppressWarnings("cast")  // warning: redundant cast
  44 final class ByteMaxVector extends ByteVector {
  45     static final ByteSpecies VSPECIES =
  46         (ByteSpecies) ByteVector.SPECIES_MAX;
  47 
  48     static final VectorShape VSHAPE =
  49         VSPECIES.vectorShape();
  50 
  51     static final Class<ByteMaxVector> VCLASS = ByteMaxVector.class;
  52 
  53     static final int VSIZE = VSPECIES.vectorBitSize();
  54 
  55     static final int VLENGTH = VSPECIES.laneCount();
  56 
  57     static final Class<Byte> ETYPE = byte.class;
  58 
  59     // The JVM expects to find the state here.
  60     private final byte[] vec; // Don't access directly, use vec() instead.
  61 
  62     ByteMaxVector(byte[] v) {
  63         vec = v;
  64     }
  65 
  66     // For compatibility as ByteMaxVector::new,
  67     // stored into species.vectorFactory.
  68     ByteMaxVector(Object v) {
  69         this((byte[]) v);
  70     }
  71 
  72     static final ByteMaxVector ZERO = new ByteMaxVector(new byte[VLENGTH]);
  73     static final ByteMaxVector IOTA = new ByteMaxVector(VSPECIES.iotaArray());
  74 
  75     static {
  76         // Warm up a few species caches.
  77         // If we do this too much we will
  78         // get NPEs from bootstrap circularity.
  79         VSPECIES.dummyVector();
  80         VSPECIES.withLanes(LaneType.BYTE);


 101 
 102     @ForceInline
 103     @Override
 104     public final VectorShape shape() { return VSHAPE; }
 105 
 106     @ForceInline
 107     @Override
 108     public final int length() { return VLENGTH; }
 109 
 110     @ForceInline
 111     @Override
 112     public final int bitSize() { return VSIZE; }
 113 
 114     @ForceInline
 115     @Override
 116     public final int byteSize() { return VSIZE / Byte.SIZE; }
 117 
 118     /*package-private*/
 119     @ForceInline
 120     final @Override
 121     byte[] vec() {
 122         return VectorIntrinsics.maybeRebox(this).vec;
 123     }
 124 
 125     // Virtualized constructors
 126 
 127     @Override
 128     @ForceInline
 129     public final ByteMaxVector broadcast(byte e) {
 130         return (ByteMaxVector) super.broadcastTemplate(e);  // specialize
 131     }
 132 
 133     @Override
 134     @ForceInline
 135     public final ByteMaxVector broadcast(long e) {
 136         return (ByteMaxVector) super.broadcastTemplate(e);  // specialize
 137     }
 138 
 139     @Override
 140     @ForceInline
 141     ByteMaxMask maskFromArray(boolean[] bits) {


 460 
 461     @Override
 462     @ForceInline
 463     public ByteMaxVector selectFrom(Vector<Byte> v,
 464                                    VectorMask<Byte> m) {
 465         return (ByteMaxVector)
 466             super.selectFromTemplate((ByteMaxVector) v,
 467                                      (ByteMaxMask) m);  // specialize
 468     }
 469 
 470 
 471     @Override
 472     public byte lane(int i) {
 473         if (i < 0 || i >= VLENGTH) {
 474             throw new IllegalArgumentException("Index " + i + " must be zero or positive, and less than " + VLENGTH);
 475         }
 476         return (byte) VectorIntrinsics.extract(
 477                                 VCLASS, ETYPE, VLENGTH,
 478                                 this, i,
 479                                 (vec, ix) -> {
 480                                     byte[] vecarr = vec.vec();
 481                                     return (long)vecarr[ix];
 482                                 });
 483     }
 484 
 485     @Override
 486     public ByteMaxVector withLane(int i, byte e) {
 487         if (i < 0 || i >= VLENGTH) {
 488             throw new IllegalArgumentException("Index " + i + " must be zero or positive, and less than " + VLENGTH);
 489         }
 490         return VectorIntrinsics.insert(
 491                                 VCLASS, ETYPE, VLENGTH,
 492                                 this, i, (long)e,
 493                                 (v, ix, bits) -> {
 494                                     byte[] res = v.vec().clone();
 495                                     res[ix] = (byte)bits;
 496                                     return v.vectorFactory(res);
 497                                 });
 498     }
 499 
 500     // Mask
 501 
 502     static final class ByteMaxMask extends AbstractMask<Byte> {
 503 
 504         private final boolean[] bits; // Don't access directly, use getBits() instead.
 505 
 506         public ByteMaxMask(boolean[] bits) {
 507             this(bits, 0);
 508         }
 509 
 510         public ByteMaxMask(boolean[] bits, int offset) {
 511             boolean[] a = new boolean[vspecies().laneCount()];
 512             for (int i = 0; i < a.length; i++) {
 513                 a[i] = bits[offset + i];
 514             }


< prev index next >