diff --git a/js/src/jit-test/tests/asm.js/testSIMD.js b/js/src/jit-test/tests/asm.js/testSIMD.js index 17da7bb2918b..4760961fbe36 100644 --- a/js/src/jit-test/tests/asm.js/testSIMD.js +++ b/js/src/jit-test/tests/asm.js/testSIMD.js @@ -138,7 +138,7 @@ assertEqX4(asmLink(asmCompile('glob', 'ffi', 'heap', USE_ASM + F32 + CF32 + FROU assertEqX4(asmLink(asmCompile('glob', USE_ASM + F32 + CF32 + FROUND + "function f(i) {i=i|0; return cf4(f4(f32(1) + f32(2), f32(2), f32(3), f32(4)))} return f"), this, {}, new ArrayBuffer(0x10000))(0x20000), [3, 2, 3, 4]); assertEqX4(asmLink(asmCompile('glob', USE_ASM + F32 + CF32 + FROUND + "function f(i) {i=i|0; return cf4(f4(f32(1) + f32(2), 2.0, 3.0, 4.0))} return f"), this, {}, new ArrayBuffer(0x10000))(0x20000), [3, 2, 3, 4]); -// 1.3.2 Reading values out of lanes +// 1.3.2 Getters - Reading values out of lanes assertAsmTypeFail('glob', USE_ASM + I32 + EXTI4 + "function f() {var x=1; return e(x,1) | 0;} return f"); assertAsmTypeFail('glob', USE_ASM + I32 + EXTI4 + "function f() {var x=1; return e(x + x, 1) | 0;} return f"); assertAsmTypeFail('glob', USE_ASM + I32 + EXTI4 + "function f() {var x=1.; return e(x, 1) | 0;} return f"); @@ -148,6 +148,13 @@ assertAsmTypeFail('glob', USE_ASM + I32 + EXTI4 + "function f() {var x=i4(1,2,3, assertAsmTypeFail('glob', USE_ASM + I32 + EXTI4 + "function f() {var x=e(i4(1,2,3,4),1); return x|0;} return f"); assertAsmTypeFail('glob', USE_ASM + I32 + EXTI4 + "function f() {var x=i4(1,2,3,4); return (e(x,0) > (1>>>0)) | 0;} return f"); +assertAsmTypeFail('glob', USE_ASM + I32 + EXTI4 + "function f() {var x=i4(1,2,3,4); return e(x,-1) | 0;} return f"); +assertAsmTypeFail('glob', USE_ASM + I32 + EXTI4 + "function f() {var x=i4(1,2,3,4); return e(x,4) | 0;} return f"); +assertAsmTypeFail('glob', USE_ASM + I32 + EXTI4 + "function f() {var x=i4(1,2,3,4); return e(x,.5) | 0;} return f"); +assertAsmTypeFail('glob', USE_ASM + I32 + EXTI4 + "function f() {var x=i4(1,2,3,4); return e(x,x) | 0;} return f"); +assertAsmTypeFail('glob', USE_ASM + I32 + EXTF4 + "function f() {var x=i4(1,2,3,4); return e(x,0) | 0;} return f"); +assertAsmTypeFail('glob', USE_ASM + I32 + EXTI4 + "function f() {var x=i4(1,2,3,4); var i=0; return e(x,i) | 0;} return f"); + // signMask function CheckSignMask(innerBody, type, expected) { var coerceBefore, coerceAfter, extractLane; diff --git a/js/src/tests/ecma_7/SIMD/typedobjects.js b/js/src/tests/ecma_7/SIMD/typedobjects.js index 992e7352a90b..7d8f99822cd8 100644 --- a/js/src/tests/ecma_7/SIMD/typedobjects.js +++ b/js/src/tests/ecma_7/SIMD/typedobjects.js @@ -24,6 +24,14 @@ function testFloat32x4Getters() { assertEq(Float32x4.extractLane(f, 1), 22); assertEq(Float32x4.extractLane(f, 2), 33); assertEq(Float32x4.extractLane(f, 3), 44); + + assertThrowsInstanceOf(() => Float32x4.extractLane(f, 4), TypeError); + assertThrowsInstanceOf(() => Float32x4.extractLane(f, -1), TypeError); + assertThrowsInstanceOf(() => Float32x4.extractLane(f, 0.5), TypeError); + assertThrowsInstanceOf(() => Float32x4.extractLane(f, {}), TypeError); + assertThrowsInstanceOf(() => Float32x4.extractLane(Int32x4(1,2,3,4), 0), TypeError); + assertThrowsInstanceOf(() => Float32x4.extractLane(1, 0), TypeError); + assertThrowsInstanceOf(() => Float32x4.extractLane(f, f), TypeError); } function testFloat32x4Handles() { @@ -102,6 +110,14 @@ function testFloat64x2Getters() { var f = Float64x2(11, 22); assertEq(Float64x2.extractLane(f, 0), 11); assertEq(Float64x2.extractLane(f, 1), 22); + + assertThrowsInstanceOf(() => Float64x2.extractLane(f, 2), TypeError); + assertThrowsInstanceOf(() => Float64x2.extractLane(f, -1), TypeError); + assertThrowsInstanceOf(() => Float64x2.extractLane(f, 0.5), TypeError); + assertThrowsInstanceOf(() => Float64x2.extractLane(f, {}), TypeError); + assertThrowsInstanceOf(() => Float64x2.extractLane(Float32x4(1,2,3,4), 0), TypeError); + assertThrowsInstanceOf(() => Float64x2.extractLane(1, 0), TypeError); + assertThrowsInstanceOf(() => Float64x2.extractLane(f, f), TypeError); } function testFloat64x2Handles() { @@ -194,6 +210,14 @@ function testInt8x16Getters() { assertEq(Int8x16.extractLane(f, 13), 50); assertEq(Int8x16.extractLane(f, 14), 60); assertEq(Int8x16.extractLane(f, 15), 70); + + assertThrowsInstanceOf(() => Int8x16.extractLane(f, 16), TypeError); + assertThrowsInstanceOf(() => Int8x16.extractLane(f, -1), TypeError); + assertThrowsInstanceOf(() => Int8x16.extractLane(f, 0.5), TypeError); + assertThrowsInstanceOf(() => Int8x16.extractLane(f, {}), TypeError); + assertThrowsInstanceOf(() => Int8x16.extractLane(Int32x4(1,2,3,4), 0), TypeError); + assertThrowsInstanceOf(() => Int8x16.extractLane(1, 0), TypeError); + assertThrowsInstanceOf(() => Int8x16.extractLane(f, f), TypeError); } function testInt8x16Handles() { @@ -279,6 +303,14 @@ function testInt16x8Getters() { assertEq(Int16x8.extractLane(f, 5), 66); assertEq(Int16x8.extractLane(f, 6), 77); assertEq(Int16x8.extractLane(f, 7), 88); + + assertThrowsInstanceOf(() => Int16x8.extractLane(f, 8), TypeError); + assertThrowsInstanceOf(() => Int16x8.extractLane(f, -1), TypeError); + assertThrowsInstanceOf(() => Int16x8.extractLane(f, 0.5), TypeError); + assertThrowsInstanceOf(() => Int16x8.extractLane(f, {}), TypeError); + assertThrowsInstanceOf(() => Int16x8.extractLane(Int32x4(1,2,3,4), 0), TypeError); + assertThrowsInstanceOf(() => Int16x8.extractLane(1, 0), TypeError); + assertThrowsInstanceOf(() => Int16x8.extractLane(f, f), TypeError); } function testInt16x8Handles() { @@ -359,6 +391,14 @@ function testInt32x4Getters() { assertEq(Int32x4.extractLane(f, 1), 22); assertEq(Int32x4.extractLane(f, 2), 33); assertEq(Int32x4.extractLane(f, 3), 44); + + assertThrowsInstanceOf(() => Int32x4.extractLane(f, 4), TypeError); + assertThrowsInstanceOf(() => Int32x4.extractLane(f, -1), TypeError); + assertThrowsInstanceOf(() => Int32x4.extractLane(f, 0.5), TypeError); + assertThrowsInstanceOf(() => Int32x4.extractLane(f, {}), TypeError); + assertThrowsInstanceOf(() => Int32x4.extractLane(Float32x4(1,2,3,4), 0), TypeError); + assertThrowsInstanceOf(() => Int32x4.extractLane(1, 0), TypeError); + assertThrowsInstanceOf(() => Int32x4.extractLane(f, f), TypeError); } function testInt32x4Handles() {