< prev index next >

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

*** 87,97 **** // and lazy version of C++ templates. // Virtualized getter /*package-private*/ ! abstract long[] getElements(); // Virtualized constructors /** * Build a vector directly using my own constructor. --- 87,97 ---- // and lazy version of C++ templates. // Virtualized getter /*package-private*/ ! abstract long[] vec(); // Virtualized constructors /** * Build a vector directly using my own constructor.
*** 151,161 **** abstract LongVector uOp(FUnOp f); @ForceInline final LongVector uOpTemplate(FUnOp f) { ! long[] vec = getElements(); long[] res = new long[length()]; for (int i = 0; i < res.length; i++) { res[i] = f.apply(i, vec[i]); } return vectorFactory(res); --- 151,161 ---- abstract LongVector uOp(FUnOp f); @ForceInline final LongVector uOpTemplate(FUnOp f) { ! long[] vec = vec(); long[] res = new long[length()]; for (int i = 0; i < res.length; i++) { res[i] = f.apply(i, vec[i]); } return vectorFactory(res);
*** 167,177 **** FUnOp f); @ForceInline final LongVector uOpTemplate(VectorMask<Long> m, FUnOp f) { ! long[] vec = getElements(); long[] res = new long[length()]; boolean[] mbits = ((AbstractMask<Long>)m).getBits(); for (int i = 0; i < res.length; i++) { res[i] = mbits[i] ? f.apply(i, vec[i]) : vec[i]; } --- 167,177 ---- FUnOp f); @ForceInline final LongVector uOpTemplate(VectorMask<Long> m, FUnOp f) { ! long[] vec = vec(); long[] res = new long[length()]; boolean[] mbits = ((AbstractMask<Long>)m).getBits(); for (int i = 0; i < res.length; i++) { res[i] = mbits[i] ? f.apply(i, vec[i]) : vec[i]; }
*** 192,203 **** @ForceInline final LongVector bOpTemplate(Vector<Long> o, FBinOp f) { long[] res = new long[length()]; ! long[] vec1 = this.getElements(); ! long[] vec2 = ((LongVector)o).getElements(); for (int i = 0; i < res.length; i++) { res[i] = f.apply(i, vec1[i], vec2[i]); } return vectorFactory(res); } --- 192,203 ---- @ForceInline final LongVector bOpTemplate(Vector<Long> o, FBinOp f) { long[] res = new long[length()]; ! long[] vec1 = this.vec(); ! long[] vec2 = ((LongVector)o).vec(); for (int i = 0; i < res.length; i++) { res[i] = f.apply(i, vec1[i], vec2[i]); } return vectorFactory(res); }
*** 211,222 **** final LongVector bOpTemplate(Vector<Long> o, VectorMask<Long> m, FBinOp f) { long[] res = new long[length()]; ! long[] vec1 = this.getElements(); ! long[] vec2 = ((LongVector)o).getElements(); boolean[] mbits = ((AbstractMask<Long>)m).getBits(); for (int i = 0; i < res.length; i++) { res[i] = mbits[i] ? f.apply(i, vec1[i], vec2[i]) : vec1[i]; } return vectorFactory(res); --- 211,222 ---- final LongVector bOpTemplate(Vector<Long> o, VectorMask<Long> m, FBinOp f) { long[] res = new long[length()]; ! long[] vec1 = this.vec(); ! long[] vec2 = ((LongVector)o).vec(); boolean[] mbits = ((AbstractMask<Long>)m).getBits(); for (int i = 0; i < res.length; i++) { res[i] = mbits[i] ? f.apply(i, vec1[i], vec2[i]) : vec1[i]; } return vectorFactory(res);
*** 238,250 **** final LongVector tOpTemplate(Vector<Long> o1, Vector<Long> o2, FTriOp f) { long[] res = new long[length()]; ! long[] vec1 = this.getElements(); ! long[] vec2 = ((LongVector)o1).getElements(); ! long[] vec3 = ((LongVector)o2).getElements(); for (int i = 0; i < res.length; i++) { res[i] = f.apply(i, vec1[i], vec2[i], vec3[i]); } return vectorFactory(res); } --- 238,250 ---- final LongVector tOpTemplate(Vector<Long> o1, Vector<Long> o2, FTriOp f) { long[] res = new long[length()]; ! long[] vec1 = this.vec(); ! long[] vec2 = ((LongVector)o1).vec(); ! long[] vec3 = ((LongVector)o2).vec(); for (int i = 0; i < res.length; i++) { res[i] = f.apply(i, vec1[i], vec2[i], vec3[i]); } return vectorFactory(res); }
*** 260,272 **** LongVector tOpTemplate(Vector<Long> o1, Vector<Long> o2, VectorMask<Long> m, FTriOp f) { long[] res = new long[length()]; ! long[] vec1 = this.getElements(); ! long[] vec2 = ((LongVector)o1).getElements(); ! long[] vec3 = ((LongVector)o2).getElements(); boolean[] mbits = ((AbstractMask<Long>)m).getBits(); for (int i = 0; i < res.length; i++) { res[i] = mbits[i] ? f.apply(i, vec1[i], vec2[i], vec3[i]) : vec1[i]; } return vectorFactory(res); --- 260,272 ---- LongVector tOpTemplate(Vector<Long> o1, Vector<Long> o2, VectorMask<Long> m, FTriOp f) { long[] res = new long[length()]; ! long[] vec1 = this.vec(); ! long[] vec2 = ((LongVector)o1).vec(); ! long[] vec3 = ((LongVector)o2).vec(); boolean[] mbits = ((AbstractMask<Long>)m).getBits(); for (int i = 0; i < res.length; i++) { res[i] = mbits[i] ? f.apply(i, vec1[i], vec2[i], vec3[i]) : vec1[i]; } return vectorFactory(res);
*** 278,288 **** abstract long rOp(long v, FBinOp f); @ForceInline final long rOpTemplate(long v, FBinOp f) { ! long[] vec = getElements(); for (int i = 0; i < vec.length; i++) { v = f.apply(i, v, vec[i]); } return v; } --- 278,288 ---- abstract long rOp(long v, FBinOp f); @ForceInline final long rOpTemplate(long v, FBinOp f) { ! long[] vec = vec(); for (int i = 0; i < vec.length; i++) { v = f.apply(i, v, vec[i]); } return v; }
*** 297,307 **** /*package-private*/ @ForceInline final <M> LongVector ldOp(M memory, int offset, FLdOp<M> f) { ! //dummy; no vec = getElements(); long[] res = new long[length()]; for (int i = 0; i < res.length; i++) { res[i] = f.apply(memory, offset, i); } return vectorFactory(res); --- 297,307 ---- /*package-private*/ @ForceInline final <M> LongVector ldOp(M memory, int offset, FLdOp<M> f) { ! //dummy; no vec = vec(); long[] res = new long[length()]; for (int i = 0; i < res.length; i++) { res[i] = f.apply(memory, offset, i); } return vectorFactory(res);
*** 311,321 **** @ForceInline final <M> LongVector ldOp(M memory, int offset, VectorMask<Long> m, FLdOp<M> f) { ! //long[] vec = getElements(); long[] res = new long[length()]; boolean[] mbits = ((AbstractMask<Long>)m).getBits(); for (int i = 0; i < res.length; i++) { if (mbits[i]) { res[i] = f.apply(memory, offset, i); --- 311,321 ---- @ForceInline final <M> LongVector ldOp(M memory, int offset, VectorMask<Long> m, FLdOp<M> f) { ! //long[] vec = vec(); long[] res = new long[length()]; boolean[] mbits = ((AbstractMask<Long>)m).getBits(); for (int i = 0; i < res.length; i++) { if (mbits[i]) { res[i] = f.apply(memory, offset, i);
*** 331,341 **** /*package-private*/ @ForceInline final <M> void stOp(M memory, int offset, FStOp<M> f) { ! long[] vec = getElements(); for (int i = 0; i < vec.length; i++) { f.apply(memory, offset, i, vec[i]); } } --- 331,341 ---- /*package-private*/ @ForceInline final <M> void stOp(M memory, int offset, FStOp<M> f) { ! long[] vec = vec(); for (int i = 0; i < vec.length; i++) { f.apply(memory, offset, i, vec[i]); } }
*** 343,353 **** @ForceInline final <M> void stOp(M memory, int offset, VectorMask<Long> m, FStOp<M> f) { ! long[] vec = getElements(); boolean[] mbits = ((AbstractMask<Long>)m).getBits(); for (int i = 0; i < vec.length; i++) { if (mbits[i]) { f.apply(memory, offset, i, vec[i]); } --- 343,353 ---- @ForceInline final <M> void stOp(M memory, int offset, VectorMask<Long> m, FStOp<M> f) { ! long[] vec = vec(); boolean[] mbits = ((AbstractMask<Long>)m).getBits(); for (int i = 0; i < vec.length; i++) { if (mbits[i]) { f.apply(memory, offset, i, vec[i]); }
*** 365,376 **** @ForceInline final AbstractMask<Long> bTest(int cond, Vector<Long> o, FBinTest f) { ! long[] vec1 = getElements(); ! long[] vec2 = ((LongVector)o).getElements(); boolean[] bits = new boolean[length()]; for (int i = 0; i < length(); i++){ bits[i] = f.apply(cond, i, vec1[i], vec2[i]); } return maskFactory(bits); --- 365,376 ---- @ForceInline final AbstractMask<Long> bTest(int cond, Vector<Long> o, FBinTest f) { ! long[] vec1 = vec(); ! long[] vec2 = ((LongVector)o).vec(); boolean[] bits = new boolean[length()]; for (int i = 0; i < length(); i++){ bits[i] = f.apply(cond, i, vec1[i], vec2[i]); } return maskFactory(bits);
*** 1916,1927 **** final @ForceInline LongVector sliceTemplate(int origin, Vector<Long> v1) { LongVector that = (LongVector) v1; that.check(this); ! long[] a0 = this.getElements(); ! long[] a1 = that.getElements(); long[] res = new long[a0.length]; int vlen = res.length; int firstPart = vlen - origin; System.arraycopy(a0, origin, res, 0, firstPart); System.arraycopy(a1, 0, res, firstPart, origin); --- 1916,1927 ---- final @ForceInline LongVector sliceTemplate(int origin, Vector<Long> v1) { LongVector that = (LongVector) v1; that.check(this); ! long[] a0 = this.vec(); ! long[] a1 = that.vec(); long[] res = new long[a0.length]; int vlen = res.length; int firstPart = vlen - origin; System.arraycopy(a0, origin, res, 0, firstPart); System.arraycopy(a1, 0, res, firstPart, origin);
*** 1959,1970 **** @ForceInline LongVector unsliceTemplate(int origin, Vector<Long> w, int part) { LongVector that = (LongVector) w; that.check(this); ! long[] slice = this.getElements(); ! long[] res = that.getElements(); int vlen = res.length; int firstPart = vlen - origin; switch (part) { case 0: System.arraycopy(slice, 0, res, origin, firstPart); --- 1959,1970 ---- @ForceInline LongVector unsliceTemplate(int origin, Vector<Long> w, int part) { LongVector that = (LongVector) w; that.check(this); ! long[] slice = this.vec(); ! long[] res = that.vec().clone(); int vlen = res.length; int firstPart = vlen - origin; switch (part) { case 0: System.arraycopy(slice, 0, res, origin, firstPart);
< prev index next >