< prev index next >
src/jdk.incubator.vector/share/classes/jdk/incubator/vector/ShortVector.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 short[] getElements();
// Virtualized constructors
/**
* Build a vector directly using my own constructor.
--- 87,97 ----
// and lazy version of C++ templates.
// Virtualized getter
/*package-private*/
! abstract short[] vec();
// Virtualized constructors
/**
* Build a vector directly using my own constructor.
*** 151,161 ****
abstract
ShortVector uOp(FUnOp f);
@ForceInline
final
ShortVector uOpTemplate(FUnOp f) {
! short[] vec = getElements();
short[] res = new short[length()];
for (int i = 0; i < res.length; i++) {
res[i] = f.apply(i, vec[i]);
}
return vectorFactory(res);
--- 151,161 ----
abstract
ShortVector uOp(FUnOp f);
@ForceInline
final
ShortVector uOpTemplate(FUnOp f) {
! short[] vec = vec();
short[] res = new short[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
ShortVector uOpTemplate(VectorMask<Short> m,
FUnOp f) {
! short[] vec = getElements();
short[] res = new short[length()];
boolean[] mbits = ((AbstractMask<Short>)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
ShortVector uOpTemplate(VectorMask<Short> m,
FUnOp f) {
! short[] vec = vec();
short[] res = new short[length()];
boolean[] mbits = ((AbstractMask<Short>)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
ShortVector bOpTemplate(Vector<Short> o,
FBinOp f) {
short[] res = new short[length()];
! short[] vec1 = this.getElements();
! short[] vec2 = ((ShortVector)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
ShortVector bOpTemplate(Vector<Short> o,
FBinOp f) {
short[] res = new short[length()];
! short[] vec1 = this.vec();
! short[] vec2 = ((ShortVector)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
ShortVector bOpTemplate(Vector<Short> o,
VectorMask<Short> m,
FBinOp f) {
short[] res = new short[length()];
! short[] vec1 = this.getElements();
! short[] vec2 = ((ShortVector)o).getElements();
boolean[] mbits = ((AbstractMask<Short>)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
ShortVector bOpTemplate(Vector<Short> o,
VectorMask<Short> m,
FBinOp f) {
short[] res = new short[length()];
! short[] vec1 = this.vec();
! short[] vec2 = ((ShortVector)o).vec();
boolean[] mbits = ((AbstractMask<Short>)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
ShortVector tOpTemplate(Vector<Short> o1,
Vector<Short> o2,
FTriOp f) {
short[] res = new short[length()];
! short[] vec1 = this.getElements();
! short[] vec2 = ((ShortVector)o1).getElements();
! short[] vec3 = ((ShortVector)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
ShortVector tOpTemplate(Vector<Short> o1,
Vector<Short> o2,
FTriOp f) {
short[] res = new short[length()];
! short[] vec1 = this.vec();
! short[] vec2 = ((ShortVector)o1).vec();
! short[] vec3 = ((ShortVector)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 ****
ShortVector tOpTemplate(Vector<Short> o1,
Vector<Short> o2,
VectorMask<Short> m,
FTriOp f) {
short[] res = new short[length()];
! short[] vec1 = this.getElements();
! short[] vec2 = ((ShortVector)o1).getElements();
! short[] vec3 = ((ShortVector)o2).getElements();
boolean[] mbits = ((AbstractMask<Short>)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 ----
ShortVector tOpTemplate(Vector<Short> o1,
Vector<Short> o2,
VectorMask<Short> m,
FTriOp f) {
short[] res = new short[length()];
! short[] vec1 = this.vec();
! short[] vec2 = ((ShortVector)o1).vec();
! short[] vec3 = ((ShortVector)o2).vec();
boolean[] mbits = ((AbstractMask<Short>)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
short rOp(short v, FBinOp f);
@ForceInline
final
short rOpTemplate(short v, FBinOp f) {
! short[] vec = getElements();
for (int i = 0; i < vec.length; i++) {
v = f.apply(i, v, vec[i]);
}
return v;
}
--- 278,288 ----
abstract
short rOp(short v, FBinOp f);
@ForceInline
final
short rOpTemplate(short v, FBinOp f) {
! short[] 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> ShortVector ldOp(M memory, int offset,
FLdOp<M> f) {
! //dummy; no vec = getElements();
short[] res = new short[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> ShortVector ldOp(M memory, int offset,
FLdOp<M> f) {
! //dummy; no vec = vec();
short[] res = new short[length()];
for (int i = 0; i < res.length; i++) {
res[i] = f.apply(memory, offset, i);
}
return vectorFactory(res);
*** 311,321 ****
@ForceInline
final
<M> ShortVector ldOp(M memory, int offset,
VectorMask<Short> m,
FLdOp<M> f) {
! //short[] vec = getElements();
short[] res = new short[length()];
boolean[] mbits = ((AbstractMask<Short>)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> ShortVector ldOp(M memory, int offset,
VectorMask<Short> m,
FLdOp<M> f) {
! //short[] vec = vec();
short[] res = new short[length()];
boolean[] mbits = ((AbstractMask<Short>)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) {
! short[] 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) {
! short[] 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<Short> m,
FStOp<M> f) {
! short[] vec = getElements();
boolean[] mbits = ((AbstractMask<Short>)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<Short> m,
FStOp<M> f) {
! short[] vec = vec();
boolean[] mbits = ((AbstractMask<Short>)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<Short> bTest(int cond,
Vector<Short> o,
FBinTest f) {
! short[] vec1 = getElements();
! short[] vec2 = ((ShortVector)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<Short> bTest(int cond,
Vector<Short> o,
FBinTest f) {
! short[] vec1 = vec();
! short[] vec2 = ((ShortVector)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);
*** 2045,2056 ****
final
@ForceInline
ShortVector sliceTemplate(int origin, Vector<Short> v1) {
ShortVector that = (ShortVector) v1;
that.check(this);
! short[] a0 = this.getElements();
! short[] a1 = that.getElements();
short[] res = new short[a0.length];
int vlen = res.length;
int firstPart = vlen - origin;
System.arraycopy(a0, origin, res, 0, firstPart);
System.arraycopy(a1, 0, res, firstPart, origin);
--- 2045,2056 ----
final
@ForceInline
ShortVector sliceTemplate(int origin, Vector<Short> v1) {
ShortVector that = (ShortVector) v1;
that.check(this);
! short[] a0 = this.vec();
! short[] a1 = that.vec();
short[] res = new short[a0.length];
int vlen = res.length;
int firstPart = vlen - origin;
System.arraycopy(a0, origin, res, 0, firstPart);
System.arraycopy(a1, 0, res, firstPart, origin);
*** 2088,2099 ****
@ForceInline
ShortVector
unsliceTemplate(int origin, Vector<Short> w, int part) {
ShortVector that = (ShortVector) w;
that.check(this);
! short[] slice = this.getElements();
! short[] res = that.getElements();
int vlen = res.length;
int firstPart = vlen - origin;
switch (part) {
case 0:
System.arraycopy(slice, 0, res, origin, firstPart);
--- 2088,2099 ----
@ForceInline
ShortVector
unsliceTemplate(int origin, Vector<Short> w, int part) {
ShortVector that = (ShortVector) w;
that.check(this);
! short[] slice = this.vec();
! short[] 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 >