Bug 1603726 - Move tests to wasm/gc. r=rhunt
authorLars T Hansen <lhansen@mozilla.com>
Mon, 16 Dec 2019 08:46:32 +0000
changeset 507055 572a5cc1d0b5779c434dda5cba78a8ad59304eff
parent 507054 c53f0a1c8a8ec23c017433b7bc247676a62b3809
child 507056 f23128d93320d080700b559277b8a034744adb8b
push id36922
push userncsoregi@mozilla.com
push dateMon, 16 Dec 2019 17:21:47 +0000
treeherdermozilla-central@27d0d6cc2131 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersrhunt
bugs1603726
milestone73.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 1603726 - Move tests to wasm/gc. r=rhunt Differential Revision: https://phabricator.services.mozilla.com/D57124
js/src/jit-test/tests/wasm/gc/ref-func.js
js/src/jit-test/tests/wasm/passive-segs-nonboundary.js
--- a/js/src/jit-test/tests/wasm/gc/ref-func.js
+++ b/js/src/jit-test/tests/wasm/gc/ref-func.js
@@ -1,12 +1,15 @@
 // |jit-test| skip-if: !wasmReftypesEnabled()
 
 load(libdir + "wasm-binary.js");
 
+const v2vSig = {args:[], ret:VoidCode};
+const v2vSigSection = sigSection([v2vSig]);
+
 // 'ref.func' parses, validates and returns a non-null value
 wasmFullPass(`
 	(module
 		(elem declared $run)
 		(func $run (result i32)
 			ref.func $run
 			ref.is_null
 		)
@@ -143,8 +146,80 @@ var ins = new WebAssembly.Instance(new W
   (module
     (import $f "m" "f" (func (param i32) (result i32)))
     (elem declared $f)
     (table 1 funcref)
     (func (export "f")
       (table.set 0 (i32.const 0) (ref.func $f))))`)),
                                    {m:{f:(x) => 37+x}});
 ins.exports.f();
+
+// Verification that we can handle encoding errors for passive element segments
+// properly.
+
+function checkPassiveElemSegment(mangle, err) {
+    let bin = moduleWithSections(
+        [v2vSigSection, declSection([0]), // One function
+         tableSection(1),                 // One table
+         { name: elemId,                  // One passive segment
+           body: (function () {
+               let body = [];
+               body.push(1);           // 1 element segment
+               body.push(0x1 | 0x4);   // Flags: Passive and uses element expression
+               body.push(AnyFuncCode + (mangle == "type" ? 1 : 0)); // always anyfunc
+               body.push(1);           // Element count
+               body.push(RefFuncCode + (mangle == "ref.func" ? 1 : 0)); // always ref.func
+               body.push(0);           // func index
+               body.push(EndCode + (mangle == "end" ? 1 : 0));
+               return body;
+           })() },
+         bodySection(                   // Empty function
+             [funcBody(
+                 {locals:[],
+                  body:[]})])
+        ]);
+    if (err) {
+        assertErrorMessage(() => new WebAssembly.Module(bin),
+                           WebAssembly.CompileError,
+                           err);
+    } else {
+        new WebAssembly.Module(bin);
+    }
+}
+
+checkPassiveElemSegment("");
+checkPassiveElemSegment("type", /segments with element expressions can only contain references/);
+checkPassiveElemSegment("ref.func", /failed to read initializer operation/);
+checkPassiveElemSegment("end", /failed to read end of initializer expression/);
+
+// Passive element segments can contain literal null values.
+
+{
+    let txt =
+        `(module
+           (table (export "t") 10 funcref)
+           (elem (i32.const 1) $m)
+           (elem (i32.const 3) $m)
+           (elem (i32.const 6) $m)
+           (elem (i32.const 8) $m)
+           (elem funcref (ref.func $f) (ref.null) (ref.func $g) (ref.null) (ref.func $h))
+           (func $m)
+           (func $f)
+           (func $g)
+           (func $h)
+           (func (export "doit") (param $idx i32)
+             (table.init 4 (local.get $idx) (i32.const 0) (i32.const 5))))`;
+    let ins = wasmEvalText(txt);
+    ins.exports.doit(0);
+    ins.exports.doit(5);
+    assertEq(typeof ins.exports.t.get(0), "function");
+    assertEq(ins.exports.t.get(1), null);
+    assertEq(typeof ins.exports.t.get(2), "function");
+    assertEq(ins.exports.t.get(0) == ins.exports.t.get(2), false);
+    assertEq(ins.exports.t.get(3), null);
+    assertEq(typeof ins.exports.t.get(4), "function");
+    assertEq(typeof ins.exports.t.get(5), "function");
+    assertEq(ins.exports.t.get(6), null);
+    assertEq(typeof ins.exports.t.get(7), "function");
+    assertEq(ins.exports.t.get(8), null);
+    assertEq(typeof ins.exports.t.get(9), "function");
+}
+
--- a/js/src/jit-test/tests/wasm/passive-segs-nonboundary.js
+++ b/js/src/jit-test/tests/wasm/passive-segs-nonboundary.js
@@ -295,87 +295,16 @@ checkNoDataCount([I32ConstCode, 0,
                   I32ConstCode, 0,
                   I32ConstCode, 0,
                   MiscPrefix, MemoryInitCode, 0, 0],
                 /memory.init requires a DataCount section/);
 
 checkNoDataCount([MiscPrefix, DataDropCode, 0],
                  /data.drop requires a DataCount section/);
 
