summaryrefslogtreecommitdiffstats
path: root/js/src/jit-test/tests/wasm/directiveless
diff options
context:
space:
mode:
Diffstat (limited to 'js/src/jit-test/tests/wasm/directiveless')
-rw-r--r--js/src/jit-test/tests/wasm/directiveless/README.md1
-rw-r--r--js/src/jit-test/tests/wasm/directiveless/bug1645310.js61
-rw-r--r--js/src/jit-test/tests/wasm/directiveless/bug1664979.js21
-rw-r--r--js/src/jit-test/tests/wasm/directiveless/bug1666051.js12
-rw-r--r--js/src/jit-test/tests/wasm/directiveless/bug1877358.js14
5 files changed, 109 insertions, 0 deletions
diff --git a/js/src/jit-test/tests/wasm/directiveless/README.md b/js/src/jit-test/tests/wasm/directiveless/README.md
new file mode 100644
index 0000000000..9687e7a9b6
--- /dev/null
+++ b/js/src/jit-test/tests/wasm/directiveless/README.md
@@ -0,0 +1 @@
+DO NOT ADD A directives.txt FILE IN THIS DIRECTORY. THE TEST CASE MUST RUN WITH MINIMAL PRELIMINARIES.
diff --git a/js/src/jit-test/tests/wasm/directiveless/bug1645310.js b/js/src/jit-test/tests/wasm/directiveless/bug1645310.js
new file mode 100644
index 0000000000..3532886c6a
--- /dev/null
+++ b/js/src/jit-test/tests/wasm/directiveless/bug1645310.js
@@ -0,0 +1,61 @@
+// |jit-test| --wasm-compiler=optimizing; skip-if: !wasmIsSupported()
+
+// In this case we're setting things up so that wasm can't be compiled, as the
+// only available compiler is Ion, and enabling the Debugger will disable Ion.
+//
+// The test tests that the lazy creation of the WebAssembly object is not
+// dependent on whether WebAssembly can be compiled or not: if wasm is supported
+// then the WebAssembly object should always be created. The fact that wasm
+// can't be compiled is a separate matter.
+//
+// IT'S IMPORTANT NOT TO MENTION THE WEBASSEMBLY OBJECT UNTIL AFTER THE DEBUGGER
+// HAS BEEN CREATED, AND NOT TO LOAD lib/wasm.js OR OTHER WASM CODE HERE.
+
+var g7 = newGlobal({newCompartment: true});
+g7.parent = this;
+g7.eval("var dbg = Debugger(parent)");
+assertEq(typeof WebAssembly, "object");
+
+// Test that validation works even if compilers are not available.
+
+WebAssembly.validate(wasmTextToBinary('(module (func))'));
+
+// Test that compilation fails with a sensible error.
+
+var bits = wasmTextToBinary('(module (func))');
+var msg = /no WebAssembly compiler available/
+var exn;
+
+exn = null;
+try { new WebAssembly.Module(bits); } catch (e) { exn = e; }
+assertEq(Boolean(exn), true);
+assertEq(Boolean(String(exn).match(msg)), true);
+
+exn = null;
+try { WebAssembly.compile(bits); } catch (e) { exn = e; }
+assertEq(Boolean(exn), true);
+assertEq(Boolean(String(exn).match(msg)), true);
+
+exn = null;
+try { WebAssembly.instantiate(bits); } catch (e) { exn = e; }
+assertEq(Boolean(exn), true);
+assertEq(Boolean(String(exn).match(msg)), true);
+
+// We do not use wasmStreamingEnabled() here because that checks whether
+// compilers are available, and that is precisely what we want to be checking
+// ourselves. But streaming compilation is available only if there are helper
+// threads, so that's an OK proxy.
+
+if (helperThreadCount() > 0) {
+ exn = null;
+ WebAssembly.compileStreaming(bits).catch(e => { exn = e; });
+ drainJobQueue();
+ assertEq(Boolean(exn), true);
+ assertEq(Boolean(String(exn).match(msg)), true);
+
+ exn = null;
+ WebAssembly.instantiateStreaming(bits).catch(e => { exn = e; });
+ drainJobQueue();
+ assertEq(Boolean(exn), true);
+ assertEq(Boolean(String(exn).match(msg)), true);
+}
diff --git a/js/src/jit-test/tests/wasm/directiveless/bug1664979.js b/js/src/jit-test/tests/wasm/directiveless/bug1664979.js
new file mode 100644
index 0000000000..e6b8bd7c3c
--- /dev/null
+++ b/js/src/jit-test/tests/wasm/directiveless/bug1664979.js
@@ -0,0 +1,21 @@
+// |jit-test| --fuzzing-safe; --ion-offthread-compile=off; skip-if: !wasmIsSupported()
+
+var all = [undefined, null, ];
+function AsmModule(stdlib) {
+ "use asm";
+ var fround = stdlib.Math.fround;
+ function fltConvNot(y38) {
+ y38 = fround(y38);
+ var i38 = 0;
+ i38 = ~((~~y38) | 0);
+ return (!!i38) | 0;
+ }
+ return {
+ fltConvNot: fltConvNot,
+ };
+}
+var asmModule = AsmModule({
+ Math: Math
+});
+for (var i38 = 0; i38 < 10; ++i38)
+ asmModule.fltConvNot(all[i38])
diff --git a/js/src/jit-test/tests/wasm/directiveless/bug1666051.js b/js/src/jit-test/tests/wasm/directiveless/bug1666051.js
new file mode 100644
index 0000000000..6b94ef921e
--- /dev/null
+++ b/js/src/jit-test/tests/wasm/directiveless/bug1666051.js
@@ -0,0 +1,12 @@
+// |jit-test| --fuzzing-safe; --no-threads; --no-baseline; --no-ion; skip-if: !wasmIsSupported()
+
+(function (stdlib) {
+ "use asm";
+ var sqrt = stdlib.Math.sqrt;
+ function f(i0) {
+ i0 = i0 | 0;
+ i0 = ~~sqrt(-.5);
+ return (1 / (1 >> (.0 == .0)) & i0 >> 1);
+ }
+ return f;
+})(this)();
diff --git a/js/src/jit-test/tests/wasm/directiveless/bug1877358.js b/js/src/jit-test/tests/wasm/directiveless/bug1877358.js
new file mode 100644
index 0000000000..1f8fad0e43
--- /dev/null
+++ b/js/src/jit-test/tests/wasm/directiveless/bug1877358.js
@@ -0,0 +1,14 @@
+// |jit-test| --no-wasm-exceptions; include:wasm.js
+
+let {test} = wasmEvalText(`(module
+ (func $m (import "" "m"))
+ (func (export "test")
+ call $m
+ )
+)`, {"": {m: () => {throw 'wrap me';}}}).exports;
+
+try {
+ test();
+} catch (err) {
+ assertEq(err, 'wrap me');
+}