Bug 1532306 - Simplify a test case. r=jseward
authorLars T Hansen <lhansen@mozilla.com>
Mon, 04 Mar 2019 16:06:29 +0100
changeset 520276 c950aab1619a8c1e6f60b3e4badffc2745acc81a
parent 520275 97b4af9b538e1e93da307dbcf4adeb757bc4cd87
child 520277 cbdb07ca9e95c649184ed26084d0d7a7ca1abbda
push id10862
push userffxbld-merge
push dateMon, 11 Mar 2019 13:01:11 +0000
treeherdermozilla-beta@a2e7f5c935da [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjseward
bugs1532306
milestone67.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 1532306 - Simplify a test case. r=jseward The tab_test() would compile and link the module for every element of the result array, but the module should be invariant for the result array, so this is not necessary. Differential Revision: https://phabricator.services.mozilla.com/D21933
js/src/jit-test/tests/wasm/passive-segs-nonboundary.js
--- a/js/src/jit-test/tests/wasm/passive-segs-nonboundary.js
+++ b/js/src/jit-test/tests/wasm/passive-segs-nonboundary.js
@@ -19,21 +19,21 @@ let tab_expmod_t =
         (func (export "ef1") (result i32) (i32.const 1))
         (func (export "ef2") (result i32) (i32.const 2))
         (func (export "ef3") (result i32) (i32.const 3))
         (func (export "ef4") (result i32) (i32.const 4))
      )`;
 
 // .. and this one imports those 5 functions.  It adds 5 of its own, creates a
 // 30 element table using both active and passive initialisers, with a mixture
-// of the imported and local functions.  |testfn| is exported.  It uses the
-// supplied |insn| to modify the table somehow, and then will indirect-call
-// the table entry number specified as a parameter.  That will either return a
-// value 0 to 9 indicating the function called, or will throw an exception if
-// the table entry is empty.
+// of the imported and local functions.  |setup| and |check| are exported.
+// |setup| uses the supplied |insn| to modify the table somehow.  |check| will
+// indirect-call the table entry number specified as a parameter.  That will
+// either return a value 0 to 9 indicating the function called, or will throw an
+// exception if the table entry is empty.
 function gen_tab_impmod_t(insn)
 {
   let t =
   `(module
      ;; -------- Types --------
      (type (func (result i32)))  ;; type #0
      ;; -------- Tables --------
      (table 30 30 funcref)
@@ -50,18 +50,19 @@ function gen_tab_impmod_t(insn)
      (import "a" "if4" (result i32))    ;; index 4
      ;; -------- Functions --------
      (func (result i32) (i32.const 5))  ;; index 5
      (func (result i32) (i32.const 6))
      (func (result i32) (i32.const 7))
      (func (result i32) (i32.const 8))
      (func (result i32) (i32.const 9))  ;; index 9
 
-     (func (export "testfn") (param i32) (result i32)
-       ${insn}
+     (func (export "setup")
+       ${insn})
+     (func (export "check") (param i32) (result i32)
        ;; call the selected table entry, which will either return a value,
        ;; or will cause an exception.
        get_local 0      ;; callIx
        call_indirect 0  ;; and its return value is our return value.
      )
    )`;
    return t;
 };
@@ -74,28 +75,30 @@ function gen_tab_impmod_t(insn)
 function tab_test(instruction, expected_result_vector)
 {
     let tab_expmod_b = wasmTextToBinary(tab_expmod_t);
     let tab_expmod_i = new Instance(new Module(tab_expmod_b));
 
     let tab_impmod_t = gen_tab_impmod_t(instruction);
     let tab_impmod_b = wasmTextToBinary(tab_impmod_t);
 
+    let inst = new Instance(new Module(tab_impmod_b),
+                            {a:{if0:tab_expmod_i.exports.ef0,
+                                if1:tab_expmod_i.exports.ef1,
+                                if2:tab_expmod_i.exports.ef2,
+                                if3:tab_expmod_i.exports.ef3,
+                                if4:tab_expmod_i.exports.ef4
+                               }});
+    inst.exports.setup();
+
     for (let i = 0; i < expected_result_vector.length; i++) {
-        let inst = new Instance(new Module(tab_impmod_b),
-                                {a:{if0:tab_expmod_i.exports.ef0,
-                                    if1:tab_expmod_i.exports.ef1,
-                                    if2:tab_expmod_i.exports.ef2,
-                                    if3:tab_expmod_i.exports.ef3,
-                                    if4:tab_expmod_i.exports.ef4
-                                   }});
         let expected = expected_result_vector[i];
         let actual = undefined;
         try {
-            actual = inst.exports.testfn(i);
+            actual = inst.exports.check(i);
             assertEq(actual !== null, true);
         } catch (e) {
             if (!(e instanceof Error &&
                   e.message.match(/indirect call to null/)))
                 throw e;
             // actual remains undefined
         }
         assertEq(actual, expected,