< prev index next >

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

*** 56,66 **** static final int VLENGTH = VSPECIES.laneCount(); static final Class<Double> ETYPE = double.class; // The JVM expects to find the state here. ! private final double[] vec; // Don't access directly, use getElements() instead. Double128Vector(double[] v) { vec = v; } --- 56,66 ---- static final int VLENGTH = VSPECIES.laneCount(); static final Class<Double> ETYPE = double.class; // The JVM expects to find the state here. ! private final double[] vec; // Don't access directly, use vec() instead. Double128Vector(double[] v) { vec = v; }
*** 117,127 **** public final int byteSize() { return VSIZE / Byte.SIZE; } /*package-private*/ @ForceInline final @Override ! double[] getElements() { return VectorIntrinsics.maybeRebox(this).vec; } // Virtualized constructors --- 117,127 ---- public final int byteSize() { return VSIZE / Byte.SIZE; } /*package-private*/ @ForceInline final @Override ! double[] vec() { return VectorIntrinsics.maybeRebox(this).vec; } // Virtualized constructors
*** 470,480 **** } long bits = (long) VectorIntrinsics.extract( VCLASS, ETYPE, VLENGTH, this, i, (vec, ix) -> { ! double[] vecarr = vec.getElements(); return (long)Double.doubleToLongBits(vecarr[ix]); }); return Double.longBitsToDouble(bits); } --- 470,480 ---- } long bits = (long) VectorIntrinsics.extract( VCLASS, ETYPE, VLENGTH, this, i, (vec, ix) -> { ! double[] vecarr = vec.vec(); return (long)Double.doubleToLongBits(vecarr[ix]); }); return Double.longBitsToDouble(bits); }
*** 485,495 **** } return VectorIntrinsics.insert( VCLASS, ETYPE, VLENGTH, this, i, (long)Double.doubleToLongBits(e), (v, ix, bits) -> { ! double[] res = v.getElements().clone(); res[ix] = Double.longBitsToDouble((long)bits); return v.vectorFactory(res); }); } --- 485,495 ---- } return VectorIntrinsics.insert( VCLASS, ETYPE, VLENGTH, this, i, (long)Double.doubleToLongBits(e), (v, ix, bits) -> { ! double[] res = v.vec().clone(); res[ix] = Double.longBitsToDouble((long)bits); return v.vectorFactory(res); }); }
< prev index next >