Bug 1042244: Remove return template parameter in SIMD operators; r=nmatsakis
authorBenjamin Bouvier <benj@benj.me>
Mon, 28 Jul 2014 19:27:42 +0200
changeset 196360 d9da1ffcb4436cb0e6de246438780575d7cf0423
parent 196359 8c3377385452e92c3f0260a15c6ac7203fb187e2
child 196361 b55fe8353becf47b89a565acbfd788fe3a28db3a
push id46862
push userbenj@benj.me
push dateMon, 28 Jul 2014 17:28:27 +0000
treeherdermozilla-inbound@ba89f7ce6ff2 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersnmatsakis
bugs1042244
milestone34.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1042244: Remove return template parameter in SIMD operators; r=nmatsakis
js/src/builtin/SIMD.cpp
js/src/builtin/SIMD.h
--- a/js/src/builtin/SIMD.cpp
+++ b/js/src/builtin/SIMD.cpp
@@ -431,63 +431,63 @@ js::Create(JSContext *cx, typename V::El
     memcpy(resultMem, data, sizeof(Elem) * V::lanes);
     return result;
 }
 
 template JSObject *js::Create<Float32x4>(JSContext *cx, Float32x4::Elem *data);
 template JSObject *js::Create<Int32x4>(JSContext *cx, Int32x4::Elem *data);
 
 namespace js {
-template<typename T, typename V>
+template<typename T>
 struct Abs {
-    static inline T apply(T x, T zero) { return V::toType(x < 0 ? -1 * x : x); }
+    static inline T apply(T x, T zero) { return x < 0 ? -1 * x : x; }
 };
-template<typename T, typename V>
+template<typename T>
 struct Neg {
-    static inline T apply(T x, T zero) { return V::toType(-1 * x); }
+    static inline T apply(T x, T zero) { return -1 * x; }
 };
-template<typename T, typename V>
+template<typename T>
 struct Not {
-    static inline T apply(T x, T zero) { return V::toType(~x); }
+    static inline T apply(T x, T zero) { return ~x; }
 };
-template<typename T, typename V>
+template<typename T>
 struct Rec {
-    static inline T apply(T x, T zero) { return V::toType(1 / x); }
+    static inline T apply(T x, T zero) { return 1 / x; }
 };
-template<typename T, typename V>
+template<typename T>
 struct RecSqrt {
-    static inline T apply(T x, T zero) { return V::toType(1 / sqrt(x)); }
+    static inline T apply(T x, T zero) { return 1 / sqrt(x); }
 };
-template<typename T, typename V>
+template<typename T>
 struct Sqrt {
-    static inline T apply(T x, T zero) { return V::toType(sqrt(x)); }
+    static inline T apply(T x, T zero) { return sqrt(x); }
 };
-template<typename T, typename V>
+template<typename T>
 struct Add {
-    static inline T apply(T l, T r) { return V::toType(l + r); }
+    static inline T apply(T l, T r) { return l + r; }
 };
-template<typename T, typename V>
+template<typename T>
 struct Sub {
-    static inline T apply(T l, T r) { return V::toType(l - r); }
+    static inline T apply(T l, T r) { return l - r; }
 };
-template<typename T, typename V>
+template<typename T>
 struct Div {
-    static inline T apply(T l, T r) { return V::toType(l / r); }
+    static inline T apply(T l, T r) { return l / r; }
 };
-template<typename T, typename V>
+template<typename T>
 struct Mul {
-    static inline T apply(T l, T r) { return V::toType(l * r); }
+    static inline T apply(T l, T r) { return l * r; }
 };
-template<typename T, typename V>
+template<typename T>
 struct Minimum {
-    static inline T apply(T l, T r) { return V::toType(l < r ? l : r); }
+    static inline T apply(T l, T r) { return l < r ? l : r; }
 };
-template<typename T, typename V>
+template<typename T>
 struct Maximum {
-    static inline T apply(T l, T r) { return V::toType(l > r ? l : r); }
+    static inline T apply(T l, T r) { return l > r ? l : r; }
 };
 template<typename T>
 struct LessThan {
     static inline int32_t apply(T l, T r) { return l < r ? 0xFFFFFFFF : 0x0; }
 };
 template<typename T>
 struct LessThanOrEqual {
     static inline int32_t apply(T l, T r) { return l <= r ? 0xFFFFFFFF : 0x0; }
@@ -503,63 +503,63 @@ struct GreaterThanOrEqual {
 template<typename T>
 struct Equal {
     static inline int32_t apply(T l, T r) { return l == r ? 0xFFFFFFFF : 0x0; }
 };
 template<typename T>
 struct NotEqual {
     static inline int32_t apply(T l, T r) { return l != r ? 0xFFFFFFFF : 0x0; }
 };
-template<typename T, typename V>
+template<typename T>
 struct Xor {
-    static inline T apply(T l, T r) { return V::toType(l ^ r); }
+    static inline T apply(T l, T r) { return l ^ r; }
 };
-template<typename T, typename V>
+template<typename T>
 struct And {
-    static inline T apply(T l, T r) { return V::toType(l & r); }
+    static inline T apply(T l, T r) { return l & r; }
 };
-template<typename T, typename V>
+template<typename T>
 struct Or {
-    static inline T apply(T l, T r) { return V::toType(l | r); }
+    static inline T apply(T l, T r) { return l | r; }
 };
-template<typename T, typename V>
+template<typename T>
 struct Scale {
-    static inline T apply(int32_t lane, T scalar, T x) { return V::toType(scalar * x); }
+    static inline T apply(int32_t lane, T scalar, T x) { return scalar * x; }
 };
-template<typename T, typename V>
+template<typename T>
 struct WithX {
-    static inline T apply(int32_t lane, T scalar, T x) { return V::toType(lane == 0 ? scalar : x); }
+    static inline T apply(int32_t lane, T scalar, T x) { return lane == 0 ? scalar : x; }
 };
-template<typename T, typename V>
+template<typename T>
 struct WithY {
-    static inline T apply(int32_t lane, T scalar, T x) { return V::toType(lane == 1 ? scalar : x); }
+    static inline T apply(int32_t lane, T scalar, T x) { return lane == 1 ? scalar : x; }
 };
-template<typename T, typename V>
+template<typename T>
 struct WithZ {
-    static inline T apply(int32_t lane, T scalar, T x) { return V::toType(lane == 2 ? scalar : x); }
+    static inline T apply(int32_t lane, T scalar, T x) { return lane == 2 ? scalar : x; }
 };
-template<typename T, typename V>
+template<typename T>
 struct WithW {
-    static inline T apply(int32_t lane, T scalar, T x) { return V::toType(lane == 3 ? scalar : x); }
+    static inline T apply(int32_t lane, T scalar, T x) { return lane == 3 ? scalar : x; }
 };
-template<typename T, typename V>
+template<typename T>
 struct WithFlagX {
-    static inline T apply(T l, T f, T x) { return V::toType(l == 0 ? (f ? 0xFFFFFFFF : 0x0) : x); }
+    static inline T apply(T l, T f, T x) { return l == 0 ? (f ? 0xFFFFFFFF : 0x0) : x; }
 };
-template<typename T, typename V>
+template<typename T>
 struct WithFlagY {
-    static inline T apply(T l, T f, T x) { return V::toType(l == 1 ? (f ? 0xFFFFFFFF : 0x0) : x); }
+    static inline T apply(T l, T f, T x) { return l == 1 ? (f ? 0xFFFFFFFF : 0x0) : x; }
 };
-template<typename T, typename V>
+template<typename T>
 struct WithFlagZ {
-    static inline T apply(T l, T f, T x) { return V::toType(l == 2 ? (f ? 0xFFFFFFFF : 0x0) : x); }
+    static inline T apply(T l, T f, T x) { return l == 2 ? (f ? 0xFFFFFFFF : 0x0) : x; }
 };
-template<typename T, typename V>
+template<typename T>
 struct WithFlagW {
-    static inline T apply(T l, T f, T x) { return V::toType(l == 3 ? (f ? 0xFFFFFFFF : 0x0) : x); }
+    static inline T apply(T l, T f, T x) { return l == 3 ? (f ? 0xFFFFFFFF : 0x0) : x; }
 };
 template<typename T, typename V>
 struct Shuffle {
     static inline int32_t apply(int32_t l, int32_t mask) { return V::toType((mask >> l) & 0x3); }
 };
 struct ShiftLeft {
     static inline int32_t apply(int32_t v, int32_t bits) { return v << bits; }
 };
@@ -895,25 +895,25 @@ Int32x4Select(JSContext *cx, unsigned ar
     }
 
     int32_t *val = TypedObjectMemory<int32_t *>(args[0]);
     int32_t *tv = TypedObjectMemory<int32_t *>(args[1]);
     int32_t *fv = TypedObjectMemory<int32_t *>(args[2]);
 
     int32_t tr[Int32x4::lanes];
     for (unsigned i = 0; i < Int32x4::lanes; i++)
-        tr[i] = And<int32_t, Int32x4>::apply(val[i], tv[i]);
+        tr[i] = And<int32_t>::apply(val[i], tv[i]);
 
     int32_t fr[Int32x4::lanes];
     for (unsigned i = 0; i < Int32x4::lanes; i++)
-        fr[i] = And<int32_t, Int32x4>::apply(Not<int32_t, Int32x4>::apply(val[i], 0), fv[i]);
+        fr[i] = And<int32_t>::apply(Not<int32_t>::apply(val[i], 0), fv[i]);
 
     int32_t orInt[Int32x4::lanes];
     for (unsigned i = 0; i < Int32x4::lanes; i++)
-        orInt[i] = Or<int32_t, Int32x4>::apply(tr[i], fr[i]);
+        orInt[i] = Or<int32_t>::apply(tr[i], fr[i]);
 
     float *result = reinterpret_cast<float *>(orInt);
     RootedObject obj(cx, Create<Float32x4>(cx, result));
     if (!obj)
         return false;
 
     args.rval().setObject(*obj);
     return true;
--- a/js/src/builtin/SIMD.h
+++ b/js/src/builtin/SIMD.h
@@ -17,91 +17,91 @@
  * Spec matching polyfill:
  * https://github.com/johnmccutchan/ecmascript_simd/blob/master/src/ecmascript_simd.js
  */
 
 #define FLOAT32X4_NULLARY_FUNCTION_LIST(V)                                                               \
   V(zero, (FuncZero<Float32x4>), 0, 0, Zero)
 
 #define FLOAT32X4_UNARY_FUNCTION_LIST(V)                                                                 \
-  V(abs, (Func<Float32x4, Abs<float, Float32x4>, Float32x4>), 1, 0, Abs)                                 \
+  V(abs, (Func<Float32x4, Abs<float>, Float32x4>), 1, 0, Abs)                                            \
   V(fromInt32x4Bits, (FuncConvertBits<Int32x4, Float32x4>), 1, 0, FromInt32x4Bits)                       \
-  V(neg, (Func<Float32x4, Neg<float, Float32x4>, Float32x4>), 1, 0, Neg)                                 \
-  V(not, (CoercedFunc<Float32x4, Int32x4, Not<int32_t, Int32x4>, Float32x4>), 1, 0, Not)                 \
-  V(reciprocal, (Func<Float32x4, Rec<float, Float32x4>, Float32x4>), 1, 0, Reciprocal)                   \
-  V(reciprocalSqrt, (Func<Float32x4, RecSqrt<float, Float32x4>, Float32x4>), 1, 0, ReciprocalSqrt)       \
+  V(neg, (Func<Float32x4, Neg<float>, Float32x4>), 1, 0, Neg)                                            \
+  V(not, (CoercedFunc<Float32x4, Int32x4, Not<int32_t>, Float32x4>), 1, 0, Not)                          \
+  V(reciprocal, (Func<Float32x4, Rec<float>, Float32x4>), 1, 0, Reciprocal)                              \
+  V(reciprocalSqrt, (Func<Float32x4, RecSqrt<float>, Float32x4>), 1, 0, ReciprocalSqrt)                  \
   V(splat, (FuncSplat<Float32x4>), 1, 0, Splat)                                                          \
-  V(sqrt, (Func<Float32x4, Sqrt<float, Float32x4>, Float32x4>), 1, 0, Sqrt)                              \
+  V(sqrt, (Func<Float32x4, Sqrt<float>, Float32x4>), 1, 0, Sqrt)                                         \
   V(fromInt32x4, (FuncConvert<Int32x4, Float32x4> ), 1, 0, FromInt32x4)
 
 #define FLOAT32X4_BINARY_FUNCTION_LIST(V)                                                                \
-  V(add, (Func<Float32x4, Add<float, Float32x4>, Float32x4>), 2, 0, Add)                                 \
-  V(and, (CoercedFunc<Float32x4, Int32x4, And<int32_t, Int32x4>, Float32x4>), 2, 0, And)                 \
-  V(div, (Func<Float32x4, Div<float, Float32x4>, Float32x4>), 2, 0, Div)                                 \
+  V(add, (Func<Float32x4, Add<float>, Float32x4>), 2, 0, Add)                                            \
+  V(and, (CoercedFunc<Float32x4, Int32x4, And<int32_t>, Float32x4>), 2, 0, And)                          \
+  V(div, (Func<Float32x4, Div<float>, Float32x4>), 2, 0, Div)                                            \
   V(equal, (Func<Float32x4, Equal<float>, Int32x4>), 2, 0, Equal)                                        \
   V(greaterThan, (Func<Float32x4, GreaterThan<float>, Int32x4>), 2, 0, GreaterThan)                      \
   V(greaterThanOrEqual, (Func<Float32x4, GreaterThanOrEqual<float>, Int32x4>), 2, 0, GreaterThanOrEqual) \
   V(lessThan, (Func<Float32x4, LessThan<float>, Int32x4>), 2, 0, LessThan)                               \
   V(lessThanOrEqual, (Func<Float32x4, LessThanOrEqual<float>, Int32x4>), 2, 0, LessThanOrEqual)          \
-  V(max, (Func<Float32x4, Maximum<float, Float32x4>, Float32x4>), 2, 0, Max)                             \
-  V(min, (Func<Float32x4, Minimum<float, Float32x4>, Float32x4>), 2, 0, Min)                             \
-  V(mul, (Func<Float32x4, Mul<float, Float32x4>, Float32x4>), 2, 0, Mul)                                 \
+  V(max, (Func<Float32x4, Maximum<float>, Float32x4>), 2, 0, Max)                                        \
+  V(min, (Func<Float32x4, Minimum<float>, Float32x4>), 2, 0, Min)                                        \
+  V(mul, (Func<Float32x4, Mul<float>, Float32x4>), 2, 0, Mul)                                            \
   V(notEqual, (Func<Float32x4, NotEqual<float>, Int32x4>), 2, 0, NotEqual)                               \
-  V(or, (CoercedFunc<Float32x4, Int32x4, Or<int32_t, Int32x4>, Float32x4>), 2, 0, Or)                    \
   V(shuffle, (FuncShuffle<Float32x4, Shuffle<float, Float32x4>, Float32x4>), 2, 0, Shuffle)              \
-  V(scale, (FuncWith<Float32x4, Scale<float, Float32x4>, Float32x4>), 2, 0, Scale)                       \
-  V(sub, (Func<Float32x4, Sub<float, Float32x4>, Float32x4>), 2, 0, Sub)                                 \
-  V(withX, (FuncWith<Float32x4, WithX<float, Float32x4>, Float32x4>), 2, 0, WithX)                       \
-  V(withY, (FuncWith<Float32x4, WithY<float, Float32x4>, Float32x4>), 2, 0, WithY)                       \
-  V(withZ, (FuncWith<Float32x4, WithZ<float, Float32x4>, Float32x4>), 2, 0, WithZ)                       \
-  V(withW, (FuncWith<Float32x4, WithW<float, Float32x4>, Float32x4>), 2, 0, WithW)                       \
-  V(xor, (CoercedFunc<Float32x4, Int32x4, Xor<int32_t, Int32x4>, Float32x4>), 2, 0, Xor)
+  V(or, (CoercedFunc<Float32x4, Int32x4, Or<int32_t>, Float32x4>), 2, 0, Or)                             \
+  V(scale, (FuncWith<Float32x4, Scale<float>, Float32x4>), 2, 0, Scale)                                  \
+  V(sub, (Func<Float32x4, Sub<float>, Float32x4>), 2, 0, Sub)                                            \
+  V(withX, (FuncWith<Float32x4, WithX<float>, Float32x4>), 2, 0, WithX)                                  \
+  V(withY, (FuncWith<Float32x4, WithY<float>, Float32x4>), 2, 0, WithY)                                  \
+  V(withZ, (FuncWith<Float32x4, WithZ<float>, Float32x4>), 2, 0, WithZ)                                  \
+  V(withW, (FuncWith<Float32x4, WithW<float>, Float32x4>), 2, 0, WithW)                                  \
+  V(xor, (CoercedFunc<Float32x4, Int32x4, Xor<int32_t>, Float32x4>), 2, 0, Xor)
 
 #define FLOAT32X4_TERNARY_FUNCTION_LIST(V)                                                               \
   V(clamp, Float32x4Clamp, 3, 0, Clamp)                                                                  \
   V(shuffleMix, (FuncShuffle<Float32x4, Shuffle<float, Float32x4>, Float32x4>), 3, 0, ShuffleMix)
 
 #define FLOAT32X4_FUNCTION_LIST(V)                                                                       \
   FLOAT32X4_NULLARY_FUNCTION_LIST(V)                                                                     \
   FLOAT32X4_UNARY_FUNCTION_LIST(V)                                                                       \
   FLOAT32X4_BINARY_FUNCTION_LIST(V)                                                                      \
   FLOAT32X4_TERNARY_FUNCTION_LIST(V)
 
 #define INT32X4_NULLARY_FUNCTION_LIST(V)                                                                 \
   V(zero, (FuncZero<Int32x4>), 0, 0, Zero)
 
 #define INT32X4_UNARY_FUNCTION_LIST(V)                                                                   \
   V(fromFloat32x4Bits, (FuncConvertBits<Float32x4, Int32x4>), 1, 0, FromFloat32x4Bits)                   \
-  V(neg, (Func<Int32x4, Neg<int32_t, Int32x4>, Int32x4>), 1, 0, Neg)                                     \
-  V(not, (Func<Int32x4, Not<int32_t, Int32x4>, Int32x4>), 1, 0, Not)                                     \
+  V(neg, (Func<Int32x4, Neg<int32_t>, Int32x4>), 1, 0, Neg)                                              \
+  V(not, (Func<Int32x4, Not<int32_t>, Int32x4>), 1, 0, Not)                                              \
   V(splat, (FuncSplat<Int32x4>), 0, 0, Splat)                                                            \
   V(fromFloat32x4, (FuncConvert<Float32x4, Int32x4>), 1, 0, FromFloat32x4)
 
 #define INT32X4_BINARY_FUNCTION_LIST(V)                                                                  \
-  V(add, (Func<Int32x4, Add<int32_t, Int32x4>, Int32x4>), 2, 0, Add)                                     \
-  V(and, (Func<Int32x4, And<int32_t, Int32x4>, Int32x4>), 2, 0, And)                                     \
+  V(add, (Func<Int32x4, Add<int32_t>, Int32x4>), 2, 0, Add)                                              \
+  V(and, (Func<Int32x4, And<int32_t>, Int32x4>), 2, 0, And)                                              \
   V(equal, (Func<Int32x4, Equal<int32_t>, Int32x4>), 2, 0, Equal)                                        \
   V(greaterThan, (Func<Int32x4, GreaterThan<int32_t>, Int32x4>), 2, 0, GreaterThan)                      \
   V(lessThan, (Func<Int32x4, LessThan<int32_t>, Int32x4>), 2, 0, LessThan)                               \
-  V(mul, (Func<Int32x4, Mul<int32_t, Int32x4>, Int32x4>), 2, 0, Mul)                                     \
-  V(or, (Func<Int32x4, Or<int32_t, Int32x4>, Int32x4>), 2, 0, Or)                                        \
-  V(sub, (Func<Int32x4, Sub<int32_t, Int32x4>, Int32x4>), 2, 0, Sub)                                     \
+  V(mul, (Func<Int32x4, Mul<int32_t>, Int32x4>), 2, 0, Mul)                                              \
+  V(or, (Func<Int32x4, Or<int32_t>, Int32x4>), 2, 0, Or)                                                 \
+  V(sub, (Func<Int32x4, Sub<int32_t>, Int32x4>), 2, 0, Sub)                                              \
   V(shiftLeft, (Int32x4BinaryScalar<ShiftLeft>), 2, 0, ShiftLeft)                                        \
   V(shiftRight, (Int32x4BinaryScalar<ShiftRight>), 2, 0, ShiftRight)                                     \
   V(shiftRightLogical, (Int32x4BinaryScalar<ShiftRightLogical>), 2, 0, ShiftRightLogical)                \
   V(shuffle, (FuncShuffle<Int32x4, Shuffle<int32_t, Int32x4>, Int32x4>), 2, 0, Shuffle)                  \
-  V(withFlagX, (FuncWith<Int32x4, WithFlagX<int32_t, Int32x4>, Int32x4>), 2, 0, WithFlagX)               \
-  V(withFlagY, (FuncWith<Int32x4, WithFlagY<int32_t, Int32x4>, Int32x4>), 2, 0, WithFlagY)               \
-  V(withFlagZ, (FuncWith<Int32x4, WithFlagZ<int32_t, Int32x4>, Int32x4>), 2, 0, WithFlagZ)               \
-  V(withFlagW, (FuncWith<Int32x4, WithFlagW<int32_t, Int32x4>, Int32x4>), 2, 0, WithFlagW)               \
-  V(withX, (FuncWith<Int32x4, WithX<int32_t, Int32x4>, Int32x4>), 2, 0, WithX)                           \
-  V(withY, (FuncWith<Int32x4, WithY<int32_t, Int32x4>, Int32x4>), 2, 0, WithY)                           \
-  V(withZ, (FuncWith<Int32x4, WithZ<int32_t, Int32x4>, Int32x4>), 2, 0, WithZ)                           \
-  V(withW, (FuncWith<Int32x4, WithW<int32_t, Int32x4>, Int32x4>), 2, 0, WithW)                           \
-  V(xor, (Func<Int32x4, Xor<int32_t, Int32x4>, Int32x4>), 2, 0, Xor)
+  V(withFlagX, (FuncWith<Int32x4, WithFlagX<int32_t>, Int32x4>), 2, 0, WithFlagX)                        \
+  V(withFlagY, (FuncWith<Int32x4, WithFlagY<int32_t>, Int32x4>), 2, 0, WithFlagY)                        \
+  V(withFlagZ, (FuncWith<Int32x4, WithFlagZ<int32_t>, Int32x4>), 2, 0, WithFlagZ)                        \
+  V(withFlagW, (FuncWith<Int32x4, WithFlagW<int32_t>, Int32x4>), 2, 0, WithFlagW)                        \
+  V(withX, (FuncWith<Int32x4, WithX<int32_t>, Int32x4>), 2, 0, WithX)                                    \
+  V(withY, (FuncWith<Int32x4, WithY<int32_t>, Int32x4>), 2, 0, WithY)                                    \
+  V(withZ, (FuncWith<Int32x4, WithZ<int32_t>, Int32x4>), 2, 0, WithZ)                                    \
+  V(withW, (FuncWith<Int32x4, WithW<int32_t>, Int32x4>), 2, 0, WithW)                                    \
+  V(xor, (Func<Int32x4, Xor<int32_t>, Int32x4>), 2, 0, Xor)
 
 #define INT32X4_TERNARY_FUNCTION_LIST(V)                                                                 \
   V(select, Int32x4Select, 3, 0, Select)                                                                 \
   V(shuffleMix, (FuncShuffle<Int32x4, Shuffle<int32_t, Int32x4>, Int32x4>), 3, 0, ShuffleMix)
 
 #define INT32X4_QUARTERNARY_FUNCTION_LIST(V)                                                             \
   V(bool, Int32x4Bool, 4, 0, Bool)