summaryrefslogtreecommitdiffstats
path: root/js/src/jit-test/tests/wasm/timeout
diff options
context:
space:
mode:
Diffstat (limited to 'js/src/jit-test/tests/wasm/timeout')
-rw-r--r--js/src/jit-test/tests/wasm/timeout/1.js15
-rw-r--r--js/src/jit-test/tests/wasm/timeout/2.js30
-rw-r--r--js/src/jit-test/tests/wasm/timeout/debug-interrupt-1.js23
-rw-r--r--js/src/jit-test/tests/wasm/timeout/debug-interrupt-2.js28
-rw-r--r--js/src/jit-test/tests/wasm/timeout/debug-noprofiling.js31
-rw-r--r--js/src/jit-test/tests/wasm/timeout/directives.txt2
-rw-r--r--js/src/jit-test/tests/wasm/timeout/interrupt-multi-instance-activation.js28
-rw-r--r--js/src/jit-test/tests/wasm/timeout/interrupt-several-instances.js21
-rw-r--r--js/src/jit-test/tests/wasm/timeout/stack-overflow.js97
-rw-r--r--js/src/jit-test/tests/wasm/timeout/while-profiling.js19
10 files changed, 294 insertions, 0 deletions
diff --git a/js/src/jit-test/tests/wasm/timeout/1.js b/js/src/jit-test/tests/wasm/timeout/1.js
new file mode 100644
index 0000000000..f731e7910f
--- /dev/null
+++ b/js/src/jit-test/tests/wasm/timeout/1.js
@@ -0,0 +1,15 @@
+// |jit-test| exitstatus: 6; skip-if: !wasmIsSupported()
+
+// Don't include wasm.js in timeout tests: when wasm isn't supported, it will
+// quit(0) which will cause the test to fail.
+
+var code = wasmTextToBinary(`(module
+ (func (export "iloop")
+ (loop $top br $top)
+ )
+)`);
+
+var i = new WebAssembly.Instance(new WebAssembly.Module(code));
+timeout(1);
+i.exports.iloop();
+assertEq(true, false);
diff --git a/js/src/jit-test/tests/wasm/timeout/2.js b/js/src/jit-test/tests/wasm/timeout/2.js
new file mode 100644
index 0000000000..25267f226c
--- /dev/null
+++ b/js/src/jit-test/tests/wasm/timeout/2.js
@@ -0,0 +1,30 @@
+// |jit-test| exitstatus: 6; skip-if: !wasmIsSupported()
+
+// Don't include wasm.js in timeout tests: when wasm isn't supported, it will
+// quit(0) which will cause the test to fail.
+
+var tbl = new WebAssembly.Table({initial:1, element:"anyfunc"});
+
+new WebAssembly.Instance(new WebAssembly.Module(wasmTextToBinary(`(module
+ (import "imports" "tbl" (table 1 funcref))
+ (func $iloop
+ loop $top
+ br $top
+ end
+ )
+ (elem (i32.const 0) $iloop)
+)`)), {imports:{tbl}});
+
+var outer = new WebAssembly.Instance(new WebAssembly.Module(wasmTextToBinary(`(module
+ (import "imports" "tbl" (table 1 funcref))
+ (type $v2v (func))
+ (func (export "run")
+ i32.const 0
+ call_indirect (type $v2v)
+ )
+)`)), {imports:{tbl}});
+
+setJitCompilerOption('simulator.always-interrupt', 1);
+timeout(1, () => { tbl.set(0, null); gc() });
+outer.exports.run();
+assertEq(true, false);
diff --git a/js/src/jit-test/tests/wasm/timeout/debug-interrupt-1.js b/js/src/jit-test/tests/wasm/timeout/debug-interrupt-1.js
new file mode 100644
index 0000000000..940bde07a1
--- /dev/null
+++ b/js/src/jit-test/tests/wasm/timeout/debug-interrupt-1.js
@@ -0,0 +1,23 @@
+// |jit-test| exitstatus: 6; skip-if: !wasmDebuggingEnabled()
+
+// Don't include wasm.js in timeout tests: when wasm isn't supported, it will
+// quit(0) which will cause the test to fail.
+
+// Note: this test triggers an interrupt and then iloops in Wasm code. If the
+// interrupt fires before the Wasm code is compiled, the test relies on the
+// JS interrupt check in onEnterFrame to catch it. Warp/Ion code however can
+// elide the combined interrupt/overrecursion check in simple leaf functions.
+// Long story short, set the Warp threshold to a non-zero value to prevent
+// intermittent timeouts with --ion-eager.
+setJitCompilerOption("ion.warmup.trigger", 30);
+
+var g = newGlobal({newCompartment: true});
+g.parent = this;
+g.eval("Debugger(parent).onEnterFrame = function() {};");
+timeout(0.01);
+var code = wasmTextToBinary(`(module
+ (func (export "f1")
+ (loop $top br $top)
+ )
+)`);
+new WebAssembly.Instance(new WebAssembly.Module(code)).exports.f1();
diff --git a/js/src/jit-test/tests/wasm/timeout/debug-interrupt-2.js b/js/src/jit-test/tests/wasm/timeout/debug-interrupt-2.js
new file mode 100644
index 0000000000..7c0d16aeae
--- /dev/null
+++ b/js/src/jit-test/tests/wasm/timeout/debug-interrupt-2.js
@@ -0,0 +1,28 @@
+// |jit-test| exitstatus: 6; skip-if: !wasmDebuggingEnabled()
+
+// Don't include wasm.js in timeout tests: when wasm isn't supported, it will
+// quit(0) which will cause the test to fail.
+
+// Note: this test triggers an interrupt and then iloops in Wasm code. If the
+// interrupt fires before the Wasm code is compiled, the test relies on the
+// JS interrupt check in onEnterFrame to catch it. Warp/Ion code however can
+// elide the combined interrupt/overrecursion check in simple leaf functions.
+// Long story short, set the Warp threshold to a non-zero value to prevent
+// intermittent timeouts with --ion-eager.
+setJitCompilerOption("ion.warmup.trigger", 30);
+
+var g = newGlobal({newCompartment: true});
+g.parent = this;
+g.eval("Debugger(parent).onEnterFrame = function() {};");
+timeout(0.01);
+var code = wasmTextToBinary(`(module
+ (func $f2
+ loop $top
+ br $top
+ end
+ )
+ (func (export "f1")
+ call $f2
+ )
+)`);
+new WebAssembly.Instance(new WebAssembly.Module(code)).exports.f1();
diff --git a/js/src/jit-test/tests/wasm/timeout/debug-noprofiling.js b/js/src/jit-test/tests/wasm/timeout/debug-noprofiling.js
new file mode 100644
index 0000000000..5b1cdd4192
--- /dev/null
+++ b/js/src/jit-test/tests/wasm/timeout/debug-noprofiling.js
@@ -0,0 +1,31 @@
+// |jit-test| exitstatus: 6; skip-if: !wasmDebuggingEnabled()
+
+// Don't include wasm.js in timeout tests: when wasm isn't supported, it will
+// quit(0) which will cause the test to fail.
+
+newGlobal({newCompartment: true}).Debugger().addDebuggee(this);
+
+var t = new WebAssembly.Table({
+ initial: 1,
+ element: "anyfunc"
+});
+
+new WebAssembly.Instance(new WebAssembly.Module(wasmTextToBinary(`
+(module
+ (import "imports" "t" (table 1 funcref))
+ (func $iloop loop $top br $top end)
+ (elem (i32.const 0) $iloop))
+`)), { imports: { t } });
+
+outer = new WebAssembly.Instance(new WebAssembly.Module(wasmTextToBinary(`
+(module
+ (import "imports" "t" (table 1 funcref))
+ (type $v2v (func))
+ (func (export "run")
+ i32.const 0
+ call_indirect (type $v2v))
+ )`)), { imports: { t } });
+
+setJitCompilerOption('simulator.always-interrupt', 1);
+timeout(1);
+outer.exports.run();
diff --git a/js/src/jit-test/tests/wasm/timeout/directives.txt b/js/src/jit-test/tests/wasm/timeout/directives.txt
new file mode 100644
index 0000000000..08048b372f
--- /dev/null
+++ b/js/src/jit-test/tests/wasm/timeout/directives.txt
@@ -0,0 +1,2 @@
+|jit-test| test-also=--wasm-compiler=optimizing; test-also=--wasm-compiler=baseline; test-also=--test-wasm-await-tier2; test-also=--disable-wasm-huge-memory; skip-variant-if: --disable-wasm-huge-memory, !wasmHugeMemorySupported();
+
diff --git a/js/src/jit-test/tests/wasm/timeout/interrupt-multi-instance-activation.js b/js/src/jit-test/tests/wasm/timeout/interrupt-multi-instance-activation.js
new file mode 100644
index 0000000000..05ac7ff51a
--- /dev/null
+++ b/js/src/jit-test/tests/wasm/timeout/interrupt-multi-instance-activation.js
@@ -0,0 +1,28 @@
+// |jit-test| exitstatus: 6; skip-if: !wasmIsSupported()
+
+const {Module, Instance} = WebAssembly;
+
+const {innerWasm} = new Instance(new Module(wasmTextToBinary(`(module
+ (func (export "innerWasm") (result i32)
+ (local i32)
+ (loop $top
+ (local.set 0 (i32.add (local.get 0) (i32.const 1)))
+ (br_if $top (i32.lt_u (local.get 0) (i32.const 100000)))
+ )
+ (local.get 0)
+ )
+)`))).exports;
+
+function middleJS() {
+ innerWasm();
+}
+
+const {outerWasm} = new Instance(new Module(wasmTextToBinary(`(module
+ (func $middleJS (import "" "middleJS"))
+ (func (export "outerWasm") (call $middleJS))
+)`)), {'':{middleJS}}).exports;
+
+timeout(1);
+while (true) {
+ outerWasm();
+}
diff --git a/js/src/jit-test/tests/wasm/timeout/interrupt-several-instances.js b/js/src/jit-test/tests/wasm/timeout/interrupt-several-instances.js
new file mode 100644
index 0000000000..58dc642d16
--- /dev/null
+++ b/js/src/jit-test/tests/wasm/timeout/interrupt-several-instances.js
@@ -0,0 +1,21 @@
+// |jit-test| exitstatus: 6; skip-if: !wasmIsSupported()
+
+// Don't include wasm.js in timeout tests: when wasm isn't supported, it will
+// quit(0) which will cause the test to fail.
+
+load(libdir + "asm.js");
+
+var code = `
+ var out = ffi.out;
+ function f() {
+ out();
+ }
+ return f;
+`;
+
+var ffi = {};
+ffi.out = new WebAssembly.Instance(new WebAssembly.Module(wasmTextToBinary('(module (func (export "f") (loop $top (br $top))))'))).exports.f;
+
+timeout(1);
+asmLink(asmCompile('glob', 'ffi', USE_ASM + code), this, ffi)();
+assertEq(true, false);
diff --git a/js/src/jit-test/tests/wasm/timeout/stack-overflow.js b/js/src/jit-test/tests/wasm/timeout/stack-overflow.js
new file mode 100644
index 0000000000..cf79b7d84c
--- /dev/null
+++ b/js/src/jit-test/tests/wasm/timeout/stack-overflow.js
@@ -0,0 +1,97 @@
+// |jit-test| exitstatus: 3; skip-if: !wasmIsSupported()
+
+let { exports } = new WebAssembly.Instance(
+ new WebAssembly.Module(wasmTextToBinary(`
+ (module
+ (func (export "f") (param i32) (param i32) (param i32) (param i32) (result i32)
+ get_local 0
+ i32.popcnt
+ get_local 1
+ i32.popcnt
+ i32.add
+
+ get_local 2
+ i32.popcnt
+ get_local 3
+ i32.popcnt
+ i32.add
+
+ get_local 0
+ get_local 1
+ i32.sub
+
+ get_local 2
+ get_local 3
+ i32.sub
+
+ get_local 0
+ get_local 1
+ i32.mul
+
+ get_local 2
+ get_local 3
+ i32.mul
+
+ get_local 0
+ get_local 2
+ i32.sub
+
+ get_local 1
+ get_local 3
+ i32.sub
+
+ get_local 0
+ get_local 1
+ i32.add
+
+ get_local 2
+ get_local 3
+ i32.add
+
+ get_local 0
+ get_local 2
+ i32.add
+
+ get_local 1
+ get_local 3
+ i32.add
+
+ get_local 0
+ i32.ctz
+ get_local 1
+ i32.ctz
+ i32.add
+
+ get_local 2
+ i32.ctz
+ get_local 3
+ i32.ctz
+
+ get_local 0
+ get_local 1
+ get_local 2
+ get_local 3
+ call 0
+
+ i32.add
+ i32.add
+ i32.add
+ i32.add
+ i32.add
+ i32.add
+ i32.add
+ i32.add
+ i32.add
+ i32.add
+ i32.add
+ i32.add
+ i32.add
+ i32.add
+ i32.add
+ )
+ )
+ `))
+);
+
+timeout(1, function() {});
+exports.f()
diff --git a/js/src/jit-test/tests/wasm/timeout/while-profiling.js b/js/src/jit-test/tests/wasm/timeout/while-profiling.js
new file mode 100644
index 0000000000..1c008f0d94
--- /dev/null
+++ b/js/src/jit-test/tests/wasm/timeout/while-profiling.js
@@ -0,0 +1,19 @@
+// |jit-test| exitstatus: 6; skip-if: !wasmIsSupported() || !getBuildConfiguration()['arm-simulator']
+
+// Single-step profiling currently only works in the ARM simulator
+
+// Don't include wasm.js in timeout tests: when wasm isn't supported, it will
+// quit(0) which will cause the test to fail.
+
+var code = wasmTextToBinary(`(module
+ (func (export "iloop")
+ (loop $top br $top)
+ )
+)`);
+
+enableGeckoProfiling();
+enableSingleStepProfiling();
+var i = new WebAssembly.Instance(new WebAssembly.Module(code));
+timeout(.1);
+i.exports.iloop();
+assertEq(true, false);