< prev index next >

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

*** 55,65 **** static final int VLENGTH = VSPECIES.laneCount(); static final Class<Byte> ETYPE = byte.class; // The JVM expects to find the state here. ! private final byte[] vec; // Don't access directly, use getElements() instead. Byte256Vector(byte[] v) { vec = v; } --- 55,65 ---- static final int VLENGTH = VSPECIES.laneCount(); static final Class<Byte> ETYPE = byte.class; // The JVM expects to find the state here. ! private final byte[] vec; // Don't access directly, use vec() instead. Byte256Vector(byte[] v) { vec = v; }
*** 116,126 **** public final int byteSize() { return VSIZE / Byte.SIZE; } /*package-private*/ @ForceInline final @Override ! byte[] getElements() { return VectorIntrinsics.maybeRebox(this).vec; } // Virtualized constructors --- 116,126 ---- public final int byteSize() { return VSIZE / Byte.SIZE; } /*package-private*/ @ForceInline final @Override ! byte[] vec() { return VectorIntrinsics.maybeRebox(this).vec; } // Virtualized constructors
*** 475,485 **** } return (byte) VectorIntrinsics.extract( VCLASS, ETYPE, VLENGTH, this, i, (vec, ix) -> { ! byte[] vecarr = vec.getElements(); return (long)vecarr[ix]; }); } @Override --- 475,485 ---- } return (byte) VectorIntrinsics.extract( VCLASS, ETYPE, VLENGTH, this, i, (vec, ix) -> { ! byte[] vecarr = vec.vec(); return (long)vecarr[ix]; }); } @Override
*** 489,499 **** } return VectorIntrinsics.insert( VCLASS, ETYPE, VLENGTH, this, i, (long)e, (v, ix, bits) -> { ! byte[] res = v.getElements().clone(); res[ix] = (byte)bits; return v.vectorFactory(res); }); } --- 489,499 ---- } return VectorIntrinsics.insert( VCLASS, ETYPE, VLENGTH, this, i, (long)e, (v, ix, bits) -> { ! byte[] res = v.vec().clone(); res[ix] = (byte)bits; return v.vectorFactory(res); }); }
< prev index next >