Bug 1507572 - Generalize alignments for memory ops testing. r=bbouvier
authorLars T Hansen <lhansen@mozilla.com>
Fri, 16 Nov 2018 10:47:36 +0100
changeset 503199 f970d9b9b00c57bef40a51639390a0b2d4c1502e
parent 503198 2ea6c6932f6e45bb6f472dd8d5271d53a22788ac
child 503200 fc0bc3b27660a2dcf0be70ad2e2dabd400f307aa
push id10290
push userffxbld-merge
push dateMon, 03 Dec 2018 16:23:23 +0000
treeherdermozilla-beta@700bed2445e6 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbbouvier
bugs1507572
milestone65.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 1507572 - Generalize alignments for memory ops testing. r=bbouvier These test cases already had some infrastructure for parameterizing over alignment, it just wasn't being used. Once enabled it stubles across the ARM bugs quickly.
js/src/jit-test/tests/wasm/memory.js
--- a/js/src/jit-test/tests/wasm/memory.js
+++ b/js/src/jit-test/tests/wasm/memory.js
@@ -203,105 +203,114 @@ for (var foldOffsets = 0; foldOffsets <=
     testStore('f64', '', 1, 7, 8, 0.89012345);
 
     testStore('i32', '8', 0, 0, 0, 0x23);
     testStore('i32', '16', 0, 0, 0, 0x2345);
 
     wasmFailValidateText('(module (memory 2 1))', /maximum length 1 is less than initial length 2/);
 
     // Test bounds checks and edge cases.
-    const align = 0;
+
+    for (let align of [0,1,2,4]) {
 
-    for (let offset of [0, 1, 2, 3, 4, 8, 16, 41, 0xfff8]) {
-        // Accesses of 1 byte.
-        let lastValidIndex = 0x10000 - 1 - offset;
-
-        testLoad('i32', '8_s', lastValidIndex, offset, align, 0);
-        testLoadOOB('i32', '8_s', lastValidIndex + 1, offset, align);
+        for (let offset of [0, 1, 2, 3, 4, 8, 16, 41, 0xfff8]) {
+            // Accesses of 1 byte.
+            let lastValidIndex = 0x10000 - 1 - offset;
 
-        testLoad('i32', '8_u', lastValidIndex, offset, align, 0);
-        testLoadOOB('i32', '8_u', lastValidIndex + 1, offset, align);
+            if (align < 2) {
+                testLoad('i32', '8_s', lastValidIndex, offset, align, 0);
+                testLoadOOB('i32', '8_s', lastValidIndex + 1, offset, align);
 
-        testStore('i32', '8', lastValidIndex, offset, align, -42);
-        testStoreOOB('i32', '8', lastValidIndex + 1, offset, align, -42);
+                testLoad('i32', '8_u', lastValidIndex, offset, align, 0);
+                testLoadOOB('i32', '8_u', lastValidIndex + 1, offset, align);
 
-        // Accesses of 2 bytes.
-        lastValidIndex = 0x10000 - 2 - offset;
+                testStore('i32', '8', lastValidIndex, offset, align, -42);
+                testStoreOOB('i32', '8', lastValidIndex + 1, offset, align, -42);
+            }
 
-        testLoad('i32', '16_s', lastValidIndex, offset, align, 0);
-        testLoadOOB('i32', '16_s', lastValidIndex + 1, offset, align);
+            // Accesses of 2 bytes.
+            lastValidIndex = 0x10000 - 2 - offset;
 
-        testLoad('i32', '16_u', lastValidIndex, offset, align, 0);
-        testLoadOOB('i32', '16_u', lastValidIndex + 1, offset, align);
-
-        testStore('i32', '16', lastValidIndex, offset, align, -32768);
-        testStoreOOB('i32', '16', lastValidIndex + 1, offset, align, -32768);
+            if (align < 4) {
+                testLoad('i32', '16_s', lastValidIndex, offset, align, 0);
+                testLoadOOB('i32', '16_s', lastValidIndex + 1, offset, align);
 
-        // Accesses of 4 bytes.
-        lastValidIndex = 0x10000 - 4 - offset;
+                testLoad('i32', '16_u', lastValidIndex, offset, align, 0);
+                testLoadOOB('i32', '16_u', lastValidIndex + 1, offset, align);
 
-        testLoad('i32', '', lastValidIndex, offset, align, 0);
-        testLoadOOB('i32', '', lastValidIndex + 1, offset, align);
+                testStore('i32', '16', lastValidIndex, offset, align, -32768);
+                testStoreOOB('i32', '16', lastValidIndex + 1, offset, align, -32768);
+            }
 
-        testLoad('f32', '', lastValidIndex, offset, align, 0);
-        testLoadOOB('f32', '', lastValidIndex + 1, offset, align);
+            // Accesses of 4 bytes.
+            lastValidIndex = 0x10000 - 4 - offset;
 
-        testStore('i32', '', lastValidIndex, offset, align, 1337);
-        testStoreOOB('i32', '', lastValidIndex + 1, offset, align, 1337);
+            testLoad('i32', '', lastValidIndex, offset, align, 0);
+            testLoadOOB('i32', '', lastValidIndex + 1, offset, align);
 
-        testStore('f32', '', lastValidIndex, offset, align, Math.fround(13.37));
-        testStoreOOB('f32', '', lastValidIndex + 1, offset, align, Math.fround(13.37));
+            testLoad('f32', '', lastValidIndex, offset, align, 0);
+            testLoadOOB('f32', '', lastValidIndex + 1, offset, align);
 
-        // Accesses of 8 bytes.
-        lastValidIndex = 0x10000 - 8 - offset;
+            testStore('i32', '', lastValidIndex, offset, align, 1337);
+            testStoreOOB('i32', '', lastValidIndex + 1, offset, align, 1337);
+
+            testStore('f32', '', lastValidIndex, offset, align, Math.fround(13.37));
+            testStoreOOB('f32', '', lastValidIndex + 1, offset, align, Math.fround(13.37));
 
-        testLoad('f64', '', lastValidIndex, offset, align, 0);
-        testLoadOOB('f64', '', lastValidIndex + 1, offset, align);
+            // Accesses of 8 bytes.
+            lastValidIndex = 0x10000 - 8 - offset;
 
-        testStore('f64', '', lastValidIndex, offset, align, 1.23456789);
-        testStoreOOB('f64', '', lastValidIndex + 1, offset, align, 1.23456789);
-    }
+            testLoad('f64', '', lastValidIndex, offset, align, 0);
+            testLoadOOB('f64', '', lastValidIndex + 1, offset, align);
+
+            testStore('f64', '', lastValidIndex, offset, align, 1.23456789);
+            testStoreOOB('f64', '', lastValidIndex + 1, offset, align, 1.23456789);
+        }
 
-    // Ensure wrapping doesn't apply.
-    offset = 0x7fffffff; // maximum allowed offset that doesn't always throw.
-    for (let index of [0, 1, 2, 3, 0x7fffffff, 0x80000000, 0x80000001]) {
-        testLoadOOB('i32', '8_s', index, offset, align);
-        testLoadOOB('i32', '16_s', index, offset, align);
-        testLoadOOB('i32', '', index, offset, align);
-        testLoadOOB('f32', '', index, offset, align);
-        testLoadOOB('f64', '', index, offset, align);
-    }
+        // Ensure wrapping doesn't apply.
+        offset = 0x7fffffff; // maximum allowed offset that doesn't always throw.
+        for (let index of [0, 1, 2, 3, 0x7fffffff, 0x80000000, 0x80000001]) {
+            if (align < 2) {
+                testLoadOOB('i32', '8_s', index, offset, align);
+            }
+            if (align < 4) {
+                testLoadOOB('i32', '16_s', index, offset, align);
+            }
+            testLoadOOB('i32', '', index, offset, align);
+            testLoadOOB('f32', '', index, offset, align);
+            testLoadOOB('f64', '', index, offset, align);
+        }
 
-    // Ensure out of bounds when the offset is greater than the immediate range.
-    index = 0;
-    for (let offset of [0x80000000, 0xfffffffe, 0xffffffff]) {
-        testLoadOOB('i32', '8_s', index, offset, 1);
-        testLoadOOB('i32', '16_s', index, offset, 1);
-        testLoadOOB('i32', '16_s', index, offset, 2);
-        testLoadOOB('i32', '', index, offset, 1);
-        testLoadOOB('i32', '', index, offset, 4);
-        testLoadOOB('f32', '', index, offset, 1);
-        testLoadOOB('f32', '', index, offset, 4);
-        testLoadOOB('f64', '', index, offset, 1);
-        testLoadOOB('f64', '', index, offset, 8);
-    }
+        // Ensure out of bounds when the offset is greater than the immediate range.
+        index = 0;
+        for (let offset of [0x80000000, 0xfffffffe, 0xffffffff]) {
+            testLoadOOB('i32', '8_s', index, offset, 1);
+            testLoadOOB('i32', '16_s', index, offset, 1);
+            testLoadOOB('i32', '16_s', index, offset, 2);
+            testLoadOOB('i32', '', index, offset, 1);
+            testLoadOOB('i32', '', index, offset, 4);
+            testLoadOOB('f32', '', index, offset, 1);
+            testLoadOOB('f32', '', index, offset, 4);
+            testLoadOOB('f64', '', index, offset, 1);
+            testLoadOOB('f64', '', index, offset, 8);
+        }
 
-    wasmFailValidateText('(module (memory 1) (func (f64.store offset=0 (i32.const 0) (i32.const 0))))', mismatchError("i32", "f64"));
-    wasmFailValidateText('(module (memory 1) (func (f64.store offset=0 (i32.const 0) (f32.const 0))))', mismatchError("f32", "f64"));
+        wasmFailValidateText('(module (memory 1) (func (f64.store offset=0 (i32.const 0) (i32.const 0))))', mismatchError("i32", "f64"));
+        wasmFailValidateText('(module (memory 1) (func (f64.store offset=0 (i32.const 0) (f32.const 0))))', mismatchError("f32", "f64"));
 
-    wasmFailValidateText('(module (memory 1) (func (f32.store offset=0 (i32.const 0) (i32.const 0))))', mismatchError("i32", "f32"));
-    wasmFailValidateText('(module (memory 1) (func (f32.store offset=0 (i32.const 0) (f64.const 0))))', mismatchError("f64", "f32"));
+        wasmFailValidateText('(module (memory 1) (func (f32.store offset=0 (i32.const 0) (i32.const 0))))', mismatchError("i32", "f32"));
+        wasmFailValidateText('(module (memory 1) (func (f32.store offset=0 (i32.const 0) (f64.const 0))))', mismatchError("f64", "f32"));
 
-    wasmFailValidateText('(module (memory 1) (func (i32.store offset=0 (i32.const 0) (f32.const 0))))', mismatchError("f32", "i32"));
-    wasmFailValidateText('(module (memory 1) (func (i32.store offset=0 (i32.const 0) (f64.const 0))))', mismatchError("f64", "i32"));
+        wasmFailValidateText('(module (memory 1) (func (i32.store offset=0 (i32.const 0) (f32.const 0))))', mismatchError("f32", "i32"));
+        wasmFailValidateText('(module (memory 1) (func (i32.store offset=0 (i32.const 0) (f64.const 0))))', mismatchError("f64", "i32"));
 
-    // Test high number of registers.
-    function testRegisters() {
-        assertEq(wasmEvalText(
-            `(module
+        // Test high number of registers.
+        function testRegisters() {
+            assertEq(wasmEvalText(
+                `(module
               (memory 1)
               (data (i32.const 0) "\\00\\01\\02\\03\\04\\05\\06\\07\\08\\09\\0a\\0b\\0c\\0d\\0e\\0f")
               (data (i32.const 16) "\\f0\\f1\\f2\\f3\\f4\\f5\\f6\\f7\\f8\\f9\\fa\\fb\\fc\\fd\\fe\\ff")
               (func (param i32) (local i32 i32 i32 i32 f32 f64) (result i32)
                (set_local 1 (i32.load8_s offset=4 (get_local 0)))
                (set_local 2 (i32.load16_s (get_local 1)))
                (i32.store8 offset=4 (get_local 0) (get_local 1))
                (set_local 3 (i32.load16_u (get_local 2)))
@@ -324,86 +333,91 @@ for (var foldOffsets = 0; foldOffsets <=
                  )
                  (i32.add
                   (get_local 4)
                   (i32.reinterpret/f32 (get_local 5))
                  )
                 )
                )
               ) (export "" 0))`
-        ).exports[""](1), 50464523);
-    }
+            ).exports[""](1), 50464523);
+        }
 
-    testRegisters();
+        testRegisters();
 
-    testLoad('i64', '', 0, 0, 0, '0x0706050403020100');
-    testLoad('i64', '', 1, 0, 0, '0x0807060504030201');
-    testLoad('i64', '', 0, 1, 0, '0x0807060504030201');
-    testLoad('i64', '', 1, 1, 4, '0x0908070605040302');
+        testLoad('i64', '', 0, 0, 0, '0x0706050403020100');
+        testLoad('i64', '', 1, 0, 0, '0x0807060504030201');
+        testLoad('i64', '', 0, 1, 0, '0x0807060504030201');
+        testLoad('i64', '', 1, 1, 4, '0x0908070605040302');
 
-    testLoad('i64', '8_s', 16, 0, 0, -0x10);
-    testLoad('i64', '8_u', 16, 0, 0, 0xf0);
-    testLoad('i64', '16_s', 16, 0, 0, -0xe10);
-    testLoad('i64', '16_u', 16, 0, 0, 0xf1f0);
-    testLoad('i64', '32_s', 16, 0, 0, 0xf3f2f1f0 | 0);
-    testLoad('i64', '32_u', 16, 0, 0, '0xf3f2f1f0');
+        testLoad('i64', '8_s', 16, 0, 0, -0x10);
+        testLoad('i64', '8_u', 16, 0, 0, 0xf0);
+        testLoad('i64', '16_s', 16, 0, 0, -0xe10);
+        testLoad('i64', '16_u', 16, 0, 0, 0xf1f0);
+        testLoad('i64', '32_s', 16, 0, 0, 0xf3f2f1f0 | 0);
+        testLoad('i64', '32_u', 16, 0, 0, '0xf3f2f1f0');
 
-    testStore('i64', '', 0, 0, 0, '0xc0c1d3d4e6e7090a');
-    testStore('i64', '', 1, 0, 0, '0xc0c1d3d4e6e7090a');
-    testStore('i64', '', 0, 1, 0, '0xc0c1d3d4e6e7090a');
-    testStore('i64', '', 1, 1, 4, '0xc0c1d3d4e6e7090a');
-    testStore('i64', '8', 0, 0, 0, 0x23);
-    testStore('i64', '16', 0, 0, 0, 0x23);
-    testStore('i64', '32', 0, 0, 0, 0x23);
+        testStore('i64', '', 0, 0, 0, '0xc0c1d3d4e6e7090a');
+        testStore('i64', '', 1, 0, 0, '0xc0c1d3d4e6e7090a');
+        testStore('i64', '', 0, 1, 0, '0xc0c1d3d4e6e7090a');
+        testStore('i64', '', 1, 1, 4, '0xc0c1d3d4e6e7090a');
+        testStore('i64', '8', 0, 0, 0, 0x23);
+        testStore('i64', '16', 0, 0, 0, 0x23);
+        testStore('i64', '32', 0, 0, 0, 0x23);
 
-    for (let offset of [0, 1, 2, 3, 4, 8, 16, 41, 0xfff8]) {
-        // Accesses of 1 byte.
-        let lastValidIndex = 0x10000 - 1 - offset;
+        for (let offset of [0, 1, 2, 3, 4, 8, 16, 41, 0xfff8]) {
+            // Accesses of 1 byte.
+            let lastValidIndex = 0x10000 - 1 - offset;
 
-        testLoad('i64', '8_s', lastValidIndex, offset, align, 0);
-        testLoadOOB('i64', '8_s', lastValidIndex + 1, offset, align);
+            if (align < 2) {
+                testLoad('i64', '8_s', lastValidIndex, offset, align, 0);
+                testLoadOOB('i64', '8_s', lastValidIndex + 1, offset, align);
 
-        testLoad('i64', '8_u', lastValidIndex, offset, align, 0);
-        testLoadOOB('i64', '8_u', lastValidIndex + 1, offset, align);
+                testLoad('i64', '8_u', lastValidIndex, offset, align, 0);
+                testLoadOOB('i64', '8_u', lastValidIndex + 1, offset, align);
 
-        testStore('i64', '8', lastValidIndex, offset, align, -42);
-        testStoreOOB('i64', '8', lastValidIndex + 1, offset, align, -42);
+                testStore('i64', '8', lastValidIndex, offset, align, -42);
+                testStoreOOB('i64', '8', lastValidIndex + 1, offset, align, -42);
+            }
 
-        // Accesses of 2 bytes.
-        lastValidIndex = 0x10000 - 2 - offset;
-
-        testLoad('i64', '16_s', lastValidIndex, offset, align, 0);
-        testLoadOOB('i64', '16_s', lastValidIndex + 1, offset, align);
+            // Accesses of 2 bytes.
+            lastValidIndex = 0x10000 - 2 - offset;
 
-        testLoad('i64', '16_u', lastValidIndex, offset, align, 0);
-        testLoadOOB('i64', '16_u', lastValidIndex + 1, offset, align);
+            if (align < 4) {
+                testLoad('i64', '16_s', lastValidIndex, offset, align, 0);
+                testLoadOOB('i64', '16_s', lastValidIndex + 1, offset, align);
 
-        testStore('i64', '16', lastValidIndex, offset, align, -32768);
-        testStoreOOB('i64', '16', lastValidIndex + 1, offset, align, -32768);
+                testLoad('i64', '16_u', lastValidIndex, offset, align, 0);
+                testLoadOOB('i64', '16_u', lastValidIndex + 1, offset, align);
 
-        // Accesses of 4 bytes.
-        lastValidIndex = 0x10000 - 4 - offset;
+                testStore('i64', '16', lastValidIndex, offset, align, -32768);
+                testStoreOOB('i64', '16', lastValidIndex + 1, offset, align, -32768);
+            }
 
-        testLoad('i64', '32_s', lastValidIndex, offset, align, 0);
-        testLoadOOB('i64', '32_s', lastValidIndex + 1, offset, align);
+            // Accesses of 4 bytes.
+            lastValidIndex = 0x10000 - 4 - offset;
 
-        testLoad('i64', '32_u', lastValidIndex, offset, align, 0);
-        testLoadOOB('i64', '32_u', lastValidIndex + 1, offset, align);
+            testLoad('i64', '32_s', lastValidIndex, offset, align, 0);
+            testLoadOOB('i64', '32_s', lastValidIndex + 1, offset, align);
 
-        testStore('i64', '32', lastValidIndex, offset, align, 0xf1231337 | 0);
-        testStoreOOB('i64', '32', lastValidIndex + 1, offset, align, 0xf1231337 | 0);
+            testLoad('i64', '32_u', lastValidIndex, offset, align, 0);
+            testLoadOOB('i64', '32_u', lastValidIndex + 1, offset, align);
 
-        // Accesses of 8 bytes.
-        lastValidIndex = 0x10000 - 8 - offset;
+            testStore('i64', '32', lastValidIndex, offset, align, 0xf1231337 | 0);
+            testStoreOOB('i64', '32', lastValidIndex + 1, offset, align, 0xf1231337 | 0);
+
+            // Accesses of 8 bytes.
+            lastValidIndex = 0x10000 - 8 - offset;
 
-        testLoad('i64', '', lastValidIndex, offset, align, 0);
-        testLoadOOB('i64', '', lastValidIndex + 1, offset, align);
+            testLoad('i64', '', lastValidIndex, offset, align, 0);
+            testLoadOOB('i64', '', lastValidIndex + 1, offset, align);
 
-        testStore('i64', '', lastValidIndex, offset, align, '0x1234567887654321');
-        testStoreOOB('i64', '', lastValidIndex + 1, offset, align, '0x1234567887654321');
+            testStore('i64', '', lastValidIndex, offset, align, '0x1234567887654321');
+            testStoreOOB('i64', '', lastValidIndex + 1, offset, align, '0x1234567887654321');
+        }
     }
 }
 
 setJitCompilerOption('wasm.fold-offsets', 1);
 
 // Test active segments with a memory index.
 
 {