Bug 1042244: Make FuncWith return the same type as their inputs; r=nmatsakis
authorBenjamin Bouvier <benj@benj.me>
Mon, 28 Jul 2014 19:27:52 +0200
changeset 196363 ba89f7ce6ff2ca8a57dad98b905bc57da8b6cba3
parent 196362 e788930eaa26f98b7177cd59808d3c7051c6d28f
child 196364 bab4b9114778e4ff13923142e835c3bf458028e7
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: Make FuncWith return the same type as their inputs; r=nmatsakis
js/src/builtin/SIMD.cpp
js/src/builtin/SIMD.h
--- a/js/src/builtin/SIMD.cpp
+++ b/js/src/builtin/SIMD.cpp
@@ -619,47 +619,46 @@ CoercedFunc(JSContext *cx, unsigned argc
 // Same as above, with Coercion == Out
 template<typename In, template<typename C> class Op, typename Out>
 static bool
 Func(JSContext *cx, unsigned argc, Value *vp)
 {
     return CoercedFunc<In, Out, Op, Out>(cx, argc, vp);
 }
 
-template<typename V, template<typename T> class OpWith, typename Vret>
+template<typename V, template<typename T> class OpWith>
 static bool
 FuncWith(JSContext *cx, unsigned argc, Value *vp)
 {
     typedef typename V::Elem Elem;
-    typedef typename Vret::Elem RetElem;
 
     CallArgs args = CallArgsFromVp(argc, vp);
     if (args.length() != 2 || !IsVectorObject<V>(args[0]) ||
         (!args[1].isNumber() && !args[1].isBoolean()))
     {
         return ErrorBadArgs(cx);
     }
 
     Elem *val = TypedObjectMemory<Elem *>(args[0]);
-    RetElem result[Vret::lanes];
+    Elem result[V::lanes];
 
     if (args[1].isNumber()) {
         Elem withAsNumber;
-        if (!Vret::toType(cx, args[1], &withAsNumber))
+        if (!V::toType(cx, args[1], &withAsNumber))
             return false;
-        for (unsigned i = 0; i < Vret::lanes; i++)
-            result[i] = OpWith<RetElem>::apply(i, withAsNumber, val[i]);
+        for (unsigned i = 0; i < V::lanes; i++)
+            result[i] = OpWith<Elem>::apply(i, withAsNumber, val[i]);
     } else {
         JS_ASSERT(args[1].isBoolean());
         bool withAsBool = args[1].toBoolean();
-        for (unsigned i = 0; i < Vret::lanes; i++)
-            result[i] = OpWith<RetElem>::apply(i, withAsBool, val[i]);
+        for (unsigned i = 0; i < V::lanes; i++)
+            result[i] = OpWith<Elem>::apply(i, withAsBool, val[i]);
     }
 
-    RootedObject obj(cx, Create<Vret>(cx, result));
+    RootedObject obj(cx, Create<V>(cx, result));
     if (!obj)
         return false;
 
     args.rval().setObject(*obj);
     return true;
 }
 
 template<typename V>
--- a/js/src/builtin/SIMD.h
+++ b/js/src/builtin/SIMD.h
@@ -42,22 +42,22 @@
   V(lessThan, (Func<Float32x4, LessThan, Int32x4>), 2, 0, LessThan)                               \
   V(lessThanOrEqual, (Func<Float32x4, LessThanOrEqual, Int32x4>), 2, 0, LessThanOrEqual)          \
   V(max, (Func<Float32x4, Maximum, Float32x4>), 2, 0, Max)                                        \
   V(min, (Func<Float32x4, Minimum, Float32x4>), 2, 0, Min)                                        \
   V(mul, (Func<Float32x4, Mul, Float32x4>), 2, 0, Mul)                                            \
   V(notEqual, (Func<Float32x4, NotEqual, Int32x4>), 2, 0, NotEqual)                               \
   V(shuffle, FuncShuffle<Float32x4>, 2, 0, Shuffle)                                               \
   V(or, (CoercedFunc<Float32x4, Int32x4, Or, Float32x4>), 2, 0, Or)                               \
-  V(scale, (FuncWith<Float32x4, Scale, Float32x4>), 2, 0, Scale)                                  \
+  V(scale, (FuncWith<Float32x4, Scale>), 2, 0, Scale)                                             \
   V(sub, (Func<Float32x4, Sub, Float32x4>), 2, 0, Sub)                                            \
-  V(withX, (FuncWith<Float32x4, WithX, Float32x4>), 2, 0, WithX)                                  \
-  V(withY, (FuncWith<Float32x4, WithY, Float32x4>), 2, 0, WithY)                                  \
-  V(withZ, (FuncWith<Float32x4, WithZ, Float32x4>), 2, 0, WithZ)                                  \
-  V(withW, (FuncWith<Float32x4, WithW, Float32x4>), 2, 0, WithW)                                  \
+  V(withX, (FuncWith<Float32x4, WithX>), 2, 0, WithX)                                             \
+  V(withY, (FuncWith<Float32x4, WithY>), 2, 0, WithY)                                             \
+  V(withZ, (FuncWith<Float32x4, WithZ>), 2, 0, WithZ)                                             \
+  V(withW, (FuncWith<Float32x4, WithW>), 2, 0, WithW)                                             \
   V(xor, (CoercedFunc<Float32x4, Int32x4, Xor, Float32x4>), 2, 0, Xor)
 
 #define FLOAT32X4_TERNARY_FUNCTION_LIST(V)                                                        \
   V(clamp, Float32x4Clamp, 3, 0, Clamp)                                                           \
   V(shuffleMix, FuncShuffle<Float32x4>, 3, 0, ShuffleMix)
 
 #define FLOAT32X4_FUNCTION_LIST(V)                                                                \
   FLOAT32X4_NULLARY_FUNCTION_LIST(V)                                                              \
@@ -83,24 +83,24 @@
   V(lessThan, (Func<Int32x4, LessThan, Int32x4>), 2, 0, LessThan)                                 \
   V(mul, (Func<Int32x4, Mul, Int32x4>), 2, 0, Mul)                                                \
   V(or, (Func<Int32x4, Or, Int32x4>), 2, 0, Or)                                                   \
   V(sub, (Func<Int32x4, Sub, 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>, 2, 0, Shuffle)                                                 \
-  V(withFlagX, (FuncWith<Int32x4, WithFlagX, Int32x4>), 2, 0, WithFlagX)                          \
-  V(withFlagY, (FuncWith<Int32x4, WithFlagY, Int32x4>), 2, 0, WithFlagY)                          \
-  V(withFlagZ, (FuncWith<Int32x4, WithFlagZ, Int32x4>), 2, 0, WithFlagZ)                          \
-  V(withFlagW, (FuncWith<Int32x4, WithFlagW, Int32x4>), 2, 0, WithFlagW)                          \
-  V(withX, (FuncWith<Int32x4, WithX, Int32x4>), 2, 0, WithX)                                      \
-  V(withY, (FuncWith<Int32x4, WithY, Int32x4>), 2, 0, WithY)                                      \
-  V(withZ, (FuncWith<Int32x4, WithZ, Int32x4>), 2, 0, WithZ)                                      \
-  V(withW, (FuncWith<Int32x4, WithW, Int32x4>), 2, 0, WithW)                                      \
+  V(withFlagX, (FuncWith<Int32x4, WithFlagX>), 2, 0, WithFlagX)                                   \
+  V(withFlagY, (FuncWith<Int32x4, WithFlagY>), 2, 0, WithFlagY)                                   \
+  V(withFlagZ, (FuncWith<Int32x4, WithFlagZ>), 2, 0, WithFlagZ)                                   \
+  V(withFlagW, (FuncWith<Int32x4, WithFlagW>), 2, 0, WithFlagW)                                   \
+  V(withX, (FuncWith<Int32x4, WithX>), 2, 0, WithX)                                               \
+  V(withY, (FuncWith<Int32x4, WithY>), 2, 0, WithY)                                               \
+  V(withZ, (FuncWith<Int32x4, WithZ>), 2, 0, WithZ)                                               \
+  V(withW, (FuncWith<Int32x4, WithW>), 2, 0, WithW)                                               \
   V(xor, (Func<Int32x4, Xor, Int32x4>), 2, 0, Xor)
 
 #define INT32X4_TERNARY_FUNCTION_LIST(V)                                                          \
   V(select, Int32x4Select, 3, 0, Select)                                                          \
   V(shuffleMix, FuncShuffle<Int32x4>, 3, 0, ShuffleMix)
 
 #define INT32X4_QUARTERNARY_FUNCTION_LIST(V)                                                      \
   V(bool, Int32x4Bool, 4, 0, Bool)