summaryrefslogtreecommitdiffstats
path: root/js/src/jit-test/tests/SIMD/store.js
diff options
context:
space:
mode:
authorMatt A. Tobin <mattatobin@localhost.localdomain>2018-02-02 04:16:08 -0500
committerMatt A. Tobin <mattatobin@localhost.localdomain>2018-02-02 04:16:08 -0500
commit5f8de423f190bbb79a62f804151bc24824fa32d8 (patch)
tree10027f336435511475e392454359edea8e25895d /js/src/jit-test/tests/SIMD/store.js
parent49ee0794b5d912db1f95dce6eb52d781dc210db5 (diff)
downloadUXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar
UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.gz
UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.lz
UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.xz
UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.zip
Add m-esr52 at 52.6.0
Diffstat (limited to 'js/src/jit-test/tests/SIMD/store.js')
-rw-r--r--js/src/jit-test/tests/SIMD/store.js143
1 files changed, 143 insertions, 0 deletions
diff --git a/js/src/jit-test/tests/SIMD/store.js b/js/src/jit-test/tests/SIMD/store.js
new file mode 100644
index 000000000..8cfa35427
--- /dev/null
+++ b/js/src/jit-test/tests/SIMD/store.js
@@ -0,0 +1,143 @@
+load(libdir + 'simd.js');
+
+setJitCompilerOption("ion.warmup.trigger", 40);
+
+function f() {
+ var f32 = new Float32Array(16);
+ for (var i = 0; i < 16; i++)
+ f32[i] = i + 1;
+
+ var f64 = new Float64Array(f32.buffer);
+ var i32 = new Int32Array(f32.buffer);
+ var u32 = new Uint32Array(f32.buffer);
+ var i16 = new Int16Array(f32.buffer);
+ var u16 = new Uint16Array(f32.buffer);
+ var i8 = new Int8Array(f32.buffer);
+ var u8 = new Uint8Array(f32.buffer);
+
+ var f4 = SIMD.Float32x4(42, 43, 44, 45);
+
+ function check(n) {
+ assertEq(f32[0], 42);
+ assertEq(f32[1], n > 1 ? 43 : 2);
+ assertEq(f32[2], n > 2 ? 44 : 3);
+ assertEq(f32[3], n > 3 ? 45 : 4);
+
+ f32[0] = 1;
+ f32[1] = 2;
+ f32[2] = 3;
+ f32[3] = 4;
+ }
+
+ function testStore() {
+ SIMD.Float32x4.store(f64, 0, f4);
+ check(4);
+ SIMD.Float32x4.store(f32, 0, f4);
+ check(4);
+ SIMD.Float32x4.store(i32, 0, f4);
+ check(4);
+ SIMD.Float32x4.store(u32, 0, f4);
+ check(4);
+ SIMD.Float32x4.store(i16, 0, f4);
+ check(4);
+ SIMD.Float32x4.store(u16, 0, f4);
+ check(4);
+ SIMD.Float32x4.store(i8, 0, f4);
+ check(4);
+ SIMD.Float32x4.store(u8, 0, f4);
+ check(4);
+ }
+
+ function testStore1() {
+ SIMD.Float32x4.store1(f64, 0, f4);
+ check(1);
+ SIMD.Float32x4.store1(f32, 0, f4);
+ check(1);
+ SIMD.Float32x4.store1(i32, 0, f4);
+ check(1);
+ SIMD.Float32x4.store1(u32, 0, f4);
+ check(1);
+ SIMD.Float32x4.store1(i16, 0, f4);
+ check(1);
+ SIMD.Float32x4.store1(u16, 0, f4);
+ check(1);
+ SIMD.Float32x4.store1(i8, 0, f4);
+ check(1);
+ SIMD.Float32x4.store1(u8, 0, f4);
+ check(1);
+ }
+
+ function testStore2() {
+ SIMD.Float32x4.store2(f64, 0, f4);
+ check(2);
+ SIMD.Float32x4.store2(f32, 0, f4);
+ check(2);
+ SIMD.Float32x4.store2(i32, 0, f4);
+ check(2);
+ SIMD.Float32x4.store2(u32, 0, f4);
+ check(2);
+ SIMD.Float32x4.store2(i16, 0, f4);
+ check(2);
+ SIMD.Float32x4.store2(u16, 0, f4);
+ check(2);
+ SIMD.Float32x4.store2(i8, 0, f4);
+ check(2);
+ SIMD.Float32x4.store2(u8, 0, f4);
+ check(2);
+ }
+
+ function testStore3() {
+ SIMD.Float32x4.store3(f64, 0, f4);
+ check(3);
+ SIMD.Float32x4.store3(f32, 0, f4);
+ check(3);
+ SIMD.Float32x4.store3(i32, 0, f4);
+ check(3);
+ SIMD.Float32x4.store3(u32, 0, f4);
+ check(3);
+ SIMD.Float32x4.store3(i16, 0, f4);
+ check(3);
+ SIMD.Float32x4.store3(u16, 0, f4);
+ check(3);
+ SIMD.Float32x4.store3(i8, 0, f4);
+ check(3);
+ SIMD.Float32x4.store3(u8, 0, f4);
+ check(3);
+ }
+
+ for (var i = 0; i < 150; i++) {
+ testStore();
+ testStore1();
+ testStore2();
+ testStore3();
+ }
+}
+
+f();
+
+function testBailout(uglyDuckling) {
+ var f32 = new Float32Array(16);
+ for (var i = 0; i < 16; i++)
+ f32[i] = i + 1;
+
+ var i8 = new Int8Array(f32.buffer);
+
+ var f4 = SIMD.Float32x4(42, 43, 44, 45);
+
+ for (var i = 0; i < 150; i++) {
+ var caught = false;
+ try {
+ SIMD.Float32x4.store(i8, (i < 149) ? 0 : (16 << 2) - (4 << 2) + 1, f4);
+ } catch (e) {
+ print(e);
+ assertEq(e instanceof RangeError, true);
+ caught = true;
+ }
+ assertEq(i < 149 || caught, true);
+ }
+}
+
+print('Testing range checks...');
+testBailout(-1);
+testBailout(-15);
+testBailout(12 * 4 + 1);