-// Verification that we can handle encoding errors for passive element segments
-// properly.
-
-function checkPassiveElemSegment(mangle, err) {
-    let bin = moduleWithSections(
-        [v2vSigSection, declSection([0]), // One function
-         tableSection(1),                 // One table
-         { name: elemId,                  // One passive segment
-           body: (function () {
-               let body = [];
-               body.push(1);           // 1 element segment
-               body.push(0x1 | 0x4);   // Flags: Passive and uses element expression
-               body.push(AnyFuncCode + (mangle == "type" ? 1 : 0)); // always anyfunc
-               body.push(1);           // Element count
-               body.push(RefFuncCode + (mangle == "ref.func" ? 1 : 0)); // always ref.func
-               body.push(0);           // func index
-               body.push(EndCode + (mangle == "end" ? 1 : 0));
-               return body;
-           })() },
-         bodySection(                   // Empty function
-             [funcBody(
-                 {locals:[],
-                  body:[]})])
-        ]);
-    if (err) {
-        assertErrorMessage(() => new WebAssembly.Module(bin),
-                           WebAssembly.CompileError,
-                           err);
-    } else {
-        new WebAssembly.Module(bin);
-    }
-}
-
-checkPassiveElemSegment("");
-checkPassiveElemSegment("type", /segments with element expressions can only contain references/);
-checkPassiveElemSegment("ref.func", /failed to read initializer operation/);
-checkPassiveElemSegment("end", /failed to read end of initializer expression/);
-
-// Passive element segments can contain literal null values.
-
-{
-    let txt =
-        `(module
-           (table (export "t") 10 funcref)
-           (elem (i32.const 1) $m)
-           (elem (i32.const 3) $m)
-           (elem (i32.const 6) $m)
-           (elem (i32.const 8) $m)
-           (elem funcref (ref.func $f) (ref.null) (ref.func $g) (ref.null) (ref.func $h))
-           (func $m)
-           (func $f)
-           (func $g)
-           (func $h)
-           (func (export "doit") (param $idx i32)
-             (table.init 4 (local.get $idx) (i32.const 0) (i32.const 5))))`;
-    let ins = wasmEvalText(txt);
-    ins.exports.doit(0);
-    ins.exports.doit(5);
-    assertEq(typeof ins.exports.t.get(0), "function");
-    assertEq(ins.exports.t.get(1), null);
-    assertEq(typeof ins.exports.t.get(2), "function");
-    assertEq(ins.exports.t.get(0) == ins.exports.t.get(2), false);
-    assertEq(ins.exports.t.get(3), null);
-    assertEq(typeof ins.exports.t.get(4), "function");
-    assertEq(typeof ins.exports.t.get(5), "function");
-    assertEq(ins.exports.t.get(6), null);
-    assertEq(typeof ins.exports.t.get(7), "function");
-    assertEq(ins.exports.t.get(8), null);
-    assertEq(typeof ins.exports.t.get(9), "function");
-}
-
 //---------------------------------------------------------------------//
 //---------------------------------------------------------------------//
 // Some further tests for memory.copy and memory.fill.  First, validation
 // tests.
 
 // Prefixed opcodes
 
 function checkMiscPrefixed(opcode, expect_failure) {