Backed out changesets 18c84fcee487 and cc4786da89db (bug 1135039) for Linux32 jit-test assertion failures.
authorRyan VanderMeulen <ryanvm@gmail.com>
Wed, 11 Mar 2015 15:23:58 -0400
changeset 261974 b79d608ca1744f808313c4574a432518a57c2f7e
parent 261973 1a5e4a1bba362ab176e63c31c50293b8d40172fb
child 261975 de19c60e56bda9c8366b801da8a8a0209cb8f56c
push id4718
push userraliiev@mozilla.com
push dateMon, 11 May 2015 18:39:53 +0000
treeherdermozilla-beta@c20c4ef55f08 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
bugs1135039
milestone39.0a1
backs out18c84fcee487097abe547d7a5cccf641ee489270
cc4786da89db2c3470551632e72d388a516d1abd
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
Backed out changesets 18c84fcee487 and cc4786da89db (bug 1135039) for Linux32 jit-test assertion failures. CLOSED TREE
js/src/builtin/SIMD.cpp
js/src/jit-test/tests/SIMD/swizzle.js
js/src/jit/Lowering.cpp
js/src/jit/MCallOptimize.cpp
js/src/jit/TypePolicy.cpp
js/src/jit/shared/CodeGenerator-x86-shared.cpp
js/src/tests/ecma_7/SIMD/swizzle-shuffle.js
--- a/js/src/builtin/SIMD.cpp
+++ b/js/src/builtin/SIMD.cpp
@@ -744,19 +744,19 @@ Swizzle(JSContext *cx, unsigned argc, Va
     typedef typename V::Elem Elem;
 
     CallArgs args = CallArgsFromVp(argc, vp);
     if (args.length() != (V::lanes + 1) || !IsVectorObject<V>(args[0]))
         return ErrorBadArgs(cx);
 
     uint32_t lanes[V::lanes];
     for (unsigned i = 0; i < V::lanes; i++) {
-        if (!args[i + 1].isInt32())
-            return ErrorBadArgs(cx);
-        int32_t lane = args[i + 1].toInt32();
+        int32_t lane = -1;
+        if (!ToInt32(cx, args[i + 1], &lane))
+            return false;
         if (lane < 0 || uint32_t(lane) >= V::lanes)
             return ErrorBadArgs(cx);
         lanes[i] = uint32_t(lane);
     }
 
     Elem *val = TypedObjectMemory<Elem *>(args[0]);
 
     Elem result[V::lanes];
@@ -773,19 +773,19 @@ Shuffle(JSContext *cx, unsigned argc, Va
     typedef typename V::Elem Elem;
 
     CallArgs args = CallArgsFromVp(argc, vp);
     if (args.length() != (V::lanes + 2) || !IsVectorObject<V>(args[0]) || !IsVectorObject<V>(args[1]))
         return ErrorBadArgs(cx);
 
     uint32_t lanes[V::lanes];
     for (unsigned i = 0; i < V::lanes; i++) {
-        if (!args[i + 2].isInt32())
-            return ErrorBadArgs(cx);
-        int32_t lane = args[i + 2].toInt32();
+        int32_t lane = -1;
+        if (!ToInt32(cx, args[i + 2], &lane))
+            return false;
         if (lane < 0 || uint32_t(lane) >= (2 * V::lanes))
             return ErrorBadArgs(cx);
         lanes[i] = uint32_t(lane);
     }
 
     Elem *lhs = TypedObjectMemory<Elem *>(args[0]);
     Elem *rhs = TypedObjectMemory<Elem *>(args[1]);
 
deleted file mode 100644
--- a/js/src/jit-test/tests/SIMD/swizzle.js
+++ /dev/null
@@ -1,71 +0,0 @@
-if (!this.hasOwnProperty("SIMD"))
-  quit();
-
-load(libdir + 'simd.js');
-
-setJitCompilerOption("ion.warmup.trigger", 50);
-
-function f() {
-    var i4 = SIMD.int32x4(1, 2, 3, 4);
-
-    var leet = Math.fround(13.37);
-    var f4 = SIMD.float32x4(-.5, -0, Infinity, leet);
-
-    var compI = [
-        [1,2,3,4],
-        [2,3,4,1],
-        [3,4,1,2],
-        [4,1,2,3]
-    ];
-
-    var compF = [
-        [-.5, -0, Infinity, leet],
-        [-0, Infinity, leet, -.5],
-        [Infinity, leet, -.5, -0],
-        [leet, -.5, -0, Infinity]
-    ];
-
-    for (var i = 0; i < 150; i++) {
-        // Variable lanes
-        var r = SIMD.float32x4.swizzle(f4, i % 4, (i + 1) % 4, (i + 2) % 4, (i + 3) % 4);
-        assertEqX4(r, compF[i % 4]);
-
-        // Constant lanes
-        assertEqX4(SIMD.float32x4.swizzle(f4, 3, 2, 1, 0), [leet, Infinity, -0, -.5]);
-
-        // Variable lanes
-        var r = SIMD.int32x4.swizzle(i4, i % 4, (i + 1) % 4, (i + 2) % 4, (i + 3) % 4);
-        assertEqX4(r, compI[i % 4]);
-
-        // Constant lanes
-        assertEqX4(SIMD.int32x4.swizzle(i4, 3, 2, 1, 0), [4, 3, 2, 1]);
-    }
-}
-
-function testBailouts(uglyDuckling) {
-    var i4 = SIMD.int32x4(1, 2, 3, 4);
-    for (var i = 0; i < 150; i++) {
-        // Test bailouts
-        var value = i == 149 ? uglyDuckling : 0;
-        var caught = false;
-        try {
-            assertEqX4(SIMD.int32x4.swizzle(i4, value, 3, 2, 0), [1, 4, 3, 1]);
-        } catch(e) {
-            print(e);
-            caught = true;
-            assertEq(i, 149);
-            assertEq(e instanceof TypeError, true);
-        }
-        assertEq(i < 149 || caught, true);
-    }
-}
-
-f();
-testBailouts(-1);
-testBailouts(4);
-testBailouts(2.5);
-testBailouts(undefined);
-testBailouts(null);
-testBailouts({});
-testBailouts('one');
-testBailouts(true);
--- a/js/src/jit/Lowering.cpp
+++ b/js/src/jit/Lowering.cpp
@@ -3958,22 +3958,20 @@ LIRGenerator::visitSimdGeneralSwizzle(MS
 
     LAllocation lanesUses[4];
     for (size_t i = 0; i < 4; i++)
         lanesUses[i] = use(ins->lane(i));
 
     if (ins->input()->type() == MIRType_Int32x4) {
         LSimdGeneralSwizzleI *lir = new (alloc()) LSimdGeneralSwizzleI(useRegister(ins->input()),
                                                                        lanesUses, temp());
-        assignSnapshot(lir, Bailout_BoundsCheck);
         define(lir, ins);
     } else if (ins->input()->type() == MIRType_Float32x4) {
         LSimdGeneralSwizzleF *lir = new (alloc()) LSimdGeneralSwizzleF(useRegister(ins->input()),
                                                                        lanesUses, temp());
-        assignSnapshot(lir, Bailout_BoundsCheck);
         define(lir, ins);
     } else {
         MOZ_CRASH("Unknown SIMD kind when getting lane");
     }
 }
 
 void
 LIRGenerator::visitSimdShuffle(MSimdShuffle *ins)
--- a/js/src/jit/MCallOptimize.cpp
+++ b/js/src/jit/MCallOptimize.cpp
@@ -349,24 +349,23 @@ IonBuilder::inlineNativeCall(CallInfo &c
         return inlineSimdSelect(callInfo, native, IsElementWise(false), SimdTypeDescr::TYPE_INT32);
     if (native == js::simd_float32x4_select)
         return inlineSimdSelect(callInfo, native, IsElementWise(true), SimdTypeDescr::TYPE_FLOAT32);
     if (native == js::simd_float32x4_bitselect)
         return inlineSimdSelect(callInfo, native, IsElementWise(false), SimdTypeDescr::TYPE_FLOAT32);
 
     if (native == js::simd_int32x4_swizzle)
         return inlineSimdSwizzle(callInfo, native, SimdTypeDescr::TYPE_INT32);
-    if (native == js::simd_float32x4_swizzle)
-        return inlineSimdSwizzle(callInfo, native, SimdTypeDescr::TYPE_FLOAT32);
 
     if (native == js::simd_int32x4_load)
         return inlineSimdLoad(callInfo, native, SimdTypeDescr::TYPE_INT32);
     if (native == js::simd_float32x4_load)
         return inlineSimdLoad(callInfo, native, SimdTypeDescr::TYPE_FLOAT32);
 
+
     if (native == js::simd_int32x4_store)
         return inlineSimdStore(callInfo, native, SimdTypeDescr::TYPE_INT32);
     if (native == js::simd_float32x4_store)
         return inlineSimdStore(callInfo, native, SimdTypeDescr::TYPE_FLOAT32);
 
     return InliningStatus_NotInlined;
 }
 
--- a/js/src/jit/TypePolicy.cpp
+++ b/js/src/jit/TypePolicy.cpp
@@ -795,17 +795,17 @@ SimdSwizzlePolicy::adjustInputs(TempAllo
         return false;
 
     // Next inputs are the lanes, which need to be int32
     for (unsigned i = 0; i < 4; i++) {
         MDefinition *in = ins->getOperand(i + 1);
         if (in->type() == MIRType_Int32)
             continue;
 
-        MInstruction *replace = MToInt32::New(alloc, in, MacroAssembler::IntConversion_NumbersOnly);
+        MInstruction *replace = MTruncateToInt32::New(alloc, in);
         ins->block()->insertBefore(ins, replace);
         ins->replaceOperand(i + 1, replace);
         if (!replace->typePolicy()->adjustInputs(alloc, replace))
             return false;
     }
 
     return true;
 }
--- a/js/src/jit/shared/CodeGenerator-x86-shared.cpp
+++ b/js/src/jit/shared/CodeGenerator-x86-shared.cpp
@@ -2387,96 +2387,87 @@ CodeGeneratorX86Shared::visitSimdGeneral
 
     // This won't generate fast code, but it's fine because we expect users
     // to have used constant indices (and thus MSimdGeneralSwizzle to be fold
     // into MSimdSwizzle, which are fast).
     masm.reserveStack(Simd128DataSize * 2);
 
     masm.storeAlignedInt32x4(input, Address(StackPointer, Simd128DataSize));
 
-    Label bail;
-
     for (size_t i = 0; i < 4; i++) {
         Operand lane = ToOperand(ins->lane(i));
 
-        masm.cmp32(lane, Imm32(3));
-        masm.j(Assembler::Above, &bail);
-
+        Label go, join;
+        masm.cmp32(lane, Imm32(4));
+        masm.j(Assembler::Below, &go);
+
+        {
+            masm.store32(Imm32(0), Address(StackPointer, i * sizeof(int32_t)));
+            masm.jump(&join);
+        }
+
+        masm.bind(&go);
         if (lane.kind() == Operand::REG) {
             masm.load32(Operand(StackPointer, ToRegister(ins->lane(i)), TimesFour, Simd128DataSize),
                         temp);
         } else {
             masm.load32(lane, temp);
             masm.load32(Operand(StackPointer, temp, TimesFour, Simd128DataSize), temp);
         }
 
         masm.store32(temp, Address(StackPointer, i * sizeof(int32_t)));
+        masm.bind(&join);
     }
 
     FloatRegister output = ToFloatRegister(ins->output());
     masm.loadAlignedInt32x4(Address(StackPointer, 0), output);
 
-    Label join;
-    masm.jump(&join);
-
-    {
-        masm.bind(&bail);
-        masm.setFramePushed(masm.framePushed() + Simd128DataSize * 2);
-        masm.freeStack(Simd128DataSize * 2);
-        bailout(ins->snapshot());
-    }
-
-    masm.bind(&join);
     masm.freeStack(Simd128DataSize * 2);
 }
 
 void
 CodeGeneratorX86Shared::visitSimdGeneralSwizzleF(LSimdGeneralSwizzleF *ins)
 {
     FloatRegister input = ToFloatRegister(ins->base());
     Register temp = ToRegister(ins->temp());
 
     // See comment in the visitSimdGeneralSwizzleI.
     masm.reserveStack(Simd128DataSize * 2);
 
     masm.storeAlignedFloat32x4(input, Address(StackPointer, Simd128DataSize));
 
-    Label bail;
-
     for (size_t i = 0; i < 4; i++) {
         Operand lane = ToOperand(ins->lane(i));
 
-        masm.cmp32(lane, Imm32(3));
-        masm.j(Assembler::Above, &bail);
-
+        Label go, join;
+        masm.cmp32(lane, Imm32(4));
+        masm.j(Assembler::Below, &go);
+
+        {
+            masm.loadConstantFloat32(float(GenericNaN()), ScratchFloat32Reg);
+            masm.storeFloat32(ScratchFloat32Reg, Address(StackPointer, i * sizeof(int32_t)));
+            masm.jump(&join);
+        }
+
+        masm.bind(&go);
         if (lane.kind() == Operand::REG) {
             masm.loadFloat32(Operand(StackPointer, ToRegister(ins->lane(i)), TimesFour, Simd128DataSize),
                              ScratchFloat32Reg);
         } else {
             masm.load32(lane, temp);
             masm.loadFloat32(Operand(StackPointer, temp, TimesFour, Simd128DataSize), ScratchFloat32Reg);
         }
 
         masm.storeFloat32(ScratchFloat32Reg, Address(StackPointer, i * sizeof(int32_t)));
+        masm.bind(&join);
     }
 
     FloatRegister output = ToFloatRegister(ins->output());
     masm.loadAlignedFloat32x4(Address(StackPointer, 0), output);
 
-    Label join;
-    masm.jump(&join);
-
-    {
-        masm.bind(&bail);
-        masm.setFramePushed(masm.framePushed() + Simd128DataSize * 2);
-        masm.freeStack(Simd128DataSize * 2);
-        bailout(ins->snapshot());
-    }
-
-    masm.bind(&join);
     masm.freeStack(Simd128DataSize * 2);
 }
 
 void
 CodeGeneratorX86Shared::visitSimdSwizzleI(LSimdSwizzleI *ins)
 {
     FloatRegister input = ToFloatRegister(ins->input());
     FloatRegister output = ToFloatRegister(ins->output());
--- a/js/src/tests/ecma_7/SIMD/swizzle-shuffle.js
+++ b/js/src/tests/ecma_7/SIMD/swizzle-shuffle.js
@@ -30,62 +30,62 @@ function getNumberOfLanesFromType(type) 
 
 function testSwizzleForType(type) {
     var lanes = getNumberOfLanesFromType(type);
     var v = lanes == 4 ? type(1, 2, 3, 4) : type(1, 2);
 
     assertThrowsInstanceOf(() => type.swizzle()               , TypeError);
     assertThrowsInstanceOf(() => type.swizzle(v, 0)           , TypeError);
     assertThrowsInstanceOf(() => type.swizzle(v, 0, 1, 2)     , TypeError);
+    assertThrowsInstanceOf(() => type.swizzle(v, 0, 1, 2, 4)  , TypeError);
+    assertThrowsInstanceOf(() => type.swizzle(v, 0, 1, 2, -1) , TypeError);
     assertThrowsInstanceOf(() => type.swizzle(0, 1, 2, 3, v)  , TypeError);
 
+    if (lanes == 2) {
+        assertThrowsInstanceOf(() => type.swizzle(v, 0, -1)   , TypeError);
+        assertThrowsInstanceOf(() => type.swizzle(v, 0, 2)    , TypeError);
+    } else {
+        assertEq(lanes, 4);
+        assertThrowsInstanceOf(() => type.swizzle(v, 0, 1), TypeError);
+    }
+
     // Test all possible swizzles.
     if (lanes == 4) {
         var x, y, z, w;
         for (var i = 0; i < Math.pow(4, 4); i++) {
             [x, y, z, w] = [i & 3, (i >> 2) & 3, (i >> 4) & 3, (i >> 6) & 3];
             assertEqVec(type.swizzle(v, x, y, z, w), swizzle4(simdToArray(v), x, y, z, w));
         }
     } else {
         assertEq(lanes, 2);
         var x, y;
         for (var i = 0; i < Math.pow(2, 2); i++) {
           [x, y] = [x & 1, (y >> 1) & 1];
           assertEqVec(type.swizzle(v, x, y), swizzle2(simdToArray(v), x, y));
         }
     }
 
-    // Test that we throw if an lane argument isn't an int32 or isn't in bounds.
+    // Test that the lane inputs are converted into an int32.
+    // n.b, order of evaluation of args is left-to-right.
+    var obj = {
+        x: 0,
+        valueOf: function() { return this.x++ }
+    };
     if (lanes == 4) {
-        assertThrowsInstanceOf(() => type.swizzle(v, 0, 0, 0, 0.5), TypeError);
-        assertThrowsInstanceOf(() => type.swizzle(v, 0, 0, 0, {}), TypeError);
-        assertThrowsInstanceOf(() => type.swizzle(v, 0, 0, 0, {valueOf: function(){return 42}}), TypeError);
-        assertThrowsInstanceOf(() => type.swizzle(v, 0, 0, 0, "one"), TypeError);
-        assertThrowsInstanceOf(() => type.swizzle(v, 0, 0, 0, null), TypeError);
-        assertThrowsInstanceOf(() => type.swizzle(v, 0, 0, 0, undefined), TypeError);
-        assertThrowsInstanceOf(() => type.swizzle(v, 0, 0, 0, true), TypeError);
-
-        // In bounds is [0, 3]
-        assertThrowsInstanceOf(() => type.swizzle(v, 0, 0, 0, -1), TypeError);
-        assertThrowsInstanceOf(() => type.swizzle(v, 0, 0, 0, 4), TypeError);
+        assertEqVec(type.swizzle(v, obj, obj, obj, obj), swizzle4(simdToArray(v), 0, 1, 2, 3));
     } else {
         assertEq(lanes, 2);
+        assertEqVec(type.swizzle(v, obj, obj), swizzle2(simdToArray(v), 0, 1));
+    }
 
-        assertThrowsInstanceOf(() => type.swizzle(v, 0, 0.5), TypeError);
-        assertThrowsInstanceOf(() => type.swizzle(v, 0, {}), TypeError);
-        assertThrowsInstanceOf(() => type.swizzle(v, 0, {valueOf: function(){return 42}}), TypeError);
-        assertThrowsInstanceOf(() => type.swizzle(v, 0, "one"), TypeError);
-        assertThrowsInstanceOf(() => type.swizzle(v, 0, null), TypeError);
-        assertThrowsInstanceOf(() => type.swizzle(v, 0, undefined), TypeError);
-        assertThrowsInstanceOf(() => type.swizzle(v, 0, true), TypeError);
-
-        // In bounds is [0, 1]
-        assertThrowsInstanceOf(() => type.swizzle(v, 0, -1), TypeError);
-        assertThrowsInstanceOf(() => type.swizzle(v, 0, 2), TypeError);
-    }
+    // Object for which ToInt32 will fail.
+    obj = {
+        valueOf: function() { throw new Error; }
+    };
+    assertThrowsInstanceOf(() => type.swizzle(v, 0, 1, 2, obj), Error);
 }
 
 function testSwizzleInt32x4() {
     var v = int32x4(1, 2, 3, 4);
 
     assertThrowsInstanceOf(function() {
         float32x4.swizzle(v, 0, 0, 0, 0);
     }, TypeError);
@@ -105,17 +105,17 @@ function testSwizzleFloat32x4() {
 
 function testSwizzleFloat64x2() {
     var v = float64x2(1, 2);
 
     assertThrowsInstanceOf(function() {
         float32x4.swizzle(v, 0, 0, 0, 0);
     }, TypeError);
 
-    testSwizzleForType(float64x2);
+   testSwizzleForType(float64x2);
 }
 
 function shuffle2(lhsa, rhsa, x, y) {
     return [(x < 2 ? lhsa : rhsa)[x % 2],
             (y < 2 ? lhsa : rhsa)[y % 2]];
 }
 function shuffle4(lhsa, rhsa, x, y, z, w) {
     return [(x < 4 ? lhsa : rhsa)[x % 4],
@@ -135,18 +135,28 @@ function testShuffleForType(type) {
         lhs = type(1, 2);
         rhs = type(3, 4);
     }
 
     assertThrowsInstanceOf(() => type.shuffle(lhs)                   , TypeError);
     assertThrowsInstanceOf(() => type.shuffle(lhs, rhs)              , TypeError);
     assertThrowsInstanceOf(() => type.shuffle(lhs, rhs, 0)           , TypeError);
     assertThrowsInstanceOf(() => type.shuffle(lhs, rhs, 0, 1, 2)     , TypeError);
+    assertThrowsInstanceOf(() => type.shuffle(lhs, rhs, 0, 1, 2, -1) , TypeError);
+    assertThrowsInstanceOf(() => type.shuffle(lhs, rhs, 0, 1, 2, 8)  , TypeError);
     assertThrowsInstanceOf(() => type.shuffle(lhs, 0, 1, 2, 7, rhs)  , TypeError);
 
+    if (lanes == 2) {
+        assertThrowsInstanceOf(() => type.shuffle(lhs, rhs, 0, 4)    , TypeError);
+        assertThrowsInstanceOf(() => type.shuffle(lhs, rhs, 0, -1)   , TypeError);
+    } else {
+        assertEq(lanes, 4);
+        assertThrowsInstanceOf(() => type.shuffle(lhs, rhs, 0, 1) , TypeError);
+    }
+
     // Test all possible shuffles.
     var x, y, z, w;
     if (lanes == 4) {
         var x, y, z, w;
         for (var i = 0; i < Math.pow(8, 4); i++) {
             [x, y, z, w] = [i & 7, (i >> 3) & 7, (i >> 6) & 7, (i >> 9) & 7];
             assertEqVec(type.shuffle(lhs, rhs, x, y, z, w),
                         shuffle4(simdToArray(lhs), simdToArray(rhs), x, y, z, w));
@@ -156,44 +166,36 @@ function testShuffleForType(type) {
         var x, y;
         for (var i = 0; i < Math.pow(4, 2); i++) {
             [x, y] = [i & 3, (i >> 3) & 3];
             assertEqVec(type.shuffle(lhs, rhs, x, y),
                         shuffle2(simdToArray(lhs), simdToArray(rhs), x, y));
         }
     }
 
-    // Test that we throw if an lane argument isn't an int32 or isn't in bounds.
+    // Test that the lane inputs are converted into an int32.
+    // n.b, order of evaluation of args is left-to-right.
+    var obj = {
+        x: 0,
+        valueOf: function() { return this.x++ }
+    };
     if (lanes == 4) {
-        assertThrowsInstanceOf(() => type.shuffle(lhs, rhs, 0, 0, 0, 0.5), TypeError);
-        assertThrowsInstanceOf(() => type.shuffle(lhs, rhs, 0, 0, 0, {}), TypeError);
-        assertThrowsInstanceOf(() => type.shuffle(lhs, rhs, 0, 0, 0, {valueOf: function(){return 42}}), TypeError);
-        assertThrowsInstanceOf(() => type.shuffle(lhs, rhs, 0, 0, 0, "one"), TypeError);
-        assertThrowsInstanceOf(() => type.shuffle(lhs, rhs, 0, 0, 0, null), TypeError);
-        assertThrowsInstanceOf(() => type.shuffle(lhs, rhs, 0, 0, 0, undefined), TypeError);
-        assertThrowsInstanceOf(() => type.shuffle(lhs, rhs, 0, 0, 0, true), TypeError);
-
-        // In bounds is [0, 7]
-        assertThrowsInstanceOf(() => type.shuffle(lhs, rhs, 0, 0, 0, -1), TypeError);
-        assertThrowsInstanceOf(() => type.shuffle(lhs, rhs, 0, 0, 0, 8), TypeError);
+        assertEqVec(type.shuffle(lhs, rhs, obj, obj, obj, obj),
+                    shuffle4(simdToArray(lhs), simdToArray(rhs), 0, 1, 2, 3));
     } else {
         assertEq(lanes, 2);
+        assertEqVec(type.shuffle(lhs, rhs, obj, obj),
+                    shuffle2(simdToArray(lhs), simdToArray(rhs), 0, 1));
+    }
 
-        assertThrowsInstanceOf(() => type.shuffle(lhs, rhs, 0, 0.5), TypeError);
-        assertThrowsInstanceOf(() => type.shuffle(lhs, rhs, 0, {}), TypeError);
-        assertThrowsInstanceOf(() => type.shuffle(lhs, rhs, 0, {valueOf: function(){return 42}}), TypeError);
-        assertThrowsInstanceOf(() => type.shuffle(lhs, rhs, 0, "one"), TypeError);
-        assertThrowsInstanceOf(() => type.shuffle(lhs, rhs, 0, null), TypeError);
-        assertThrowsInstanceOf(() => type.shuffle(lhs, rhs, 0, undefined), TypeError);
-        assertThrowsInstanceOf(() => type.shuffle(lhs, rhs, 0, true), TypeError);
-
-        // In bounds is [0, 3]
-        assertThrowsInstanceOf(() => type.shuffle(lhs, rhs, 0, -1), TypeError);
-        assertThrowsInstanceOf(() => type.shuffle(lhs, rhs, 0, 4), TypeError);
-    }
+    // Object for which ToInt32 will fail.
+    obj = {
+        valueOf: function() { throw new Error; }
+    };
+    assertThrowsInstanceOf(() => type.shuffle(lhs, rhs, 0, 1, 2, obj), Error);
 }
 
 function testShuffleInt32x4() {
     var v = int32x4(1, 2, 3, 4);
 
     assertThrowsInstanceOf(function() {
         float32x4.shuffle(v, v, 0, 0, 0, 0);
     }, TypeError);