< prev index next >

src/jdk.incubator.vector/share/classes/jdk/incubator/vector/Int64Vector.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


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


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


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




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


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


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


< prev index next >