< prev index next >

src/jdk.incubator.vector/share/classes/jdk/incubator/vector/X-Vector.java.template

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

*** 93,103 **** // and lazy version of C++ templates. // Virtualized getter /*package-private*/ ! abstract $type$[] getElements(); // Virtualized constructors /** * Build a vector directly using my own constructor. --- 93,103 ---- // and lazy version of C++ templates. // Virtualized getter /*package-private*/ ! abstract $type$[] vec(); // Virtualized constructors /** * Build a vector directly using my own constructor.
*** 157,167 **** abstract $abstractvectortype$ uOp(FUnOp f); @ForceInline final $abstractvectortype$ uOpTemplate(FUnOp f) { ! $type$[] vec = getElements(); $type$[] res = new $type$[length()]; for (int i = 0; i < res.length; i++) { res[i] = f.apply(i, vec[i]); } return vectorFactory(res); --- 157,167 ---- abstract $abstractvectortype$ uOp(FUnOp f); @ForceInline final $abstractvectortype$ uOpTemplate(FUnOp f) { ! $type$[] vec = vec(); $type$[] res = new $type$[length()]; for (int i = 0; i < res.length; i++) { res[i] = f.apply(i, vec[i]); } return vectorFactory(res);
*** 173,183 **** FUnOp f); @ForceInline final $abstractvectortype$ uOpTemplate(VectorMask<$Boxtype$> m, FUnOp f) { ! $type$[] vec = getElements(); $type$[] res = new $type$[length()]; boolean[] mbits = ((AbstractMask<$Boxtype$>)m).getBits(); for (int i = 0; i < res.length; i++) { res[i] = mbits[i] ? f.apply(i, vec[i]) : vec[i]; } --- 173,183 ---- FUnOp f); @ForceInline final $abstractvectortype$ uOpTemplate(VectorMask<$Boxtype$> m, FUnOp f) { ! $type$[] vec = vec(); $type$[] res = new $type$[length()]; boolean[] mbits = ((AbstractMask<$Boxtype$>)m).getBits(); for (int i = 0; i < res.length; i++) { res[i] = mbits[i] ? f.apply(i, vec[i]) : vec[i]; }
*** 198,209 **** @ForceInline final $abstractvectortype$ bOpTemplate(Vector<$Boxtype$> o, FBinOp f) { $type$[] res = new $type$[length()]; ! $type$[] vec1 = this.getElements(); ! $type$[] vec2 = (($abstractvectortype$)o).getElements(); for (int i = 0; i < res.length; i++) { res[i] = f.apply(i, vec1[i], vec2[i]); } return vectorFactory(res); } --- 198,209 ---- @ForceInline final $abstractvectortype$ bOpTemplate(Vector<$Boxtype$> o, FBinOp f) { $type$[] res = new $type$[length()]; ! $type$[] vec1 = this.vec(); ! $type$[] vec2 = (($abstractvectortype$)o).vec(); for (int i = 0; i < res.length; i++) { res[i] = f.apply(i, vec1[i], vec2[i]); } return vectorFactory(res); }
*** 217,228 **** final $abstractvectortype$ bOpTemplate(Vector<$Boxtype$> o, VectorMask<$Boxtype$> m, FBinOp f) { $type$[] res = new $type$[length()]; ! $type$[] vec1 = this.getElements(); ! $type$[] vec2 = (($abstractvectortype$)o).getElements(); boolean[] mbits = ((AbstractMask<$Boxtype$>)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); --- 217,228 ---- final $abstractvectortype$ bOpTemplate(Vector<$Boxtype$> o, VectorMask<$Boxtype$> m, FBinOp f) { $type$[] res = new $type$[length()]; ! $type$[] vec1 = this.vec(); ! $type$[] vec2 = (($abstractvectortype$)o).vec(); boolean[] mbits = ((AbstractMask<$Boxtype$>)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);
*** 244,256 **** final $abstractvectortype$ tOpTemplate(Vector<$Boxtype$> o1, Vector<$Boxtype$> o2, FTriOp f) { $type$[] res = new $type$[length()]; ! $type$[] vec1 = this.getElements(); ! $type$[] vec2 = (($abstractvectortype$)o1).getElements(); ! $type$[] vec3 = (($abstractvectortype$)o2).getElements(); for (int i = 0; i < res.length; i++) { res[i] = f.apply(i, vec1[i], vec2[i], vec3[i]); } return vectorFactory(res); } --- 244,256 ---- final $abstractvectortype$ tOpTemplate(Vector<$Boxtype$> o1, Vector<$Boxtype$> o2, FTriOp f) { $type$[] res = new $type$[length()]; ! $type$[] vec1 = this.vec(); ! $type$[] vec2 = (($abstractvectortype$)o1).vec(); ! $type$[] vec3 = (($abstractvectortype$)o2).vec(); for (int i = 0; i < res.length; i++) { res[i] = f.apply(i, vec1[i], vec2[i], vec3[i]); } return vectorFactory(res); }
*** 266,278 **** $abstractvectortype$ tOpTemplate(Vector<$Boxtype$> o1, Vector<$Boxtype$> o2, VectorMask<$Boxtype$> m, FTriOp f) { $type$[] res = new $type$[length()]; ! $type$[] vec1 = this.getElements(); ! $type$[] vec2 = (($abstractvectortype$)o1).getElements(); ! $type$[] vec3 = (($abstractvectortype$)o2).getElements(); boolean[] mbits = ((AbstractMask<$Boxtype$>)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); --- 266,278 ---- $abstractvectortype$ tOpTemplate(Vector<$Boxtype$> o1, Vector<$Boxtype$> o2, VectorMask<$Boxtype$> m, FTriOp f) { $type$[] res = new $type$[length()]; ! $type$[] vec1 = this.vec(); ! $type$[] vec2 = (($abstractvectortype$)o1).vec(); ! $type$[] vec3 = (($abstractvectortype$)o2).vec(); boolean[] mbits = ((AbstractMask<$Boxtype$>)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);
*** 284,294 **** abstract $type$ rOp($type$ v, FBinOp f); @ForceInline final $type$ rOpTemplate($type$ v, FBinOp f) { ! $type$[] vec = getElements(); for (int i = 0; i < vec.length; i++) { v = f.apply(i, v, vec[i]); } return v; } --- 284,294 ---- abstract $type$ rOp($type$ v, FBinOp f); @ForceInline final $type$ rOpTemplate($type$ v, FBinOp f) { ! $type$[] vec = vec(); for (int i = 0; i < vec.length; i++) { v = f.apply(i, v, vec[i]); } return v; }
*** 303,313 **** /*package-private*/ @ForceInline final <M> $abstractvectortype$ ldOp(M memory, int offset, FLdOp<M> f) { ! //dummy; no vec = getElements(); $type$[] res = new $type$[length()]; for (int i = 0; i < res.length; i++) { res[i] = f.apply(memory, offset, i); } return vectorFactory(res); --- 303,313 ---- /*package-private*/ @ForceInline final <M> $abstractvectortype$ ldOp(M memory, int offset, FLdOp<M> f) { ! //dummy; no vec = vec(); $type$[] res = new $type$[length()]; for (int i = 0; i < res.length; i++) { res[i] = f.apply(memory, offset, i); } return vectorFactory(res);
*** 317,327 **** @ForceInline final <M> $abstractvectortype$ ldOp(M memory, int offset, VectorMask<$Boxtype$> m, FLdOp<M> f) { ! //$type$[] vec = getElements(); $type$[] res = new $type$[length()]; boolean[] mbits = ((AbstractMask<$Boxtype$>)m).getBits(); for (int i = 0; i < res.length; i++) { if (mbits[i]) { res[i] = f.apply(memory, offset, i); --- 317,327 ---- @ForceInline final <M> $abstractvectortype$ ldOp(M memory, int offset, VectorMask<$Boxtype$> m, FLdOp<M> f) { ! //$type$[] vec = vec(); $type$[] res = new $type$[length()]; boolean[] mbits = ((AbstractMask<$Boxtype$>)m).getBits(); for (int i = 0; i < res.length; i++) { if (mbits[i]) { res[i] = f.apply(memory, offset, i);
*** 337,347 **** /*package-private*/ @ForceInline final <M> void stOp(M memory, int offset, FStOp<M> f) { ! $type$[] vec = getElements(); for (int i = 0; i < vec.length; i++) { f.apply(memory, offset, i, vec[i]); } } --- 337,347 ---- /*package-private*/ @ForceInline final <M> void stOp(M memory, int offset, FStOp<M> f) { ! $type$[] vec = vec(); for (int i = 0; i < vec.length; i++) { f.apply(memory, offset, i, vec[i]); } }
*** 349,359 **** @ForceInline final <M> void stOp(M memory, int offset, VectorMask<$Boxtype$> m, FStOp<M> f) { ! $type$[] vec = getElements(); boolean[] mbits = ((AbstractMask<$Boxtype$>)m).getBits(); for (int i = 0; i < vec.length; i++) { if (mbits[i]) { f.apply(memory, offset, i, vec[i]); } --- 349,359 ---- @ForceInline final <M> void stOp(M memory, int offset, VectorMask<$Boxtype$> m, FStOp<M> f) { ! $type$[] vec = vec(); boolean[] mbits = ((AbstractMask<$Boxtype$>)m).getBits(); for (int i = 0; i < vec.length; i++) { if (mbits[i]) { f.apply(memory, offset, i, vec[i]); }
*** 371,382 **** @ForceInline final AbstractMask<$Boxtype$> bTest(int cond, Vector<$Boxtype$> o, FBinTest f) { ! $type$[] vec1 = getElements(); ! $type$[] vec2 = (($abstractvectortype$)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); --- 371,382 ---- @ForceInline final AbstractMask<$Boxtype$> bTest(int cond, Vector<$Boxtype$> o, FBinTest f) { ! $type$[] vec1 = vec(); ! $type$[] vec2 = (($abstractvectortype$)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);
*** 2303,2314 **** final @ForceInline $abstractvectortype$ sliceTemplate(int origin, Vector<$Boxtype$> v1) { $abstractvectortype$ that = ($abstractvectortype$) v1; that.check(this); ! $type$[] a0 = this.getElements(); ! $type$[] a1 = that.getElements(); $type$[] res = new $type$[a0.length]; int vlen = res.length; int firstPart = vlen - origin; System.arraycopy(a0, origin, res, 0, firstPart); System.arraycopy(a1, 0, res, firstPart, origin); --- 2303,2314 ---- final @ForceInline $abstractvectortype$ sliceTemplate(int origin, Vector<$Boxtype$> v1) { $abstractvectortype$ that = ($abstractvectortype$) v1; that.check(this); ! $type$[] a0 = this.vec(); ! $type$[] a1 = that.vec(); $type$[] res = new $type$[a0.length]; int vlen = res.length; int firstPart = vlen - origin; System.arraycopy(a0, origin, res, 0, firstPart); System.arraycopy(a1, 0, res, firstPart, origin);
*** 2346,2357 **** @ForceInline $abstractvectortype$ unsliceTemplate(int origin, Vector<$Boxtype$> w, int part) { $abstractvectortype$ that = ($abstractvectortype$) w; that.check(this); ! $type$[] slice = this.getElements(); ! $type$[] res = that.getElements(); int vlen = res.length; int firstPart = vlen - origin; switch (part) { case 0: System.arraycopy(slice, 0, res, origin, firstPart); --- 2346,2357 ---- @ForceInline $abstractvectortype$ unsliceTemplate(int origin, Vector<$Boxtype$> w, int part) { $abstractvectortype$ that = ($abstractvectortype$) w; that.check(this); ! $type$[] slice = this.vec(); ! $type$[] 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 >