mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-30 16:22:00 +00:00
Backed out changeset 6fdd8e351ba3 (bug 1747450) for causing SM bustages on simd_address.wast.js CLOSED TREE
This commit is contained in:
parent
5f93ec58df
commit
feadfdb6b8
@ -7,4 +7,4 @@ update:
|
||||
rm -r ../../tests/wasm/spec
|
||||
cp -R generate-spectests/tests/js ../../tests/wasm/spec
|
||||
echo $(warning) > ../../tests/wasm/spec/README.md
|
||||
[ -f ./spec-tests.patch ] && (cd ../../tests/wasm/spec && patch -u -p7 < ../../../etc/wasm/spec-tests.patch)
|
||||
[ ! -d ./spec-tests.patch ] || (cd ../../tests/wasm/spec && patch -u -p7 < ../../../etc/wasm/spec-tests.patch)
|
||||
|
@ -1,18 +1,18 @@
|
||||
[[repos]]
|
||||
name = 'spec'
|
||||
commit = 'ffb5e3b4'
|
||||
|
||||
[[repos]]
|
||||
name = 'threads'
|
||||
commit = '85b562cd'
|
||||
commit = 'dfdcb81a'
|
||||
|
||||
[[repos]]
|
||||
name = 'spec'
|
||||
commit = 'c9ed6580'
|
||||
|
||||
[[repos]]
|
||||
name = 'simd'
|
||||
commit = 'a78b98a6'
|
||||
commit = '1618b39a'
|
||||
|
||||
[[repos]]
|
||||
name = 'exception-handling'
|
||||
commit = '76419ef8'
|
||||
commit = '7fcfe173'
|
||||
|
||||
[[repos]]
|
||||
name = 'memory64'
|
||||
|
@ -1,90 +0,0 @@
|
||||
# HG changeset patch
|
||||
# User Lars T Hansen <lhansen@mozilla.com>
|
||||
# Date 1634962581 0
|
||||
# Sat Oct 23 04:16:21 2021 +0000
|
||||
# Node ID 1342a887d949e1a0f23da8c0421c7bfa46328e92
|
||||
# Parent ae6e0144bd5b37d044c34d62fd9d4a449b835a0e
|
||||
Bug 1737225 - Disable some tests on arm. r=yury
|
||||
|
||||
Disable a partial-oob test on arm/arm64 because some hardware will
|
||||
perform byte-at-a-time writes at the end of the heap, and we have
|
||||
not fixed that yet.
|
||||
|
||||
Differential Revision: https://phabricator.services.mozilla.com/D129248
|
||||
|
||||
diff --git a/js/src/jit-test/tests/wasm/spec/memory64/align64.wast.js b/js/src/jit-test/tests/wasm/spec/memory64/align64.wast.js
|
||||
--- a/js/src/jit-test/tests/wasm/spec/memory64/align64.wast.js
|
||||
+++ b/js/src/jit-test/tests/wasm/spec/memory64/align64.wast.js
|
||||
@@ -1445,11 +1445,15 @@ let $24 = instantiate(`(module
|
||||
)
|
||||
)`);
|
||||
|
||||
-// ./test/core/align64.wast:864
|
||||
-assert_trap(
|
||||
- () => invoke($24, `store`, [65532n, -1n]),
|
||||
- `out of bounds memory access`,
|
||||
-);
|
||||
+// Bug 1737225 - do not observe the partial store caused by bug 1666747 on
|
||||
+// some native platforms.
|
||||
+if (!partialOobWriteMayWritePartialData()) {
|
||||
+ // ./test/core/align64.wast:864
|
||||
+ assert_trap(
|
||||
+ () => invoke($24, `store`, [65532n, -1n]),
|
||||
+ `out of bounds memory access`,
|
||||
+ );
|
||||
|
||||
-// ./test/core/align64.wast:866
|
||||
-assert_return(() => invoke($24, `load`, [65532n]), [value("i32", 0)]);
|
||||
+ // ./test/core/align64.wast:866
|
||||
+ assert_return(() => invoke($24, `load`, [65532n]), [value("i32", 0)]);
|
||||
+}
|
||||
diff --git a/js/src/jit-test/tests/wasm/spec/memory64/harness/harness.js b/js/src/jit-test/tests/wasm/spec/memory64/harness/harness.js
|
||||
--- a/js/src/jit-test/tests/wasm/spec/memory64/harness/harness.js
|
||||
+++ b/js/src/jit-test/tests/wasm/spec/memory64/harness/harness.js
|
||||
@@ -19,6 +19,17 @@ if (!wasmIsSupported()) {
|
||||
quit();
|
||||
}
|
||||
|
||||
+function partialOobWriteMayWritePartialData() {
|
||||
+ let cfg = getBuildConfiguration();
|
||||
+ let arm_native = cfg["arm"] && !cfg["arm-simulator"];
|
||||
+ let arm64_native = cfg["arm64"] && !cfg["arm64-simulator"];
|
||||
+ return arm_native || arm64_native;
|
||||
+}
|
||||
+
|
||||
+let cfg = getBuildConfiguration();
|
||||
+let native_arm = cfg["arm"] && !cfg["arm-simulator"];
|
||||
+let native_arm64 = cfg["arm64"] && !cfg["arm64-simulator"];
|
||||
+
|
||||
function bytes(type, bytes) {
|
||||
var typedBuffer = new Uint8Array(bytes);
|
||||
return wasmGlobalFromArrayBuffer(type, typedBuffer.buffer);
|
||||
diff --git a/js/src/jit-test/tests/wasm/spec/memory64/memory_trap64.wast.js b/js/src/jit-test/tests/wasm/spec/memory64/memory_trap64.wast.js
|
||||
--- a/js/src/jit-test/tests/wasm/spec/memory64/memory_trap64.wast.js
|
||||
+++ b/js/src/jit-test/tests/wasm/spec/memory64/memory_trap64.wast.js
|
||||
@@ -1028,12 +1028,17 @@ assert_trap(
|
||||
`out of bounds memory access`,
|
||||
);
|
||||
|
||||
-// ./test/core/memory_trap64.wast:268
|
||||
-assert_return(() => invoke($1, `i64.load`, [65528n]), [
|
||||
- value("i64", 7523094288207667809n),
|
||||
-]);
|
||||
+// Bug 1737225 - do not observe the partial store caused by bug 1666747 on
|
||||
+// some native platforms.
|
||||
+if (!partialOobWriteMayWritePartialData()) {
|
||||
+ // ./test/core/memory_trap64.wast:268
|
||||
+ assert_return(() => invoke($1, `i64.load`, [65528n]), [
|
||||
+ value("i64", 7523094288207667809n),
|
||||
+ ]);
|
||||
|
||||
-// ./test/core/memory_trap64.wast:269
|
||||
-assert_return(() => invoke($1, `i64.load`, [0n]), [
|
||||
- value("i64", 7523094288207667809n),
|
||||
-]);
|
||||
+ // ./test/core/memory_trap64.wast:269
|
||||
+ assert_return(() => invoke($1, `i64.load`, [0n]), [
|
||||
+ value("i64", 7523094288207667809n),
|
||||
+ ]);
|
||||
+}
|
||||
+
|
@ -79,65 +79,37 @@ let $0 = instantiate(`(module
|
||||
)
|
||||
)
|
||||
)
|
||||
|
||||
(func (export "rethrow-stack-polymorphism")
|
||||
(try
|
||||
(do (throw $$e0))
|
||||
(catch $$e0 (i32.const 1) (rethrow 0))
|
||||
)
|
||||
)
|
||||
)`);
|
||||
|
||||
// ./test/core/rethrow.wast:75
|
||||
// ./test/core/rethrow.wast:68
|
||||
assert_exception(() => invoke($0, `catch-rethrow-0`, []));
|
||||
|
||||
// ./test/core/rethrow.wast:77
|
||||
// ./test/core/rethrow.wast:70
|
||||
assert_exception(() => invoke($0, `catch-rethrow-1`, [0]));
|
||||
|
||||
// ./test/core/rethrow.wast:78
|
||||
// ./test/core/rethrow.wast:71
|
||||
assert_return(() => invoke($0, `catch-rethrow-1`, [1]), [value("i32", 23)]);
|
||||
|
||||
// ./test/core/rethrow.wast:80
|
||||
// ./test/core/rethrow.wast:73
|
||||
assert_exception(() => invoke($0, `catchall-rethrow-0`, []));
|
||||
|
||||
// ./test/core/rethrow.wast:82
|
||||
// ./test/core/rethrow.wast:75
|
||||
assert_exception(() => invoke($0, `catchall-rethrow-1`, [0]));
|
||||
|
||||
// ./test/core/rethrow.wast:83
|
||||
// ./test/core/rethrow.wast:76
|
||||
assert_return(() => invoke($0, `catchall-rethrow-1`, [1]), [value("i32", 23)]);
|
||||
|
||||
// ./test/core/rethrow.wast:84
|
||||
// ./test/core/rethrow.wast:77
|
||||
assert_exception(() => invoke($0, `rethrow-nested`, [0]));
|
||||
|
||||
// ./test/core/rethrow.wast:85
|
||||
// ./test/core/rethrow.wast:78
|
||||
assert_exception(() => invoke($0, `rethrow-nested`, [1]));
|
||||
|
||||
// ./test/core/rethrow.wast:86
|
||||
// ./test/core/rethrow.wast:79
|
||||
assert_return(() => invoke($0, `rethrow-nested`, [2]), [value("i32", 23)]);
|
||||
|
||||
// ./test/core/rethrow.wast:88
|
||||
// ./test/core/rethrow.wast:81
|
||||
assert_return(() => invoke($0, `rethrow-recatch`, [0]), [value("i32", 23)]);
|
||||
|
||||
// ./test/core/rethrow.wast:89
|
||||
// ./test/core/rethrow.wast:82
|
||||
assert_return(() => invoke($0, `rethrow-recatch`, [1]), [value("i32", 42)]);
|
||||
|
||||
// ./test/core/rethrow.wast:91
|
||||
assert_exception(() => invoke($0, `rethrow-stack-polymorphism`, []));
|
||||
|
||||
// ./test/core/rethrow.wast:93
|
||||
assert_invalid(
|
||||
() => instantiate(`(module (func (rethrow 0)))`),
|
||||
`invalid rethrow label`,
|
||||
);
|
||||
|
||||
// ./test/core/rethrow.wast:94
|
||||
assert_invalid(
|
||||
() => instantiate(`(module (func (block (rethrow 0))))`),
|
||||
`invalid rethrow label`,
|
||||
);
|
||||
|
||||
// ./test/core/rethrow.wast:95
|
||||
assert_invalid(
|
||||
() => instantiate(`(module (func (try (do (rethrow 0)) (delegate 0))))`),
|
||||
`invalid rethrow label`,
|
||||
);
|
||||
|
@ -70,19 +70,3 @@ assert_exception(() => invoke($0, `throw-param-f64`, [value("f64", 5)]));
|
||||
|
||||
// ./test/core/throw.wast:45
|
||||
assert_return(() => invoke($0, `test-throw-1-2`, []), []);
|
||||
|
||||
// ./test/core/throw.wast:47
|
||||
assert_invalid(() => instantiate(`(module (func (throw 0)))`), `unknown tag 0`);
|
||||
|
||||
// ./test/core/throw.wast:48
|
||||
assert_invalid(
|
||||
() => instantiate(`(module (tag (param i32)) (func (throw 0)))`),
|
||||
`type mismatch: instruction requires [i32] but stack has []`,
|
||||
);
|
||||
|
||||
// ./test/core/throw.wast:50
|
||||
assert_invalid(
|
||||
() =>
|
||||
instantiate(`(module (tag (param i32)) (func (i64.const 5) (throw 0)))`),
|
||||
`type mismatch: instruction requires [i32] but stack has [i64]`,
|
||||
);
|
||||
|
@ -177,16 +177,13 @@ assert_return(() => invoke($1, `simple-throw-catch`, [0]), [value("i32", 23)]);
|
||||
assert_return(() => invoke($1, `simple-throw-catch`, [1]), [value("i32", 42)]);
|
||||
|
||||
// ./test/core/try_catch.wast:157
|
||||
assert_trap(() => invoke($1, `unreachable-not-caught`, []), `unreachable`);
|
||||
assert_exception(() => invoke($1, `unreachable-not-caught`, []));
|
||||
|
||||
// ./test/core/try_catch.wast:159
|
||||
assert_return(() => invoke($1, `trap-in-callee`, [7, 2]), [value("i32", 3)]);
|
||||
|
||||
// ./test/core/try_catch.wast:160
|
||||
assert_trap(
|
||||
() => invoke($1, `trap-in-callee`, [1, 0]),
|
||||
`integer divide by zero`,
|
||||
);
|
||||
assert_exception(() => invoke($1, `trap-in-callee`, [1, 0]));
|
||||
|
||||
// ./test/core/try_catch.wast:162
|
||||
assert_return(() => invoke($1, `catch-complex-1`, [0]), [value("i32", 3)]);
|
||||
@ -269,81 +266,19 @@ assert_return(() => invoke($1, `catchless-try`, [0]), [value("i32", 0)]);
|
||||
assert_return(() => invoke($1, `catchless-try`, [1]), [value("i32", 1)]);
|
||||
|
||||
// ./test/core/try_catch.wast:191
|
||||
let $2 = instantiate(`(module
|
||||
(func $$imported-throw (import "test" "throw"))
|
||||
(tag $$e0)
|
||||
|
||||
(func (export "imported-mismatch") (result i32)
|
||||
(try (result i32)
|
||||
(do
|
||||
(try (result i32)
|
||||
(do
|
||||
(i32.const 1)
|
||||
(call $$imported-throw)
|
||||
)
|
||||
(catch $$e0 (i32.const 2))
|
||||
)
|
||||
)
|
||||
(catch_all (i32.const 3))
|
||||
)
|
||||
)
|
||||
)`);
|
||||
|
||||
// ./test/core/try_catch.wast:211
|
||||
assert_return(() => invoke($2, `imported-mismatch`, []), [value("i32", 3)]);
|
||||
|
||||
// ./test/core/try_catch.wast:213
|
||||
assert_malformed(
|
||||
() => instantiate(`(module (func (catch_all))) `),
|
||||
`unexpected token`,
|
||||
);
|
||||
|
||||
// ./test/core/try_catch.wast:218
|
||||
// ./test/core/try_catch.wast:196
|
||||
assert_malformed(
|
||||
() => instantiate(`(module (tag $$e) (func (catch $$e))) `),
|
||||
`unexpected token`,
|
||||
);
|
||||
|
||||
// ./test/core/try_catch.wast:223
|
||||
// ./test/core/try_catch.wast:201
|
||||
assert_malformed(
|
||||
() => instantiate(`(module (func (try (do) (catch_all) (catch_all)))) `),
|
||||
`unexpected token`,
|
||||
);
|
||||
|
||||
// ./test/core/try_catch.wast:230
|
||||
assert_invalid(
|
||||
() => instantiate(`(module (func (result i32) (try (result i32) (do))))`),
|
||||
`type mismatch: instruction requires [i32] but stack has []`,
|
||||
);
|
||||
|
||||
// ./test/core/try_catch.wast:232
|
||||
assert_invalid(
|
||||
() =>
|
||||
instantiate(
|
||||
`(module (func (result i32) (try (result i32) (do (i64.const 42)))))`,
|
||||
),
|
||||
`type mismatch: instruction requires [i32] but stack has [i64]`,
|
||||
);
|
||||
|
||||
// ./test/core/try_catch.wast:234
|
||||
assert_invalid(
|
||||
() =>
|
||||
instantiate(`(module (tag) (func (try (do) (catch 0 (i32.const 42)))))`),
|
||||
`type mismatch: block requires [] but stack has [i32]`,
|
||||
);
|
||||
|
||||
// ./test/core/try_catch.wast:236
|
||||
assert_invalid(
|
||||
() =>
|
||||
instantiate(`(module
|
||||
(tag (param i64))
|
||||
(func (result i32)
|
||||
(try (result i32) (do (i32.const 42)) (catch 0))))`),
|
||||
`type mismatch: instruction requires [i32] but stack has [i64]`,
|
||||
);
|
||||
|
||||
// ./test/core/try_catch.wast:241
|
||||
assert_invalid(
|
||||
() => instantiate(`(module (func (try (do) (catch_all (i32.const 42)))))`),
|
||||
`type mismatch: block requires [] but stack has [i32]`,
|
||||
);
|
||||
|
@ -61,23 +61,6 @@ let $0 = instantiate(`(module
|
||||
)
|
||||
)
|
||||
|
||||
(func (export "delegate-to-block") (result i32)
|
||||
(try (result i32)
|
||||
(do (block (try (do (throw $$e0)) (delegate 0)))
|
||||
(i32.const 0))
|
||||
(catch_all (i32.const 1)))
|
||||
)
|
||||
|
||||
(func (export "delegate-to-catch") (result i32)
|
||||
(try (result i32)
|
||||
(do (try
|
||||
(do (throw $$e0))
|
||||
(catch $$e0
|
||||
(try (do (rethrow 1)) (delegate 0))))
|
||||
(i32.const 0))
|
||||
(catch_all (i32.const 1)))
|
||||
)
|
||||
|
||||
(func (export "delegate-to-caller")
|
||||
(try (do (try (do (throw $$e0)) (delegate 1))) (catch_all))
|
||||
)
|
||||
@ -110,52 +93,46 @@ let $0 = instantiate(`(module
|
||||
)
|
||||
)`);
|
||||
|
||||
// ./test/core/try_delegate.wast:97
|
||||
// ./test/core/try_delegate.wast:80
|
||||
assert_return(() => invoke($0, `delegate-no-throw`, []), [value("i32", 1)]);
|
||||
|
||||
// ./test/core/try_delegate.wast:99
|
||||
// ./test/core/try_delegate.wast:82
|
||||
assert_return(() => invoke($0, `delegate-throw`, [0]), [value("i32", 1)]);
|
||||
|
||||
// ./test/core/try_delegate.wast:100
|
||||
// ./test/core/try_delegate.wast:83
|
||||
assert_return(() => invoke($0, `delegate-throw`, [1]), [value("i32", 2)]);
|
||||
|
||||
// ./test/core/try_delegate.wast:102
|
||||
// ./test/core/try_delegate.wast:85
|
||||
assert_exception(() => invoke($0, `delegate-throw-no-catch`, []));
|
||||
|
||||
// ./test/core/try_delegate.wast:104
|
||||
// ./test/core/try_delegate.wast:87
|
||||
assert_return(() => invoke($0, `delegate-merge`, [1, 0]), [value("i32", 2)]);
|
||||
|
||||
// ./test/core/try_delegate.wast:105
|
||||
// ./test/core/try_delegate.wast:88
|
||||
assert_exception(() => invoke($0, `delegate-merge`, [2, 0]));
|
||||
|
||||
// ./test/core/try_delegate.wast:106
|
||||
// ./test/core/try_delegate.wast:89
|
||||
assert_return(() => invoke($0, `delegate-merge`, [0, 1]), [value("i32", 2)]);
|
||||
|
||||
// ./test/core/try_delegate.wast:107
|
||||
// ./test/core/try_delegate.wast:90
|
||||
assert_exception(() => invoke($0, `delegate-merge`, [0, 2]));
|
||||
|
||||
// ./test/core/try_delegate.wast:108
|
||||
// ./test/core/try_delegate.wast:91
|
||||
assert_return(() => invoke($0, `delegate-merge`, [0, 0]), [value("i32", 1)]);
|
||||
|
||||
// ./test/core/try_delegate.wast:110
|
||||
// ./test/core/try_delegate.wast:93
|
||||
assert_return(() => invoke($0, `delegate-skip`, []), [value("i32", 3)]);
|
||||
|
||||
// ./test/core/try_delegate.wast:112
|
||||
assert_return(() => invoke($0, `delegate-to-block`, []), [value("i32", 1)]);
|
||||
|
||||
// ./test/core/try_delegate.wast:113
|
||||
assert_return(() => invoke($0, `delegate-to-catch`, []), [value("i32", 1)]);
|
||||
|
||||
// ./test/core/try_delegate.wast:115
|
||||
// ./test/core/try_delegate.wast:95
|
||||
assert_exception(() => invoke($0, `delegate-to-caller`, []));
|
||||
|
||||
// ./test/core/try_delegate.wast:117
|
||||
// ./test/core/try_delegate.wast:97
|
||||
assert_malformed(
|
||||
() => instantiate(`(module (func (delegate 0))) `),
|
||||
`unexpected token`,
|
||||
);
|
||||
|
||||
// ./test/core/try_delegate.wast:122
|
||||
// ./test/core/try_delegate.wast:102
|
||||
assert_malformed(
|
||||
() =>
|
||||
instantiate(
|
||||
@ -164,20 +141,14 @@ assert_malformed(
|
||||
`unexpected token`,
|
||||
);
|
||||
|
||||
// ./test/core/try_delegate.wast:127
|
||||
// ./test/core/try_delegate.wast:107
|
||||
assert_malformed(
|
||||
() => instantiate(`(module (func (try (do) (catch_all) (delegate 0)))) `),
|
||||
`unexpected token`,
|
||||
);
|
||||
|
||||
// ./test/core/try_delegate.wast:132
|
||||
// ./test/core/try_delegate.wast:112
|
||||
assert_malformed(
|
||||
() => instantiate(`(module (func (try (do) (delegate) (delegate 0)))) `),
|
||||
`unexpected token`,
|
||||
);
|
||||
|
||||
// ./test/core/try_delegate.wast:137
|
||||
assert_invalid(
|
||||
() => instantiate(`(module (func (try (do) (delegate 1))))`),
|
||||
`unknown label`,
|
||||
);
|
||||
|
@ -1 +1 @@
|
||||
|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(); local-include:harness/harness.js; skip-if: !wasmMemory64Enabled()
|
||||
|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(); local-include:harness/harness.js; skip-if: !wasmMemory64Enabled()
|
||||
|
@ -19,16 +19,16 @@
|
||||
let $0 = instantiate(`(module;;comment
|
||||
)`);
|
||||
|
||||
// ./test/core/comments.wast:56:11
|
||||
// ./test/core/comments.wast:52:11
|
||||
let $1 = instantiate(`(module(;comment;)
|
||||
(;comment;))`);
|
||||
|
||||
// ./test/core/comments.wast:66
|
||||
// ./test/core/comments.wast:62
|
||||
let $2 = instantiate(`(module
|
||||
(;comment(;nested(;further;)nested;)comment;)
|
||||
)`);
|
||||
|
||||
// ./test/core/comments.wast:75
|
||||
// ./test/core/comments.wast:71
|
||||
let $3 = instantiate(`(module
|
||||
(;comment;;comment(;nested;)comment;)
|
||||
)`);
|
||||
|
@ -21549,15 +21549,3 @@ assert_invalid(
|
||||
() => instantiate(`(module (func (result f32) (f32.trunc (i64.const 0))))`),
|
||||
`type mismatch`,
|
||||
);
|
||||
|
||||
// ./test/core/f32.wast:2536
|
||||
assert_malformed(
|
||||
() => instantiate(`(func (result f32) (f32.const nan:arithmetic)) `),
|
||||
`unexpected token`,
|
||||
);
|
||||
|
||||
// ./test/core/f32.wast:2540
|
||||
assert_malformed(
|
||||
() => instantiate(`(func (result f32) (f32.const nan:canonical)) `),
|
||||
`unexpected token`,
|
||||
);
|
||||
|
@ -28300,15 +28300,3 @@ assert_invalid(
|
||||
() => instantiate(`(module (func (result f64) (f64.trunc (i64.const 0))))`),
|
||||
`type mismatch`,
|
||||
);
|
||||
|
||||
// ./test/core/f64.wast:2536
|
||||
assert_malformed(
|
||||
() => instantiate(`(func (result f64) (f64.const nan:arithmetic)) `),
|
||||
`unexpected token`,
|
||||
);
|
||||
|
||||
// ./test/core/f64.wast:2540
|
||||
assert_malformed(
|
||||
() => instantiate(`(func (result f64) (f64.const nan:canonical)) `),
|
||||
`unexpected token`,
|
||||
);
|
||||
|
@ -2105,15 +2105,3 @@ assert_invalid(
|
||||
),
|
||||
`type mismatch`,
|
||||
);
|
||||
|
||||
// ./test/core/i32.wast:978
|
||||
assert_malformed(
|
||||
() => instantiate(`(func (result i32) (i32.const nan:arithmetic)) `),
|
||||
`unexpected token`,
|
||||
);
|
||||
|
||||
// ./test/core/i32.wast:982
|
||||
assert_malformed(
|
||||
() => instantiate(`(func (result i32) (i32.const nan:canonical)) `),
|
||||
`unexpected token`,
|
||||
);
|
||||
|
@ -1872,15 +1872,3 @@ assert_invalid(
|
||||
),
|
||||
`type mismatch`,
|
||||
);
|
||||
|
||||
// ./test/core/i64.wast:487
|
||||
assert_malformed(
|
||||
() => instantiate(`(func (result i64) (i64.const nan:arithmetic)) `),
|
||||
`unexpected token`,
|
||||
);
|
||||
|
||||
// ./test/core/i64.wast:491
|
||||
assert_malformed(
|
||||
() => instantiate(`(func (result i64) (i64.const nan:canonical)) `),
|
||||
`unexpected token`,
|
||||
);
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -59,7 +59,7 @@ let $0 = instantiate(`(module
|
||||
// ./test/core/type.wast:43
|
||||
assert_malformed(
|
||||
() => instantiate(`(type (func (result i32) (param i32))) `),
|
||||
`unexpected token`,
|
||||
`result before parameter`,
|
||||
);
|
||||
|
||||
// ./test/core/type.wast:47
|
||||
|
@ -1,85 +0,0 @@
|
||||
/* Copyright 2021 Mozilla Foundation
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
// ./test/core/unreached-valid.wast
|
||||
|
||||
// ./test/core/unreached-valid.wast:1
|
||||
let $0 = instantiate(`(module
|
||||
|
||||
;; Check that both sides of the select are evaluated
|
||||
(func (export "select-trap-left") (param $$cond i32) (result i32)
|
||||
(select (unreachable) (i32.const 0) (local.get $$cond))
|
||||
)
|
||||
(func (export "select-trap-right") (param $$cond i32) (result i32)
|
||||
(select (i32.const 0) (unreachable) (local.get $$cond))
|
||||
)
|
||||
|
||||
(func (export "select-unreached")
|
||||
(unreachable) (select)
|
||||
(unreachable) (i32.const 0) (select)
|
||||
(unreachable) (i32.const 0) (i32.const 0) (select)
|
||||
(unreachable) (i32.const 0) (i32.const 0) (i32.const 0) (select)
|
||||
(unreachable) (f32.const 0) (i32.const 0) (select)
|
||||
(unreachable)
|
||||
)
|
||||
|
||||
(func (export "select_unreached_result_1") (result i32)
|
||||
(unreachable) (i32.add (select))
|
||||
)
|
||||
|
||||
(func (export "select_unreached_result_2") (result i64)
|
||||
(unreachable) (i64.add (select (i64.const 0) (i32.const 0)))
|
||||
)
|
||||
|
||||
(func (export "unreachable-num")
|
||||
(unreachable)
|
||||
(select)
|
||||
(i32.eqz)
|
||||
(drop)
|
||||
)
|
||||
(func (export "unreachable-ref")
|
||||
(unreachable)
|
||||
(select)
|
||||
(ref.is_null)
|
||||
(drop)
|
||||
)
|
||||
)`);
|
||||
|
||||
// ./test/core/unreached-valid.wast:42
|
||||
assert_trap(() => invoke($0, `select-trap-left`, [1]), `unreachable`);
|
||||
|
||||
// ./test/core/unreached-valid.wast:43
|
||||
assert_trap(() => invoke($0, `select-trap-left`, [0]), `unreachable`);
|
||||
|
||||
// ./test/core/unreached-valid.wast:44
|
||||
assert_trap(() => invoke($0, `select-trap-right`, [1]), `unreachable`);
|
||||
|
||||
// ./test/core/unreached-valid.wast:45
|
||||
assert_trap(() => invoke($0, `select-trap-right`, [0]), `unreachable`);
|
||||
|
||||
// ./test/core/unreached-valid.wast:49
|
||||
let $1 = instantiate(`(module
|
||||
(func (export "meet-bottom")
|
||||
(block (result f64)
|
||||
(block (result f32)
|
||||
(unreachable)
|
||||
(br_table 0 1 1 (i32.const 1))
|
||||
)
|
||||
(drop)
|
||||
(f64.const 0)
|
||||
)
|
||||
(drop)
|
||||
)
|
||||
)`);
|
1055
js/src/jit-test/tests/wasm/spec/threads/address.wast.js
Normal file
1055
js/src/jit-test/tests/wasm/spec/threads/address.wast.js
Normal file
File diff suppressed because it is too large
Load Diff
1558
js/src/jit-test/tests/wasm/spec/threads/block.wast.js
Normal file
1558
js/src/jit-test/tests/wasm/spec/threads/block.wast.js
Normal file
File diff suppressed because it is too large
Load Diff
755
js/src/jit-test/tests/wasm/spec/threads/br.wast.js
Normal file
755
js/src/jit-test/tests/wasm/spec/threads/br.wast.js
Normal file
@ -0,0 +1,755 @@
|
||||
/* Copyright 2021 Mozilla Foundation
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
// ./test/core/br.wast
|
||||
|
||||
// ./test/core/br.wast:3
|
||||
let $0 = instantiate(`(module
|
||||
;; Auxiliary definition
|
||||
(func $$dummy)
|
||||
|
||||
(func (export "type-i32") (block (drop (i32.ctz (br 0)))))
|
||||
(func (export "type-i64") (block (drop (i64.ctz (br 0)))))
|
||||
(func (export "type-f32") (block (drop (f32.neg (br 0)))))
|
||||
(func (export "type-f64") (block (drop (f64.neg (br 0)))))
|
||||
|
||||
(func (export "type-i32-value") (result i32)
|
||||
(block (result i32) (i32.ctz (br 0 (i32.const 1))))
|
||||
)
|
||||
(func (export "type-i64-value") (result i64)
|
||||
(block (result i64) (i64.ctz (br 0 (i64.const 2))))
|
||||
)
|
||||
(func (export "type-f32-value") (result f32)
|
||||
(block (result f32) (f32.neg (br 0 (f32.const 3))))
|
||||
)
|
||||
(func (export "type-f64-value") (result f64)
|
||||
(block (result f64) (f64.neg (br 0 (f64.const 4))))
|
||||
)
|
||||
|
||||
(func (export "as-block-first")
|
||||
(block (br 0) (call $$dummy))
|
||||
)
|
||||
(func (export "as-block-mid")
|
||||
(block (call $$dummy) (br 0) (call $$dummy))
|
||||
)
|
||||
(func (export "as-block-last")
|
||||
(block (nop) (call $$dummy) (br 0))
|
||||
)
|
||||
(func (export "as-block-value") (result i32)
|
||||
(block (result i32) (nop) (call $$dummy) (br 0 (i32.const 2)))
|
||||
)
|
||||
|
||||
(func (export "as-loop-first") (result i32)
|
||||
(block (result i32) (loop (result i32) (br 1 (i32.const 3)) (i32.const 2)))
|
||||
)
|
||||
(func (export "as-loop-mid") (result i32)
|
||||
(block (result i32)
|
||||
(loop (result i32) (call $$dummy) (br 1 (i32.const 4)) (i32.const 2))
|
||||
)
|
||||
)
|
||||
(func (export "as-loop-last") (result i32)
|
||||
(block (result i32)
|
||||
(loop (result i32) (nop) (call $$dummy) (br 1 (i32.const 5)))
|
||||
)
|
||||
)
|
||||
|
||||
(func (export "as-br-value") (result i32)
|
||||
(block (result i32) (br 0 (br 0 (i32.const 9))))
|
||||
)
|
||||
|
||||
(func (export "as-br_if-cond")
|
||||
(block (br_if 0 (br 0)))
|
||||
)
|
||||
(func (export "as-br_if-value") (result i32)
|
||||
(block (result i32)
|
||||
(drop (br_if 0 (br 0 (i32.const 8)) (i32.const 1))) (i32.const 7)
|
||||
)
|
||||
)
|
||||
(func (export "as-br_if-value-cond") (result i32)
|
||||
(block (result i32)
|
||||
(drop (br_if 0 (i32.const 6) (br 0 (i32.const 9)))) (i32.const 7)
|
||||
)
|
||||
)
|
||||
|
||||
(func (export "as-br_table-index")
|
||||
(block (br_table 0 0 0 (br 0)))
|
||||
)
|
||||
(func (export "as-br_table-value") (result i32)
|
||||
(block (result i32)
|
||||
(br_table 0 0 0 (br 0 (i32.const 10)) (i32.const 1)) (i32.const 7)
|
||||
)
|
||||
)
|
||||
(func (export "as-br_table-value-index") (result i32)
|
||||
(block (result i32)
|
||||
(br_table 0 0 (i32.const 6) (br 0 (i32.const 11))) (i32.const 7)
|
||||
)
|
||||
)
|
||||
|
||||
(func (export "as-return-value") (result i64)
|
||||
(block (result i64) (return (br 0 (i64.const 7))))
|
||||
)
|
||||
|
||||
(func (export "as-if-cond") (result i32)
|
||||
(block (result i32)
|
||||
(if (result i32) (br 0 (i32.const 2))
|
||||
(then (i32.const 0))
|
||||
(else (i32.const 1))
|
||||
)
|
||||
)
|
||||
)
|
||||
(func (export "as-if-then") (param i32 i32) (result i32)
|
||||
(block (result i32)
|
||||
(if (result i32) (local.get 0)
|
||||
(then (br 1 (i32.const 3)))
|
||||
(else (local.get 1))
|
||||
)
|
||||
)
|
||||
)
|
||||
(func (export "as-if-else") (param i32 i32) (result i32)
|
||||
(block (result i32)
|
||||
(if (result i32) (local.get 0)
|
||||
(then (local.get 1))
|
||||
(else (br 1 (i32.const 4)))
|
||||
)
|
||||
)
|
||||
)
|
||||
|
||||
(func (export "as-select-first") (param i32 i32) (result i32)
|
||||
(block (result i32)
|
||||
(select (br 0 (i32.const 5)) (local.get 0) (local.get 1))
|
||||
)
|
||||
)
|
||||
(func (export "as-select-second") (param i32 i32) (result i32)
|
||||
(block (result i32)
|
||||
(select (local.get 0) (br 0 (i32.const 6)) (local.get 1))
|
||||
)
|
||||
)
|
||||
(func (export "as-select-cond") (result i32)
|
||||
(block (result i32)
|
||||
(select (i32.const 0) (i32.const 1) (br 0 (i32.const 7)))
|
||||
)
|
||||
)
|
||||
|
||||
(func $$f (param i32 i32 i32) (result i32) (i32.const -1))
|
||||
(func (export "as-call-first") (result i32)
|
||||
(block (result i32)
|
||||
(call $$f (br 0 (i32.const 12)) (i32.const 2) (i32.const 3))
|
||||
)
|
||||
)
|
||||
(func (export "as-call-mid") (result i32)
|
||||
(block (result i32)
|
||||
(call $$f (i32.const 1) (br 0 (i32.const 13)) (i32.const 3))
|
||||
)
|
||||
)
|
||||
(func (export "as-call-last") (result i32)
|
||||
(block (result i32)
|
||||
(call $$f (i32.const 1) (i32.const 2) (br 0 (i32.const 14)))
|
||||
)
|
||||
)
|
||||
|
||||
(type $$sig (func (param i32 i32 i32) (result i32)))
|
||||
(table funcref (elem $$f))
|
||||
(func (export "as-call_indirect-func") (result i32)
|
||||
(block (result i32)
|
||||
(call_indirect (type $$sig)
|
||||
(br 0 (i32.const 20))
|
||||
(i32.const 1) (i32.const 2) (i32.const 3)
|
||||
)
|
||||
)
|
||||
)
|
||||
(func (export "as-call_indirect-first") (result i32)
|
||||
(block (result i32)
|
||||
(call_indirect (type $$sig)
|
||||
(i32.const 0)
|
||||
(br 0 (i32.const 21)) (i32.const 2) (i32.const 3)
|
||||
)
|
||||
)
|
||||
)
|
||||
(func (export "as-call_indirect-mid") (result i32)
|
||||
(block (result i32)
|
||||
(call_indirect (type $$sig)
|
||||
(i32.const 0)
|
||||
(i32.const 1) (br 0 (i32.const 22)) (i32.const 3)
|
||||
)
|
||||
)
|
||||
)
|
||||
(func (export "as-call_indirect-last") (result i32)
|
||||
(block (result i32)
|
||||
(call_indirect (type $$sig)
|
||||
(i32.const 0)
|
||||
(i32.const 1) (i32.const 2) (br 0 (i32.const 23))
|
||||
)
|
||||
)
|
||||
)
|
||||
|
||||
(func (export "as-local.set-value") (result i32) (local f32)
|
||||
(block (result i32) (local.set 0 (br 0 (i32.const 17))) (i32.const -1))
|
||||
)
|
||||
(func (export "as-local.tee-value") (result i32) (local i32)
|
||||
(block (result i32) (local.tee 0 (br 0 (i32.const 1))))
|
||||
)
|
||||
(global $$a (mut i32) (i32.const 10))
|
||||
(func (export "as-global.set-value") (result i32)
|
||||
(block (result i32) (global.set $$a (br 0 (i32.const 1))))
|
||||
)
|
||||
|
||||
(memory 1)
|
||||
(func (export "as-load-address") (result f32)
|
||||
(block (result f32) (f32.load (br 0 (f32.const 1.7))))
|
||||
)
|
||||
(func (export "as-loadN-address") (result i64)
|
||||
(block (result i64) (i64.load8_s (br 0 (i64.const 30))))
|
||||
)
|
||||
|
||||
(func (export "as-store-address") (result i32)
|
||||
(block (result i32)
|
||||
(f64.store (br 0 (i32.const 30)) (f64.const 7)) (i32.const -1)
|
||||
)
|
||||
)
|
||||
(func (export "as-store-value") (result i32)
|
||||
(block (result i32)
|
||||
(i64.store (i32.const 2) (br 0 (i32.const 31))) (i32.const -1)
|
||||
)
|
||||
)
|
||||
|
||||
(func (export "as-storeN-address") (result i32)
|
||||
(block (result i32)
|
||||
(i32.store8 (br 0 (i32.const 32)) (i32.const 7)) (i32.const -1)
|
||||
)
|
||||
)
|
||||
(func (export "as-storeN-value") (result i32)
|
||||
(block (result i32)
|
||||
(i64.store16 (i32.const 2) (br 0 (i32.const 33))) (i32.const -1)
|
||||
)
|
||||
)
|
||||
|
||||
(func (export "as-unary-operand") (result f32)
|
||||
(block (result f32) (f32.neg (br 0 (f32.const 3.4))))
|
||||
)
|
||||
|
||||
(func (export "as-binary-left") (result i32)
|
||||
(block (result i32) (i32.add (br 0 (i32.const 3)) (i32.const 10)))
|
||||
)
|
||||
(func (export "as-binary-right") (result i64)
|
||||
(block (result i64) (i64.sub (i64.const 10) (br 0 (i64.const 45))))
|
||||
)
|
||||
|
||||
(func (export "as-test-operand") (result i32)
|
||||
(block (result i32) (i32.eqz (br 0 (i32.const 44))))
|
||||
)
|
||||
|
||||
(func (export "as-compare-left") (result i32)
|
||||
(block (result i32) (f64.le (br 0 (i32.const 43)) (f64.const 10)))
|
||||
)
|
||||
(func (export "as-compare-right") (result i32)
|
||||
(block (result i32) (f32.ne (f32.const 10) (br 0 (i32.const 42))))
|
||||
)
|
||||
|
||||
(func (export "as-convert-operand") (result i32)
|
||||
(block (result i32) (i32.wrap_i64 (br 0 (i32.const 41))))
|
||||
)
|
||||
|
||||
(func (export "as-memory.grow-size") (result i32)
|
||||
(block (result i32) (memory.grow (br 0 (i32.const 40))))
|
||||
)
|
||||
|
||||
(func (export "nested-block-value") (result i32)
|
||||
(i32.add
|
||||
(i32.const 1)
|
||||
(block (result i32)
|
||||
(call $$dummy)
|
||||
(i32.add (i32.const 4) (br 0 (i32.const 8)))
|
||||
)
|
||||
)
|
||||
)
|
||||
|
||||
(func (export "nested-br-value") (result i32)
|
||||
(i32.add
|
||||
(i32.const 1)
|
||||
(block (result i32)
|
||||
(drop (i32.const 2))
|
||||
(drop
|
||||
(block (result i32)
|
||||
(drop (i32.const 4))
|
||||
(br 0 (br 1 (i32.const 8)))
|
||||
)
|
||||
)
|
||||
(i32.const 16)
|
||||
)
|
||||
)
|
||||
)
|
||||
|
||||
(func (export "nested-br_if-value") (result i32)
|
||||
(i32.add
|
||||
(i32.const 1)
|
||||
(block (result i32)
|
||||
(drop (i32.const 2))
|
||||
(drop
|
||||
(block (result i32)
|
||||
(drop (i32.const 4))
|
||||
(drop (br_if 0 (br 1 (i32.const 8)) (i32.const 1)))
|
||||
(i32.const 32)
|
||||
)
|
||||
)
|
||||
(i32.const 16)
|
||||
)
|
||||
)
|
||||
)
|
||||
|
||||
(func (export "nested-br_if-value-cond") (result i32)
|
||||
(i32.add
|
||||
(i32.const 1)
|
||||
(block (result i32)
|
||||
(drop (i32.const 2))
|
||||
(drop (br_if 0 (i32.const 4) (br 0 (i32.const 8))))
|
||||
(i32.const 16)
|
||||
)
|
||||
)
|
||||
)
|
||||
|
||||
(func (export "nested-br_table-value") (result i32)
|
||||
(i32.add
|
||||
(i32.const 1)
|
||||
(block (result i32)
|
||||
(drop (i32.const 2))
|
||||
(drop
|
||||
(block (result i32)
|
||||
(drop (i32.const 4))
|
||||
(br_table 0 (br 1 (i32.const 8)) (i32.const 1))
|
||||
)
|
||||
)
|
||||
(i32.const 16)
|
||||
)
|
||||
)
|
||||
)
|
||||
|
||||
(func (export "nested-br_table-value-index") (result i32)
|
||||
(i32.add
|
||||
(i32.const 1)
|
||||
(block (result i32)
|
||||
(drop (i32.const 2))
|
||||
(br_table 0 (i32.const 4) (br 0 (i32.const 8)))
|
||||
(i32.const 16)
|
||||
)
|
||||
)
|
||||
)
|
||||
)`);
|
||||
|
||||
// ./test/core/br.wast:334
|
||||
assert_return(() => invoke($0, `type-i32`, []), []);
|
||||
|
||||
// ./test/core/br.wast:335
|
||||
assert_return(() => invoke($0, `type-i64`, []), []);
|
||||
|
||||
// ./test/core/br.wast:336
|
||||
assert_return(() => invoke($0, `type-f32`, []), []);
|
||||
|
||||
// ./test/core/br.wast:337
|
||||
assert_return(() => invoke($0, `type-f64`, []), []);
|
||||
|
||||
// ./test/core/br.wast:339
|
||||
assert_return(() => invoke($0, `type-i32-value`, []), [value("i32", 1)]);
|
||||
|
||||
// ./test/core/br.wast:340
|
||||
assert_return(() => invoke($0, `type-i64-value`, []), [value("i64", 2n)]);
|
||||
|
||||
// ./test/core/br.wast:341
|
||||
assert_return(() => invoke($0, `type-f32-value`, []), [value("f32", 3)]);
|
||||
|
||||
// ./test/core/br.wast:342
|
||||
assert_return(() => invoke($0, `type-f64-value`, []), [value("f64", 4)]);
|
||||
|
||||
// ./test/core/br.wast:344
|
||||
assert_return(() => invoke($0, `as-block-first`, []), []);
|
||||
|
||||
// ./test/core/br.wast:345
|
||||
assert_return(() => invoke($0, `as-block-mid`, []), []);
|
||||
|
||||
// ./test/core/br.wast:346
|
||||
assert_return(() => invoke($0, `as-block-last`, []), []);
|
||||
|
||||
// ./test/core/br.wast:347
|
||||
assert_return(() => invoke($0, `as-block-value`, []), [value("i32", 2)]);
|
||||
|
||||
// ./test/core/br.wast:349
|
||||
assert_return(() => invoke($0, `as-loop-first`, []), [value("i32", 3)]);
|
||||
|
||||
// ./test/core/br.wast:350
|
||||
assert_return(() => invoke($0, `as-loop-mid`, []), [value("i32", 4)]);
|
||||
|
||||
// ./test/core/br.wast:351
|
||||
assert_return(() => invoke($0, `as-loop-last`, []), [value("i32", 5)]);
|
||||
|
||||
// ./test/core/br.wast:353
|
||||
assert_return(() => invoke($0, `as-br-value`, []), [value("i32", 9)]);
|
||||
|
||||
// ./test/core/br.wast:355
|
||||
assert_return(() => invoke($0, `as-br_if-cond`, []), []);
|
||||
|
||||
// ./test/core/br.wast:356
|
||||
assert_return(() => invoke($0, `as-br_if-value`, []), [value("i32", 8)]);
|
||||
|
||||
// ./test/core/br.wast:357
|
||||
assert_return(() => invoke($0, `as-br_if-value-cond`, []), [value("i32", 9)]);
|
||||
|
||||
// ./test/core/br.wast:359
|
||||
assert_return(() => invoke($0, `as-br_table-index`, []), []);
|
||||
|
||||
// ./test/core/br.wast:360
|
||||
assert_return(() => invoke($0, `as-br_table-value`, []), [value("i32", 10)]);
|
||||
|
||||
// ./test/core/br.wast:361
|
||||
assert_return(() => invoke($0, `as-br_table-value-index`, []), [
|
||||
value("i32", 11),
|
||||
]);
|
||||
|
||||
// ./test/core/br.wast:363
|
||||
assert_return(() => invoke($0, `as-return-value`, []), [value("i64", 7n)]);
|
||||
|
||||
// ./test/core/br.wast:365
|
||||
assert_return(() => invoke($0, `as-if-cond`, []), [value("i32", 2)]);
|
||||
|
||||
// ./test/core/br.wast:366
|
||||
assert_return(() => invoke($0, `as-if-then`, [1, 6]), [value("i32", 3)]);
|
||||
|
||||
// ./test/core/br.wast:367
|
||||
assert_return(() => invoke($0, `as-if-then`, [0, 6]), [value("i32", 6)]);
|
||||
|
||||
// ./test/core/br.wast:368
|
||||
assert_return(() => invoke($0, `as-if-else`, [0, 6]), [value("i32", 4)]);
|
||||
|
||||
// ./test/core/br.wast:369
|
||||
assert_return(() => invoke($0, `as-if-else`, [1, 6]), [value("i32", 6)]);
|
||||
|
||||
// ./test/core/br.wast:371
|
||||
assert_return(() => invoke($0, `as-select-first`, [0, 6]), [value("i32", 5)]);
|
||||
|
||||
// ./test/core/br.wast:372
|
||||
assert_return(() => invoke($0, `as-select-first`, [1, 6]), [value("i32", 5)]);
|
||||
|
||||
// ./test/core/br.wast:373
|
||||
assert_return(() => invoke($0, `as-select-second`, [0, 6]), [value("i32", 6)]);
|
||||
|
||||
// ./test/core/br.wast:374
|
||||
assert_return(() => invoke($0, `as-select-second`, [1, 6]), [value("i32", 6)]);
|
||||
|
||||
// ./test/core/br.wast:375
|
||||
assert_return(() => invoke($0, `as-select-cond`, []), [value("i32", 7)]);
|
||||
|
||||
// ./test/core/br.wast:377
|
||||
assert_return(() => invoke($0, `as-call-first`, []), [value("i32", 12)]);
|
||||
|
||||
// ./test/core/br.wast:378
|
||||
assert_return(() => invoke($0, `as-call-mid`, []), [value("i32", 13)]);
|
||||
|
||||
// ./test/core/br.wast:379
|
||||
assert_return(() => invoke($0, `as-call-last`, []), [value("i32", 14)]);
|
||||
|
||||
// ./test/core/br.wast:381
|
||||
assert_return(() => invoke($0, `as-call_indirect-func`, []), [
|
||||
value("i32", 20),
|
||||
]);
|
||||
|
||||
// ./test/core/br.wast:382
|
||||
assert_return(() => invoke($0, `as-call_indirect-first`, []), [
|
||||
value("i32", 21),
|
||||
]);
|
||||
|
||||
// ./test/core/br.wast:383
|
||||
assert_return(() => invoke($0, `as-call_indirect-mid`, []), [value("i32", 22)]);
|
||||
|
||||
// ./test/core/br.wast:384
|
||||
assert_return(() => invoke($0, `as-call_indirect-last`, []), [
|
||||
value("i32", 23),
|
||||
]);
|
||||
|
||||
// ./test/core/br.wast:386
|
||||
assert_return(() => invoke($0, `as-local.set-value`, []), [value("i32", 17)]);
|
||||
|
||||
// ./test/core/br.wast:387
|
||||
assert_return(() => invoke($0, `as-local.tee-value`, []), [value("i32", 1)]);
|
||||
|
||||
// ./test/core/br.wast:388
|
||||
assert_return(() => invoke($0, `as-global.set-value`, []), [value("i32", 1)]);
|
||||
|
||||
// ./test/core/br.wast:390
|
||||
assert_return(() => invoke($0, `as-load-address`, []), [value("f32", 1.7)]);
|
||||
|
||||
// ./test/core/br.wast:391
|
||||
assert_return(() => invoke($0, `as-loadN-address`, []), [value("i64", 30n)]);
|
||||
|
||||
// ./test/core/br.wast:393
|
||||
assert_return(() => invoke($0, `as-store-address`, []), [value("i32", 30)]);
|
||||
|
||||
// ./test/core/br.wast:394
|
||||
assert_return(() => invoke($0, `as-store-value`, []), [value("i32", 31)]);
|
||||
|
||||
// ./test/core/br.wast:395
|
||||
assert_return(() => invoke($0, `as-storeN-address`, []), [value("i32", 32)]);
|
||||
|
||||
// ./test/core/br.wast:396
|
||||
assert_return(() => invoke($0, `as-storeN-value`, []), [value("i32", 33)]);
|
||||
|
||||
// ./test/core/br.wast:398
|
||||
assert_return(() => invoke($0, `as-unary-operand`, []), [value("f32", 3.4)]);
|
||||
|
||||
// ./test/core/br.wast:400
|
||||
assert_return(() => invoke($0, `as-binary-left`, []), [value("i32", 3)]);
|
||||
|
||||
// ./test/core/br.wast:401
|
||||
assert_return(() => invoke($0, `as-binary-right`, []), [value("i64", 45n)]);
|
||||
|
||||
// ./test/core/br.wast:403
|
||||
assert_return(() => invoke($0, `as-test-operand`, []), [value("i32", 44)]);
|
||||
|
||||
// ./test/core/br.wast:405
|
||||
assert_return(() => invoke($0, `as-compare-left`, []), [value("i32", 43)]);
|
||||
|
||||
// ./test/core/br.wast:406
|
||||
assert_return(() => invoke($0, `as-compare-right`, []), [value("i32", 42)]);
|
||||
|
||||
// ./test/core/br.wast:408
|
||||
assert_return(() => invoke($0, `as-convert-operand`, []), [value("i32", 41)]);
|
||||
|
||||
// ./test/core/br.wast:410
|
||||
assert_return(() => invoke($0, `as-memory.grow-size`, []), [value("i32", 40)]);
|
||||
|
||||
// ./test/core/br.wast:412
|
||||
assert_return(() => invoke($0, `nested-block-value`, []), [value("i32", 9)]);
|
||||
|
||||
// ./test/core/br.wast:413
|
||||
assert_return(() => invoke($0, `nested-br-value`, []), [value("i32", 9)]);
|
||||
|
||||
// ./test/core/br.wast:414
|
||||
assert_return(() => invoke($0, `nested-br_if-value`, []), [value("i32", 9)]);
|
||||
|
||||
// ./test/core/br.wast:415
|
||||
assert_return(() => invoke($0, `nested-br_if-value-cond`, []), [
|
||||
value("i32", 9),
|
||||
]);
|
||||
|
||||
// ./test/core/br.wast:416
|
||||
assert_return(() => invoke($0, `nested-br_table-value`, []), [value("i32", 9)]);
|
||||
|
||||
// ./test/core/br.wast:417
|
||||
assert_return(() => invoke($0, `nested-br_table-value-index`, []), [
|
||||
value("i32", 9),
|
||||
]);
|
||||
|
||||
// ./test/core/br.wast:419
|
||||
assert_invalid(
|
||||
() =>
|
||||
instantiate(`(module (func $$type-arg-empty-vs-num (result i32)
|
||||
(block (result i32) (br 0) (i32.const 1))
|
||||
))`),
|
||||
`type mismatch`,
|
||||
);
|
||||
|
||||
// ./test/core/br.wast:426
|
||||
assert_invalid(
|
||||
() =>
|
||||
instantiate(`(module (func $$type-arg-void-vs-num (result i32)
|
||||
(block (result i32) (br 0 (nop)) (i32.const 1))
|
||||
))`),
|
||||
`type mismatch`,
|
||||
);
|
||||
|
||||
// ./test/core/br.wast:432
|
||||
assert_invalid(
|
||||
() =>
|
||||
instantiate(`(module (func $$type-arg-void-vs-num-nested (result i32)
|
||||
(block (result i32) (i32.const 0) (block (br 1)))
|
||||
))`),
|
||||
`type mismatch`,
|
||||
);
|
||||
|
||||
// ./test/core/br.wast:438
|
||||
assert_invalid(
|
||||
() =>
|
||||
instantiate(`(module (func $$type-arg-num-vs-num (result i32)
|
||||
(block (result i32) (br 0 (i64.const 1)) (i32.const 1))
|
||||
))`),
|
||||
`type mismatch`,
|
||||
);
|
||||
|
||||
// ./test/core/br.wast:445
|
||||
assert_invalid(() =>
|
||||
instantiate(`(module
|
||||
(func $$type-arg-empty-in-br
|
||||
(i32.const 0)
|
||||
(block (result i32) (br 0 (br 0))) (i32.eqz) (drop)
|
||||
)
|
||||
)`), `type mismatch`);
|
||||
|
||||
// ./test/core/br.wast:454
|
||||
assert_invalid(() =>
|
||||
instantiate(`(module
|
||||
(func $$type-arg-empty-in-br_if
|
||||
(i32.const 0)
|
||||
(block (result i32) (br_if 0 (br 0) (i32.const 1))) (i32.eqz) (drop)
|
||||
)
|
||||
)`), `type mismatch`);
|
||||
|
||||
// ./test/core/br.wast:463
|
||||
assert_invalid(() =>
|
||||
instantiate(`(module
|
||||
(func $$type-arg-empty-in-br_table
|
||||
(i32.const 0)
|
||||
(block (result i32) (br_table 0 (br 0))) (i32.eqz) (drop)
|
||||
)
|
||||
)`), `type mismatch`);
|
||||
|
||||
// ./test/core/br.wast:472
|
||||
assert_invalid(() =>
|
||||
instantiate(`(module
|
||||
(func $$type-arg-empty-in-return
|
||||
(block (result i32)
|
||||
(return (br 0))
|
||||
)
|
||||
(i32.eqz) (drop)
|
||||
)
|
||||
)`), `type mismatch`);
|
||||
|
||||
// ./test/core/br.wast:483
|
||||
assert_invalid(() =>
|
||||
instantiate(`(module
|
||||
(func $$type-arg-empty-in-select
|
||||
(block (result i32)
|
||||
(select (br 0) (i32.const 1) (i32.const 2))
|
||||
)
|
||||
(i32.eqz) (drop)
|
||||
)
|
||||
)`), `type mismatch`);
|
||||
|
||||
// ./test/core/br.wast:494
|
||||
assert_invalid(() =>
|
||||
instantiate(`(module
|
||||
(func $$type-arg-empty-in-call
|
||||
(block (result i32)
|
||||
(call 1 (br 0))
|
||||
)
|
||||
(i32.eqz) (drop)
|
||||
)
|
||||
(func (param i32) (result i32) (local.get 0))
|
||||
)`), `type mismatch`);
|
||||
|
||||
// ./test/core/br.wast:506
|
||||
assert_invalid(() =>
|
||||
instantiate(`(module
|
||||
(func $$f (param i32) (result i32) (local.get 0))
|
||||
(type $$sig (func (param i32) (result i32)))
|
||||
(table funcref (elem $$f))
|
||||
(func $$type-arg-empty-in-call_indirect
|
||||
(block (result i32)
|
||||
(call_indirect (type $$sig)
|
||||
(br 0) (i32.const 0)
|
||||
)
|
||||
)
|
||||
(i32.eqz) (drop)
|
||||
)
|
||||
)`), `type mismatch`);
|
||||
|
||||
// ./test/core/br.wast:522
|
||||
assert_invalid(() =>
|
||||
instantiate(`(module
|
||||
(func $$type-arg-empty-in-local.set
|
||||
(local i32)
|
||||
(block (result i32)
|
||||
(local.set 0 (br 0)) (local.get 0)
|
||||
)
|
||||
(i32.eqz) (drop)
|
||||
)
|
||||
)`), `type mismatch`);
|
||||
|
||||
// ./test/core/br.wast:534
|
||||
assert_invalid(() =>
|
||||
instantiate(`(module
|
||||
(func $$type-arg-empty-in-local.tee
|
||||
(local i32)
|
||||
(block (result i32)
|
||||
(local.tee 0 (br 0))
|
||||
)
|
||||
(i32.eqz) (drop)
|
||||
)
|
||||
)`), `type mismatch`);
|
||||
|
||||
// ./test/core/br.wast:546
|
||||
assert_invalid(() =>
|
||||
instantiate(`(module
|
||||
(global $$x (mut i32) (i32.const 0))
|
||||
(func $$type-arg-empty-in-global.set
|
||||
(block (result i32)
|
||||
(global.set $$x (br 0)) (global.get $$x)
|
||||
)
|
||||
(i32.eqz) (drop)
|
||||
)
|
||||
)`), `type mismatch`);
|
||||
|
||||
// ./test/core/br.wast:558
|
||||
assert_invalid(() =>
|
||||
instantiate(`(module
|
||||
(memory 0)
|
||||
(func $$type-arg-empty-in-memory.grow
|
||||
(block (result i32)
|
||||
(memory.grow (br 0))
|
||||
)
|
||||
(i32.eqz) (drop)
|
||||
)
|
||||
)`), `type mismatch`);
|
||||
|
||||
// ./test/core/br.wast:570
|
||||
assert_invalid(() =>
|
||||
instantiate(`(module
|
||||
(memory 1)
|
||||
(func $$type-arg-empty-in-load
|
||||
(block (result i32)
|
||||
(i32.load (br 0))
|
||||
)
|
||||
(i32.eqz) (drop)
|
||||
)
|
||||
)`), `type mismatch`);
|
||||
|
||||
// ./test/core/br.wast:582
|
||||
assert_invalid(() =>
|
||||
instantiate(`(module
|
||||
(memory 1)
|
||||
(func $$type-arg-empty-in-store
|
||||
(block (result i32)
|
||||
(i32.store (br 0) (i32.const 0))
|
||||
)
|
||||
(i32.eqz) (drop)
|
||||
)
|
||||
)`), `type mismatch`);
|
||||
|
||||
// ./test/core/br.wast:595
|
||||
assert_invalid(
|
||||
() => instantiate(`(module (func $$unbound-label (br 1)))`),
|
||||
`unknown label`,
|
||||
);
|
||||
|
||||
// ./test/core/br.wast:599
|
||||
assert_invalid(
|
||||
() =>
|
||||
instantiate(
|
||||
`(module (func $$unbound-nested-label (block (block (br 5)))))`,
|
||||
),
|
||||
`unknown label`,
|
||||
);
|
||||
|
||||
// ./test/core/br.wast:603
|
||||
assert_invalid(
|
||||
() => instantiate(`(module (func $$large-label (br 0x10000001)))`),
|
||||
`unknown label`,
|
||||
);
|
927
js/src/jit-test/tests/wasm/spec/threads/br_if.wast.js
Normal file
927
js/src/jit-test/tests/wasm/spec/threads/br_if.wast.js
Normal file
@ -0,0 +1,927 @@
|
||||
/* Copyright 2021 Mozilla Foundation
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
// ./test/core/br_if.wast
|
||||
|
||||
// ./test/core/br_if.wast:3
|
||||
let $0 = instantiate(`(module
|
||||
(func $$dummy)
|
||||
|
||||
(func (export "type-i32")
|
||||
(block (drop (i32.ctz (br_if 0 (i32.const 0) (i32.const 1)))))
|
||||
)
|
||||
(func (export "type-i64")
|
||||
(block (drop (i64.ctz (br_if 0 (i64.const 0) (i32.const 1)))))
|
||||
)
|
||||
(func (export "type-f32")
|
||||
(block (drop (f32.neg (br_if 0 (f32.const 0) (i32.const 1)))))
|
||||
)
|
||||
(func (export "type-f64")
|
||||
(block (drop (f64.neg (br_if 0 (f64.const 0) (i32.const 1)))))
|
||||
)
|
||||
|
||||
(func (export "type-i32-value") (result i32)
|
||||
(block (result i32) (i32.ctz (br_if 0 (i32.const 1) (i32.const 1))))
|
||||
)
|
||||
(func (export "type-i64-value") (result i64)
|
||||
(block (result i64) (i64.ctz (br_if 0 (i64.const 2) (i32.const 1))))
|
||||
)
|
||||
(func (export "type-f32-value") (result f32)
|
||||
(block (result f32) (f32.neg (br_if 0 (f32.const 3) (i32.const 1))))
|
||||
)
|
||||
(func (export "type-f64-value") (result f64)
|
||||
(block (result f64) (f64.neg (br_if 0 (f64.const 4) (i32.const 1))))
|
||||
)
|
||||
|
||||
(func (export "as-block-first") (param i32) (result i32)
|
||||
(block (br_if 0 (local.get 0)) (return (i32.const 2))) (i32.const 3)
|
||||
)
|
||||
(func (export "as-block-mid") (param i32) (result i32)
|
||||
(block (call $$dummy) (br_if 0 (local.get 0)) (return (i32.const 2)))
|
||||
(i32.const 3)
|
||||
)
|
||||
(func (export "as-block-last") (param i32)
|
||||
(block (call $$dummy) (call $$dummy) (br_if 0 (local.get 0)))
|
||||
)
|
||||
(func (export "as-block-first-value") (param i32) (result i32)
|
||||
(block (result i32)
|
||||
(drop (br_if 0 (i32.const 10) (local.get 0))) (return (i32.const 11))
|
||||
)
|
||||
)
|
||||
(func (export "as-block-mid-value") (param i32) (result i32)
|
||||
(block (result i32)
|
||||
(call $$dummy)
|
||||
(drop (br_if 0 (i32.const 20) (local.get 0)))
|
||||
(return (i32.const 21))
|
||||
)
|
||||
)
|
||||
(func (export "as-block-last-value") (param i32) (result i32)
|
||||
(block (result i32)
|
||||
(call $$dummy) (call $$dummy) (br_if 0 (i32.const 11) (local.get 0))
|
||||
)
|
||||
)
|
||||
|
||||
(func (export "as-loop-first") (param i32) (result i32)
|
||||
(block (loop (br_if 1 (local.get 0)) (return (i32.const 2)))) (i32.const 3)
|
||||
)
|
||||
(func (export "as-loop-mid") (param i32) (result i32)
|
||||
(block (loop (call $$dummy) (br_if 1 (local.get 0)) (return (i32.const 2))))
|
||||
(i32.const 4)
|
||||
)
|
||||
(func (export "as-loop-last") (param i32)
|
||||
(loop (call $$dummy) (br_if 1 (local.get 0)))
|
||||
)
|
||||
|
||||
(func (export "as-br-value") (result i32)
|
||||
(block (result i32) (br 0 (br_if 0 (i32.const 1) (i32.const 2))))
|
||||
)
|
||||
|
||||
(func (export "as-br_if-cond")
|
||||
(block (br_if 0 (br_if 0 (i32.const 1) (i32.const 1))))
|
||||
)
|
||||
(func (export "as-br_if-value") (result i32)
|
||||
(block (result i32)
|
||||
(drop (br_if 0 (br_if 0 (i32.const 1) (i32.const 2)) (i32.const 3)))
|
||||
(i32.const 4)
|
||||
)
|
||||
)
|
||||
(func (export "as-br_if-value-cond") (param i32) (result i32)
|
||||
(block (result i32)
|
||||
(drop (br_if 0 (i32.const 2) (br_if 0 (i32.const 1) (local.get 0))))
|
||||
(i32.const 4)
|
||||
)
|
||||
)
|
||||
|
||||
(func (export "as-br_table-index")
|
||||
(block (br_table 0 0 0 (br_if 0 (i32.const 1) (i32.const 2))))
|
||||
)
|
||||
(func (export "as-br_table-value") (result i32)
|
||||
(block (result i32)
|
||||
(br_table 0 0 0 (br_if 0 (i32.const 1) (i32.const 2)) (i32.const 3)) (i32.const 4)
|
||||
)
|
||||
)
|
||||
(func (export "as-br_table-value-index") (result i32)
|
||||
(block (result i32)
|
||||
(br_table 0 0 (i32.const 2) (br_if 0 (i32.const 1) (i32.const 3))) (i32.const 4)
|
||||
)
|
||||
)
|
||||
(func (export "as-return-value") (result i64)
|
||||
(block (result i64) (return (br_if 0 (i64.const 1) (i32.const 2))))
|
||||
)
|
||||
|
||||
(func (export "as-if-cond") (param i32) (result i32)
|
||||
(block (result i32)
|
||||
(if (result i32)
|
||||
(br_if 0 (i32.const 1) (local.get 0))
|
||||
(then (i32.const 2))
|
||||
(else (i32.const 3))
|
||||
)
|
||||
)
|
||||
)
|
||||
(func (export "as-if-then") (param i32 i32)
|
||||
(block
|
||||
(if (local.get 0) (then (br_if 1 (local.get 1))) (else (call $$dummy)))
|
||||
)
|
||||
)
|
||||
(func (export "as-if-else") (param i32 i32)
|
||||
(block
|
||||
(if (local.get 0) (then (call $$dummy)) (else (br_if 1 (local.get 1))))
|
||||
)
|
||||
)
|
||||
|
||||
(func (export "as-select-first") (param i32) (result i32)
|
||||
(block (result i32)
|
||||
(select (br_if 0 (i32.const 3) (i32.const 10)) (i32.const 2) (local.get 0))
|
||||
)
|
||||
)
|
||||
(func (export "as-select-second") (param i32) (result i32)
|
||||
(block (result i32)
|
||||
(select (i32.const 1) (br_if 0 (i32.const 3) (i32.const 10)) (local.get 0))
|
||||
)
|
||||
)
|
||||
(func (export "as-select-cond") (result i32)
|
||||
(block (result i32)
|
||||
(select (i32.const 1) (i32.const 2) (br_if 0 (i32.const 3) (i32.const 10)))
|
||||
)
|
||||
)
|
||||
|
||||
(func $$f (param i32 i32 i32) (result i32) (i32.const -1))
|
||||
(func (export "as-call-first") (result i32)
|
||||
(block (result i32)
|
||||
(call $$f
|
||||
(br_if 0 (i32.const 12) (i32.const 1)) (i32.const 2) (i32.const 3)
|
||||
)
|
||||
)
|
||||
)
|
||||
(func (export "as-call-mid") (result i32)
|
||||
(block (result i32)
|
||||
(call $$f
|
||||
(i32.const 1) (br_if 0 (i32.const 13) (i32.const 1)) (i32.const 3)
|
||||
)
|
||||
)
|
||||
)
|
||||
(func (export "as-call-last") (result i32)
|
||||
(block (result i32)
|
||||
(call $$f
|
||||
(i32.const 1) (i32.const 2) (br_if 0 (i32.const 14) (i32.const 1))
|
||||
)
|
||||
)
|
||||
)
|
||||
|
||||
(func $$func (param i32 i32 i32) (result i32) (local.get 0))
|
||||
(type $$check (func (param i32 i32 i32) (result i32)))
|
||||
(table funcref (elem $$func))
|
||||
(func (export "as-call_indirect-func") (result i32)
|
||||
(block (result i32)
|
||||
(call_indirect (type $$check)
|
||||
(br_if 0 (i32.const 4) (i32.const 10))
|
||||
(i32.const 1) (i32.const 2) (i32.const 0)
|
||||
)
|
||||
)
|
||||
)
|
||||
|
||||
(func (export "as-call_indirect-first") (result i32)
|
||||
(block (result i32)
|
||||
(call_indirect (type $$check)
|
||||
(i32.const 1) (br_if 0 (i32.const 4) (i32.const 10)) (i32.const 2) (i32.const 0)
|
||||
)
|
||||
)
|
||||
)
|
||||
(func (export "as-call_indirect-mid") (result i32)
|
||||
(block (result i32)
|
||||
(call_indirect (type $$check)
|
||||
(i32.const 1) (i32.const 2) (br_if 0 (i32.const 4) (i32.const 10)) (i32.const 0)
|
||||
)
|
||||
)
|
||||
)
|
||||
(func (export "as-call_indirect-last") (result i32)
|
||||
(block (result i32)
|
||||
(call_indirect (type $$check)
|
||||
(i32.const 1) (i32.const 2) (i32.const 3) (br_if 0 (i32.const 4) (i32.const 10))
|
||||
)
|
||||
)
|
||||
)
|
||||
|
||||
(func (export "as-local.set-value") (param i32) (result i32)
|
||||
(local i32)
|
||||
(block (result i32)
|
||||
(local.set 0 (br_if 0 (i32.const 17) (local.get 0)))
|
||||
(i32.const -1)
|
||||
)
|
||||
)
|
||||
(func (export "as-local.tee-value") (param i32) (result i32)
|
||||
(block (result i32)
|
||||
(local.tee 0 (br_if 0 (i32.const 1) (local.get 0)))
|
||||
(return (i32.const -1))
|
||||
)
|
||||
)
|
||||
(global $$a (mut i32) (i32.const 10))
|
||||
(func (export "as-global.set-value") (param i32) (result i32)
|
||||
(block (result i32)
|
||||
(global.set $$a (br_if 0 (i32.const 1) (local.get 0)))
|
||||
(return (i32.const -1))
|
||||
)
|
||||
)
|
||||
|
||||
(memory 1)
|
||||
(func (export "as-load-address") (result i32)
|
||||
(block (result i32) (i32.load (br_if 0 (i32.const 1) (i32.const 1))))
|
||||
)
|
||||
(func (export "as-loadN-address") (result i32)
|
||||
(block (result i32) (i32.load8_s (br_if 0 (i32.const 30) (i32.const 1))))
|
||||
)
|
||||
|
||||
(func (export "as-store-address") (result i32)
|
||||
(block (result i32)
|
||||
(i32.store (br_if 0 (i32.const 30) (i32.const 1)) (i32.const 7)) (i32.const -1)
|
||||
)
|
||||
)
|
||||
(func (export "as-store-value") (result i32)
|
||||
(block (result i32)
|
||||
(i32.store (i32.const 2) (br_if 0 (i32.const 31) (i32.const 1))) (i32.const -1)
|
||||
)
|
||||
)
|
||||
|
||||
(func (export "as-storeN-address") (result i32)
|
||||
(block (result i32)
|
||||
(i32.store8 (br_if 0 (i32.const 32) (i32.const 1)) (i32.const 7)) (i32.const -1)
|
||||
)
|
||||
)
|
||||
(func (export "as-storeN-value") (result i32)
|
||||
(block (result i32)
|
||||
(i32.store16 (i32.const 2) (br_if 0 (i32.const 33) (i32.const 1))) (i32.const -1)
|
||||
)
|
||||
)
|
||||
|
||||
(func (export "as-unary-operand") (result f64)
|
||||
(block (result f64) (f64.neg (br_if 0 (f64.const 1.0) (i32.const 1))))
|
||||
)
|
||||
(func (export "as-binary-left") (result i32)
|
||||
(block (result i32) (i32.add (br_if 0 (i32.const 1) (i32.const 1)) (i32.const 10)))
|
||||
)
|
||||
(func (export "as-binary-right") (result i32)
|
||||
(block (result i32) (i32.sub (i32.const 10) (br_if 0 (i32.const 1) (i32.const 1))))
|
||||
)
|
||||
(func (export "as-test-operand") (result i32)
|
||||
(block (result i32) (i32.eqz (br_if 0 (i32.const 0) (i32.const 1))))
|
||||
)
|
||||
(func (export "as-compare-left") (result i32)
|
||||
(block (result i32) (i32.le_u (br_if 0 (i32.const 1) (i32.const 1)) (i32.const 10)))
|
||||
)
|
||||
(func (export "as-compare-right") (result i32)
|
||||
(block (result i32) (i32.ne (i32.const 10) (br_if 0 (i32.const 1) (i32.const 42))))
|
||||
)
|
||||
|
||||
(func (export "as-memory.grow-size") (result i32)
|
||||
(block (result i32) (memory.grow (br_if 0 (i32.const 1) (i32.const 1))))
|
||||
)
|
||||
|
||||
(func (export "nested-block-value") (param i32) (result i32)
|
||||
(i32.add
|
||||
(i32.const 1)
|
||||
(block (result i32)
|
||||
(drop (i32.const 2))
|
||||
(i32.add
|
||||
(i32.const 4)
|
||||
(block (result i32)
|
||||
(drop (br_if 1 (i32.const 8) (local.get 0)))
|
||||
(i32.const 16)
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
|
||||
(func (export "nested-br-value") (param i32) (result i32)
|
||||
(i32.add
|
||||
(i32.const 1)
|
||||
(block (result i32)
|
||||
(drop (i32.const 2))
|
||||
(br 0
|
||||
(block (result i32)
|
||||
(drop (br_if 1 (i32.const 8) (local.get 0))) (i32.const 4)
|
||||
)
|
||||
)
|
||||
(i32.const 16)
|
||||
)
|
||||
)
|
||||
)
|
||||
|
||||
(func (export "nested-br_if-value") (param i32) (result i32)
|
||||
(i32.add
|
||||
(i32.const 1)
|
||||
(block (result i32)
|
||||
(drop (i32.const 2))
|
||||
(drop (br_if 0
|
||||
(block (result i32)
|
||||
(drop (br_if 1 (i32.const 8) (local.get 0))) (i32.const 4)
|
||||
)
|
||||
(i32.const 1)
|
||||
))
|
||||
(i32.const 16)
|
||||
)
|
||||
)
|
||||
)
|
||||
|
||||
(func (export "nested-br_if-value-cond") (param i32) (result i32)
|
||||
(i32.add
|
||||
(i32.const 1)
|
||||
(block (result i32)
|
||||
(drop (i32.const 2))
|
||||
(drop (br_if 0
|
||||
(i32.const 4)
|
||||
(block (result i32)
|
||||
(drop (br_if 1 (i32.const 8) (local.get 0))) (i32.const 1)
|
||||
)
|
||||
))
|
||||
(i32.const 16)
|
||||
)
|
||||
)
|
||||
)
|
||||
|
||||
(func (export "nested-br_table-value") (param i32) (result i32)
|
||||
(i32.add
|
||||
(i32.const 1)
|
||||
(block (result i32)
|
||||
(drop (i32.const 2))
|
||||
(br_table 0
|
||||
(block (result i32)
|
||||
(drop (br_if 1 (i32.const 8) (local.get 0))) (i32.const 4)
|
||||
)
|
||||
(i32.const 1)
|
||||
)
|
||||
(i32.const 16)
|
||||
)
|
||||
)
|
||||
)
|
||||
|
||||
(func (export "nested-br_table-value-index") (param i32) (result i32)
|
||||
(i32.add
|
||||
(i32.const 1)
|
||||
(block (result i32)
|
||||
(drop (i32.const 2))
|
||||
(br_table 0
|
||||
(i32.const 4)
|
||||
(block (result i32)
|
||||
(drop (br_if 1 (i32.const 8) (local.get 0))) (i32.const 1)
|
||||
)
|
||||
)
|
||||
(i32.const 16)
|
||||
)
|
||||
)
|
||||
)
|
||||
|
||||
)`);
|
||||
|
||||
// ./test/core/br_if.wast:372
|
||||
assert_return(() => invoke($0, `type-i32`, []), []);
|
||||
|
||||
// ./test/core/br_if.wast:373
|
||||
assert_return(() => invoke($0, `type-i64`, []), []);
|
||||
|
||||
// ./test/core/br_if.wast:374
|
||||
assert_return(() => invoke($0, `type-f32`, []), []);
|
||||
|
||||
// ./test/core/br_if.wast:375
|
||||
assert_return(() => invoke($0, `type-f64`, []), []);
|
||||
|
||||
// ./test/core/br_if.wast:377
|
||||
assert_return(() => invoke($0, `type-i32-value`, []), [value("i32", 1)]);
|
||||
|
||||
// ./test/core/br_if.wast:378
|
||||
assert_return(() => invoke($0, `type-i64-value`, []), [value("i64", 2n)]);
|
||||
|
||||
// ./test/core/br_if.wast:379
|
||||
assert_return(() => invoke($0, `type-f32-value`, []), [value("f32", 3)]);
|
||||
|
||||
// ./test/core/br_if.wast:380
|
||||
assert_return(() => invoke($0, `type-f64-value`, []), [value("f64", 4)]);
|
||||
|
||||
// ./test/core/br_if.wast:382
|
||||
assert_return(() => invoke($0, `as-block-first`, [0]), [value("i32", 2)]);
|
||||
|
||||
// ./test/core/br_if.wast:383
|
||||
assert_return(() => invoke($0, `as-block-first`, [1]), [value("i32", 3)]);
|
||||
|
||||
// ./test/core/br_if.wast:384
|
||||
assert_return(() => invoke($0, `as-block-mid`, [0]), [value("i32", 2)]);
|
||||
|
||||
// ./test/core/br_if.wast:385
|
||||
assert_return(() => invoke($0, `as-block-mid`, [1]), [value("i32", 3)]);
|
||||
|
||||
// ./test/core/br_if.wast:386
|
||||
assert_return(() => invoke($0, `as-block-last`, [0]), []);
|
||||
|
||||
// ./test/core/br_if.wast:387
|
||||
assert_return(() => invoke($0, `as-block-last`, [1]), []);
|
||||
|
||||
// ./test/core/br_if.wast:389
|
||||
assert_return(() => invoke($0, `as-block-first-value`, [0]), [
|
||||
value("i32", 11),
|
||||
]);
|
||||
|
||||
// ./test/core/br_if.wast:390
|
||||
assert_return(() => invoke($0, `as-block-first-value`, [1]), [
|
||||
value("i32", 10),
|
||||
]);
|
||||
|
||||
// ./test/core/br_if.wast:391
|
||||
assert_return(() => invoke($0, `as-block-mid-value`, [0]), [value("i32", 21)]);
|
||||
|
||||
// ./test/core/br_if.wast:392
|
||||
assert_return(() => invoke($0, `as-block-mid-value`, [1]), [value("i32", 20)]);
|
||||
|
||||
// ./test/core/br_if.wast:393
|
||||
assert_return(() => invoke($0, `as-block-last-value`, [0]), [value("i32", 11)]);
|
||||
|
||||
// ./test/core/br_if.wast:394
|
||||
assert_return(() => invoke($0, `as-block-last-value`, [1]), [value("i32", 11)]);
|
||||
|
||||
// ./test/core/br_if.wast:396
|
||||
assert_return(() => invoke($0, `as-loop-first`, [0]), [value("i32", 2)]);
|
||||
|
||||
// ./test/core/br_if.wast:397
|
||||
assert_return(() => invoke($0, `as-loop-first`, [1]), [value("i32", 3)]);
|
||||
|
||||
// ./test/core/br_if.wast:398
|
||||
assert_return(() => invoke($0, `as-loop-mid`, [0]), [value("i32", 2)]);
|
||||
|
||||
// ./test/core/br_if.wast:399
|
||||
assert_return(() => invoke($0, `as-loop-mid`, [1]), [value("i32", 4)]);
|
||||
|
||||
// ./test/core/br_if.wast:400
|
||||
assert_return(() => invoke($0, `as-loop-last`, [0]), []);
|
||||
|
||||
// ./test/core/br_if.wast:401
|
||||
assert_return(() => invoke($0, `as-loop-last`, [1]), []);
|
||||
|
||||
// ./test/core/br_if.wast:403
|
||||
assert_return(() => invoke($0, `as-br-value`, []), [value("i32", 1)]);
|
||||
|
||||
// ./test/core/br_if.wast:405
|
||||
assert_return(() => invoke($0, `as-br_if-cond`, []), []);
|
||||
|
||||
// ./test/core/br_if.wast:406
|
||||
assert_return(() => invoke($0, `as-br_if-value`, []), [value("i32", 1)]);
|
||||
|
||||
// ./test/core/br_if.wast:407
|
||||
assert_return(() => invoke($0, `as-br_if-value-cond`, [0]), [value("i32", 2)]);
|
||||
|
||||
// ./test/core/br_if.wast:408
|
||||
assert_return(() => invoke($0, `as-br_if-value-cond`, [1]), [value("i32", 1)]);
|
||||
|
||||
// ./test/core/br_if.wast:410
|
||||
assert_return(() => invoke($0, `as-br_table-index`, []), []);
|
||||
|
||||
// ./test/core/br_if.wast:411
|
||||
assert_return(() => invoke($0, `as-br_table-value`, []), [value("i32", 1)]);
|
||||
|
||||
// ./test/core/br_if.wast:412
|
||||
assert_return(() => invoke($0, `as-br_table-value-index`, []), [
|
||||
value("i32", 1),
|
||||
]);
|
||||
|
||||
// ./test/core/br_if.wast:414
|
||||
assert_return(() => invoke($0, `as-return-value`, []), [value("i64", 1n)]);
|
||||
|
||||
// ./test/core/br_if.wast:416
|
||||
assert_return(() => invoke($0, `as-if-cond`, [0]), [value("i32", 2)]);
|
||||
|
||||
// ./test/core/br_if.wast:417
|
||||
assert_return(() => invoke($0, `as-if-cond`, [1]), [value("i32", 1)]);
|
||||
|
||||
// ./test/core/br_if.wast:418
|
||||
assert_return(() => invoke($0, `as-if-then`, [0, 0]), []);
|
||||
|
||||
// ./test/core/br_if.wast:419
|
||||
assert_return(() => invoke($0, `as-if-then`, [4, 0]), []);
|
||||
|
||||
// ./test/core/br_if.wast:420
|
||||
assert_return(() => invoke($0, `as-if-then`, [0, 1]), []);
|
||||
|
||||
// ./test/core/br_if.wast:421
|
||||
assert_return(() => invoke($0, `as-if-then`, [4, 1]), []);
|
||||
|
||||
// ./test/core/br_if.wast:422
|
||||
assert_return(() => invoke($0, `as-if-else`, [0, 0]), []);
|
||||
|
||||
// ./test/core/br_if.wast:423
|
||||
assert_return(() => invoke($0, `as-if-else`, [3, 0]), []);
|
||||
|
||||
// ./test/core/br_if.wast:424
|
||||
assert_return(() => invoke($0, `as-if-else`, [0, 1]), []);
|
||||
|
||||
// ./test/core/br_if.wast:425
|
||||
assert_return(() => invoke($0, `as-if-else`, [3, 1]), []);
|
||||
|
||||
// ./test/core/br_if.wast:427
|
||||
assert_return(() => invoke($0, `as-select-first`, [0]), [value("i32", 3)]);
|
||||
|
||||
// ./test/core/br_if.wast:428
|
||||
assert_return(() => invoke($0, `as-select-first`, [1]), [value("i32", 3)]);
|
||||
|
||||
// ./test/core/br_if.wast:429
|
||||
assert_return(() => invoke($0, `as-select-second`, [0]), [value("i32", 3)]);
|
||||
|
||||
// ./test/core/br_if.wast:430
|
||||
assert_return(() => invoke($0, `as-select-second`, [1]), [value("i32", 3)]);
|
||||
|
||||
// ./test/core/br_if.wast:431
|
||||
assert_return(() => invoke($0, `as-select-cond`, []), [value("i32", 3)]);
|
||||
|
||||
// ./test/core/br_if.wast:433
|
||||
assert_return(() => invoke($0, `as-call-first`, []), [value("i32", 12)]);
|
||||
|
||||
// ./test/core/br_if.wast:434
|
||||
assert_return(() => invoke($0, `as-call-mid`, []), [value("i32", 13)]);
|
||||
|
||||
// ./test/core/br_if.wast:435
|
||||
assert_return(() => invoke($0, `as-call-last`, []), [value("i32", 14)]);
|
||||
|
||||
// ./test/core/br_if.wast:437
|
||||
assert_return(() => invoke($0, `as-call_indirect-func`, []), [value("i32", 4)]);
|
||||
|
||||
// ./test/core/br_if.wast:438
|
||||
assert_return(() => invoke($0, `as-call_indirect-first`, []), [
|
||||
value("i32", 4),
|
||||
]);
|
||||
|
||||
// ./test/core/br_if.wast:439
|
||||
assert_return(() => invoke($0, `as-call_indirect-mid`, []), [value("i32", 4)]);
|
||||
|
||||
// ./test/core/br_if.wast:440
|
||||
assert_return(() => invoke($0, `as-call_indirect-last`, []), [value("i32", 4)]);
|
||||
|
||||
// ./test/core/br_if.wast:442
|
||||
assert_return(() => invoke($0, `as-local.set-value`, [0]), [value("i32", -1)]);
|
||||
|
||||
// ./test/core/br_if.wast:443
|
||||
assert_return(() => invoke($0, `as-local.set-value`, [1]), [value("i32", 17)]);
|
||||
|
||||
// ./test/core/br_if.wast:445
|
||||
assert_return(() => invoke($0, `as-local.tee-value`, [0]), [value("i32", -1)]);
|
||||
|
||||
// ./test/core/br_if.wast:446
|
||||
assert_return(() => invoke($0, `as-local.tee-value`, [1]), [value("i32", 1)]);
|
||||
|
||||
// ./test/core/br_if.wast:448
|
||||
assert_return(() => invoke($0, `as-global.set-value`, [0]), [value("i32", -1)]);
|
||||
|
||||
// ./test/core/br_if.wast:449
|
||||
assert_return(() => invoke($0, `as-global.set-value`, [1]), [value("i32", 1)]);
|
||||
|
||||
// ./test/core/br_if.wast:451
|
||||
assert_return(() => invoke($0, `as-load-address`, []), [value("i32", 1)]);
|
||||
|
||||
// ./test/core/br_if.wast:452
|
||||
assert_return(() => invoke($0, `as-loadN-address`, []), [value("i32", 30)]);
|
||||
|
||||
// ./test/core/br_if.wast:454
|
||||
assert_return(() => invoke($0, `as-store-address`, []), [value("i32", 30)]);
|
||||
|
||||
// ./test/core/br_if.wast:455
|
||||
assert_return(() => invoke($0, `as-store-value`, []), [value("i32", 31)]);
|
||||
|
||||
// ./test/core/br_if.wast:456
|
||||
assert_return(() => invoke($0, `as-storeN-address`, []), [value("i32", 32)]);
|
||||
|
||||
// ./test/core/br_if.wast:457
|
||||
assert_return(() => invoke($0, `as-storeN-value`, []), [value("i32", 33)]);
|
||||
|
||||
// ./test/core/br_if.wast:459
|
||||
assert_return(() => invoke($0, `as-unary-operand`, []), [value("f64", 1)]);
|
||||
|
||||
// ./test/core/br_if.wast:460
|
||||
assert_return(() => invoke($0, `as-binary-left`, []), [value("i32", 1)]);
|
||||
|
||||
// ./test/core/br_if.wast:461
|
||||
assert_return(() => invoke($0, `as-binary-right`, []), [value("i32", 1)]);
|
||||
|
||||
// ./test/core/br_if.wast:462
|
||||
assert_return(() => invoke($0, `as-test-operand`, []), [value("i32", 0)]);
|
||||
|
||||
// ./test/core/br_if.wast:463
|
||||
assert_return(() => invoke($0, `as-compare-left`, []), [value("i32", 1)]);
|
||||
|
||||
// ./test/core/br_if.wast:464
|
||||
assert_return(() => invoke($0, `as-compare-right`, []), [value("i32", 1)]);
|
||||
|
||||
// ./test/core/br_if.wast:465
|
||||
assert_return(() => invoke($0, `as-memory.grow-size`, []), [value("i32", 1)]);
|
||||
|
||||
// ./test/core/br_if.wast:467
|
||||
assert_return(() => invoke($0, `nested-block-value`, [0]), [value("i32", 21)]);
|
||||
|
||||
// ./test/core/br_if.wast:468
|
||||
assert_return(() => invoke($0, `nested-block-value`, [1]), [value("i32", 9)]);
|
||||
|
||||
// ./test/core/br_if.wast:469
|
||||
assert_return(() => invoke($0, `nested-br-value`, [0]), [value("i32", 5)]);
|
||||
|
||||
// ./test/core/br_if.wast:470
|
||||
assert_return(() => invoke($0, `nested-br-value`, [1]), [value("i32", 9)]);
|
||||
|
||||
// ./test/core/br_if.wast:471
|
||||
assert_return(() => invoke($0, `nested-br_if-value`, [0]), [value("i32", 5)]);
|
||||
|
||||
// ./test/core/br_if.wast:472
|
||||
assert_return(() => invoke($0, `nested-br_if-value`, [1]), [value("i32", 9)]);
|
||||
|
||||
// ./test/core/br_if.wast:473
|
||||
assert_return(() => invoke($0, `nested-br_if-value-cond`, [0]), [
|
||||
value("i32", 5),
|
||||
]);
|
||||
|
||||
// ./test/core/br_if.wast:474
|
||||
assert_return(() => invoke($0, `nested-br_if-value-cond`, [1]), [
|
||||
value("i32", 9),
|
||||
]);
|
||||
|
||||
// ./test/core/br_if.wast:475
|
||||
assert_return(() => invoke($0, `nested-br_table-value`, [0]), [
|
||||
value("i32", 5),
|
||||
]);
|
||||
|
||||
// ./test/core/br_if.wast:476
|
||||
assert_return(() => invoke($0, `nested-br_table-value`, [1]), [
|
||||
value("i32", 9),
|
||||
]);
|
||||
|
||||
// ./test/core/br_if.wast:477
|
||||
assert_return(() => invoke($0, `nested-br_table-value-index`, [0]), [
|
||||
value("i32", 5),
|
||||
]);
|
||||
|
||||
// ./test/core/br_if.wast:478
|
||||
assert_return(() => invoke($0, `nested-br_table-value-index`, [1]), [
|
||||
value("i32", 9),
|
||||
]);
|
||||
|
||||
// ./test/core/br_if.wast:480
|
||||
assert_invalid(
|
||||
() =>
|
||||
instantiate(
|
||||
`(module (func $$type-false-i32 (block (i32.ctz (br_if 0 (i32.const 0))))))`,
|
||||
),
|
||||
`type mismatch`,
|
||||
);
|
||||
|
||||
// ./test/core/br_if.wast:484
|
||||
assert_invalid(
|
||||
() =>
|
||||
instantiate(
|
||||
`(module (func $$type-false-i64 (block (i64.ctz (br_if 0 (i32.const 0))))))`,
|
||||
),
|
||||
`type mismatch`,
|
||||
);
|
||||
|
||||
// ./test/core/br_if.wast:488
|
||||
assert_invalid(
|
||||
() =>
|
||||
instantiate(
|
||||
`(module (func $$type-false-f32 (block (f32.neg (br_if 0 (i32.const 0))))))`,
|
||||
),
|
||||
`type mismatch`,
|
||||
);
|
||||
|
||||
// ./test/core/br_if.wast:492
|
||||
assert_invalid(
|
||||
() =>
|
||||
instantiate(
|
||||
`(module (func $$type-false-f64 (block (f64.neg (br_if 0 (i32.const 0))))))`,
|
||||
),
|
||||
`type mismatch`,
|
||||
);
|
||||
|
||||
// ./test/core/br_if.wast:497
|
||||
assert_invalid(
|
||||
() =>
|
||||
instantiate(
|
||||
`(module (func $$type-true-i32 (block (i32.ctz (br_if 0 (i32.const 1))))))`,
|
||||
),
|
||||
`type mismatch`,
|
||||
);
|
||||
|
||||
// ./test/core/br_if.wast:501
|
||||
assert_invalid(
|
||||
() =>
|
||||
instantiate(
|
||||
`(module (func $$type-true-i64 (block (i64.ctz (br_if 0 (i64.const 1))))))`,
|
||||
),
|
||||
`type mismatch`,
|
||||
);
|
||||
|
||||
// ./test/core/br_if.wast:505
|
||||
assert_invalid(
|
||||
() =>
|
||||
instantiate(
|
||||
`(module (func $$type-true-f32 (block (f32.neg (br_if 0 (f32.const 1))))))`,
|
||||
),
|
||||
`type mismatch`,
|
||||
);
|
||||
|
||||
// ./test/core/br_if.wast:509
|
||||
assert_invalid(
|
||||
() =>
|
||||
instantiate(
|
||||
`(module (func $$type-true-f64 (block (f64.neg (br_if 0 (i64.const 1))))))`,
|
||||
),
|
||||
`type mismatch`,
|
||||
);
|
||||
|
||||
// ./test/core/br_if.wast:514
|
||||
assert_invalid(
|
||||
() =>
|
||||
instantiate(`(module (func $$type-false-arg-void-vs-num (result i32)
|
||||
(block (result i32) (br_if 0 (i32.const 0)) (i32.const 1))
|
||||
))`),
|
||||
`type mismatch`,
|
||||
);
|
||||
|
||||
// ./test/core/br_if.wast:520
|
||||
assert_invalid(
|
||||
() =>
|
||||
instantiate(`(module (func $$type-true-arg-void-vs-num (result i32)
|
||||
(block (result i32) (br_if 0 (i32.const 1)) (i32.const 1))
|
||||
))`),
|
||||
`type mismatch`,
|
||||
);
|
||||
|
||||
// ./test/core/br_if.wast:526
|
||||
assert_invalid(() =>
|
||||
instantiate(`(module (func $$type-false-arg-num-vs-void
|
||||
(block (br_if 0 (i32.const 0) (i32.const 0)))
|
||||
))`), `type mismatch`);
|
||||
|
||||
// ./test/core/br_if.wast:532
|
||||
assert_invalid(() =>
|
||||
instantiate(`(module (func $$type-true-arg-num-vs-void
|
||||
(block (br_if 0 (i32.const 0) (i32.const 1)))
|
||||
))`), `type mismatch`);
|
||||
|
||||
// ./test/core/br_if.wast:539
|
||||
assert_invalid(
|
||||
() =>
|
||||
instantiate(`(module (func $$type-false-arg-void-vs-num (result i32)
|
||||
(block (result i32) (br_if 0 (nop) (i32.const 0)) (i32.const 1))
|
||||
))`),
|
||||
`type mismatch`,
|
||||
);
|
||||
|
||||
// ./test/core/br_if.wast:545
|
||||
assert_invalid(
|
||||
() =>
|
||||
instantiate(`(module (func $$type-true-arg-void-vs-num (result i32)
|
||||
(block (result i32) (br_if 0 (nop) (i32.const 1)) (i32.const 1))
|
||||
))`),
|
||||
`type mismatch`,
|
||||
);
|
||||
|
||||
// ./test/core/br_if.wast:551
|
||||
assert_invalid(
|
||||
() =>
|
||||
instantiate(`(module (func $$type-false-arg-num-vs-num (result i32)
|
||||
(block (result i32)
|
||||
(drop (br_if 0 (i64.const 1) (i32.const 0))) (i32.const 1)
|
||||
)
|
||||
))`),
|
||||
`type mismatch`,
|
||||
);
|
||||
|
||||
// ./test/core/br_if.wast:559
|
||||
assert_invalid(
|
||||
() =>
|
||||
instantiate(`(module (func $$type-true-arg-num-vs-num (result i32)
|
||||
(block (result i32)
|
||||
(drop (br_if 0 (i64.const 1) (i32.const 0))) (i32.const 1)
|
||||
)
|
||||
))`),
|
||||
`type mismatch`,
|
||||
);
|
||||
|
||||
// ./test/core/br_if.wast:568
|
||||
assert_invalid(() =>
|
||||
instantiate(`(module (func $$type-cond-empty-vs-i32
|
||||
(block (br_if 0))
|
||||
))`), `type mismatch`);
|
||||
|
||||
// ./test/core/br_if.wast:574
|
||||
assert_invalid(() =>
|
||||
instantiate(`(module (func $$type-cond-void-vs-i32
|
||||
(block (br_if 0 (nop)))
|
||||
))`), `type mismatch`);
|
||||
|
||||
// ./test/core/br_if.wast:580
|
||||
assert_invalid(() =>
|
||||
instantiate(`(module (func $$type-cond-num-vs-i32
|
||||
(block (br_if 0 (i64.const 0)))
|
||||
))`), `type mismatch`);
|
||||
|
||||
// ./test/core/br_if.wast:586
|
||||
assert_invalid(
|
||||
() =>
|
||||
instantiate(`(module (func $$type-arg-cond-void-vs-i32 (result i32)
|
||||
(block (result i32) (br_if 0 (i32.const 0) (nop)) (i32.const 1))
|
||||
))`),
|
||||
`type mismatch`,
|
||||
);
|
||||
|
||||
// ./test/core/br_if.wast:592
|
||||
assert_invalid(
|
||||
() =>
|
||||
instantiate(`(module (func $$type-arg-void-vs-num-nested (result i32)
|
||||
(block (result i32) (i32.const 0) (block (br_if 1 (i32.const 1))))
|
||||
))`),
|
||||
`type mismatch`,
|
||||
);
|
||||
|
||||
// ./test/core/br_if.wast:598
|
||||
assert_invalid(
|
||||
() =>
|
||||
instantiate(`(module (func $$type-arg-cond-num-vs-i32 (result i32)
|
||||
(block (result i32) (br_if 0 (i32.const 0) (i64.const 0)) (i32.const 1))
|
||||
))`),
|
||||
`type mismatch`,
|
||||
);
|
||||
|
||||
// ./test/core/br_if.wast:605
|
||||
assert_invalid(() =>
|
||||
instantiate(`(module
|
||||
(func $$type-1st-cond-empty-in-then
|
||||
(block
|
||||
(i32.const 0) (i32.const 0)
|
||||
(if (result i32) (then (br_if 0)))
|
||||
)
|
||||
(i32.eqz) (drop)
|
||||
)
|
||||
)`), `type mismatch`);
|
||||
|
||||
// ./test/core/br_if.wast:617
|
||||
assert_invalid(() =>
|
||||
instantiate(`(module
|
||||
(func $$type-2nd-cond-empty-in-then
|
||||
(block
|
||||
(i32.const 0) (i32.const 0)
|
||||
(if (result i32) (then (br_if 0 (i32.const 1))))
|
||||
)
|
||||
(i32.eqz) (drop)
|
||||
)
|
||||
)`), `type mismatch`);
|
||||
|
||||
// ./test/core/br_if.wast:629
|
||||
assert_invalid(() =>
|
||||
instantiate(`(module
|
||||
(func $$type-1st-cond-empty-in-return
|
||||
(block (result i32)
|
||||
(return (br_if 0))
|
||||
)
|
||||
(i32.eqz) (drop)
|
||||
)
|
||||
)`), `type mismatch`);
|
||||
|
||||
// ./test/core/br_if.wast:640
|
||||
assert_invalid(() =>
|
||||
instantiate(`(module
|
||||
(func $$type-2nd-cond-empty-in-return
|
||||
(block (result i32)
|
||||
(return (br_if 0 (i32.const 1)))
|
||||
)
|
||||
(i32.eqz) (drop)
|
||||
)
|
||||
)`), `type mismatch`);
|
||||
|
||||
// ./test/core/br_if.wast:653
|
||||
assert_invalid(
|
||||
() => instantiate(`(module (func $$unbound-label (br_if 1 (i32.const 1))))`),
|
||||
`unknown label`,
|
||||
);
|
||||
|
||||
// ./test/core/br_if.wast:657
|
||||
assert_invalid(
|
||||
() =>
|
||||
instantiate(
|
||||
`(module (func $$unbound-nested-label (block (block (br_if 5 (i32.const 1))))))`,
|
||||
),
|
||||
`unknown label`,
|
||||
);
|
||||
|
||||
// ./test/core/br_if.wast:661
|
||||
assert_invalid(
|
||||
() =>
|
||||
instantiate(
|
||||
`(module (func $$large-label (br_if 0x10000001 (i32.const 1))))`,
|
||||
),
|
||||
`unknown label`,
|
||||
);
|
32
js/src/jit-test/tests/wasm/spec/threads/break-drop.wast.js
Normal file
32
js/src/jit-test/tests/wasm/spec/threads/break-drop.wast.js
Normal file
@ -0,0 +1,32 @@
|
||||
/* Copyright 2021 Mozilla Foundation
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
// ./test/core/break-drop.wast
|
||||
|
||||
// ./test/core/break-drop.wast:1
|
||||
let $0 = instantiate(`(module
|
||||
(func (export "br") (block (br 0)))
|
||||
(func (export "br_if") (block (br_if 0 (i32.const 1))))
|
||||
(func (export "br_table") (block (br_table 0 (i32.const 0))))
|
||||
)`);
|
||||
|
||||
// ./test/core/break-drop.wast:7
|
||||
assert_return(() => invoke($0, `br`, []), []);
|
||||
|
||||
// ./test/core/break-drop.wast:8
|
||||
assert_return(() => invoke($0, `br_if`, []), []);
|
||||
|
||||
// ./test/core/break-drop.wast:9
|
||||
assert_return(() => invoke($0, `br_table`, []), []);
|
593
js/src/jit-test/tests/wasm/spec/threads/call.wast.js
Normal file
593
js/src/jit-test/tests/wasm/spec/threads/call.wast.js
Normal file
@ -0,0 +1,593 @@
|
||||
/* Copyright 2021 Mozilla Foundation
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
// ./test/core/call.wast
|
||||
|
||||
// ./test/core/call.wast:3
|
||||
let $0 = instantiate(`(module
|
||||
;; Auxiliary definitions
|
||||
(func $$const-i32 (result i32) (i32.const 0x132))
|
||||
(func $$const-i64 (result i64) (i64.const 0x164))
|
||||
(func $$const-f32 (result f32) (f32.const 0xf32))
|
||||
(func $$const-f64 (result f64) (f64.const 0xf64))
|
||||
|
||||
(func $$id-i32 (param i32) (result i32) (local.get 0))
|
||||
(func $$id-i64 (param i64) (result i64) (local.get 0))
|
||||
(func $$id-f32 (param f32) (result f32) (local.get 0))
|
||||
(func $$id-f64 (param f64) (result f64) (local.get 0))
|
||||
|
||||
(func $$f32-i32 (param f32 i32) (result i32) (local.get 1))
|
||||
(func $$i32-i64 (param i32 i64) (result i64) (local.get 1))
|
||||
(func $$f64-f32 (param f64 f32) (result f32) (local.get 1))
|
||||
(func $$i64-f64 (param i64 f64) (result f64) (local.get 1))
|
||||
|
||||
;; Typing
|
||||
|
||||
(func (export "type-i32") (result i32) (call $$const-i32))
|
||||
(func (export "type-i64") (result i64) (call $$const-i64))
|
||||
(func (export "type-f32") (result f32) (call $$const-f32))
|
||||
(func (export "type-f64") (result f64) (call $$const-f64))
|
||||
|
||||
(func (export "type-first-i32") (result i32) (call $$id-i32 (i32.const 32)))
|
||||
(func (export "type-first-i64") (result i64) (call $$id-i64 (i64.const 64)))
|
||||
(func (export "type-first-f32") (result f32) (call $$id-f32 (f32.const 1.32)))
|
||||
(func (export "type-first-f64") (result f64) (call $$id-f64 (f64.const 1.64)))
|
||||
|
||||
(func (export "type-second-i32") (result i32)
|
||||
(call $$f32-i32 (f32.const 32.1) (i32.const 32))
|
||||
)
|
||||
(func (export "type-second-i64") (result i64)
|
||||
(call $$i32-i64 (i32.const 32) (i64.const 64))
|
||||
)
|
||||
(func (export "type-second-f32") (result f32)
|
||||
(call $$f64-f32 (f64.const 64) (f32.const 32))
|
||||
)
|
||||
(func (export "type-second-f64") (result f64)
|
||||
(call $$i64-f64 (i64.const 64) (f64.const 64.1))
|
||||
)
|
||||
|
||||
;; Recursion
|
||||
|
||||
(func $$fac (export "fac") (param i64) (result i64)
|
||||
(if (result i64) (i64.eqz (local.get 0))
|
||||
(then (i64.const 1))
|
||||
(else
|
||||
(i64.mul
|
||||
(local.get 0)
|
||||
(call $$fac (i64.sub (local.get 0) (i64.const 1)))
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
|
||||
(func $$fac-acc (export "fac-acc") (param i64 i64) (result i64)
|
||||
(if (result i64) (i64.eqz (local.get 0))
|
||||
(then (local.get 1))
|
||||
(else
|
||||
(call $$fac-acc
|
||||
(i64.sub (local.get 0) (i64.const 1))
|
||||
(i64.mul (local.get 0) (local.get 1))
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
|
||||
(func $$fib (export "fib") (param i64) (result i64)
|
||||
(if (result i64) (i64.le_u (local.get 0) (i64.const 1))
|
||||
(then (i64.const 1))
|
||||
(else
|
||||
(i64.add
|
||||
(call $$fib (i64.sub (local.get 0) (i64.const 2)))
|
||||
(call $$fib (i64.sub (local.get 0) (i64.const 1)))
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
|
||||
(func $$even (export "even") (param i64) (result i32)
|
||||
(if (result i32) (i64.eqz (local.get 0))
|
||||
(then (i32.const 44))
|
||||
(else (call $$odd (i64.sub (local.get 0) (i64.const 1))))
|
||||
)
|
||||
)
|
||||
(func $$odd (export "odd") (param i64) (result i32)
|
||||
(if (result i32) (i64.eqz (local.get 0))
|
||||
(then (i32.const 99))
|
||||
(else (call $$even (i64.sub (local.get 0) (i64.const 1))))
|
||||
)
|
||||
)
|
||||
|
||||
;; Stack exhaustion
|
||||
|
||||
;; Implementations are required to have every call consume some abstract
|
||||
;; resource towards exhausting some abstract finite limit, such that
|
||||
;; infinitely recursive test cases reliably trap in finite time. This is
|
||||
;; because otherwise applications could come to depend on it on those
|
||||
;; implementations and be incompatible with implementations that don't do
|
||||
;; it (or don't do it under the same circumstances).
|
||||
|
||||
(func $$runaway (export "runaway") (call $$runaway))
|
||||
|
||||
(func $$mutual-runaway1 (export "mutual-runaway") (call $$mutual-runaway2))
|
||||
(func $$mutual-runaway2 (call $$mutual-runaway1))
|
||||
|
||||
;; As parameter of control constructs and instructions
|
||||
|
||||
(memory 1)
|
||||
|
||||
(func (export "as-select-first") (result i32)
|
||||
(select (call $$const-i32) (i32.const 2) (i32.const 3))
|
||||
)
|
||||
(func (export "as-select-mid") (result i32)
|
||||
(select (i32.const 2) (call $$const-i32) (i32.const 3))
|
||||
)
|
||||
(func (export "as-select-last") (result i32)
|
||||
(select (i32.const 2) (i32.const 3) (call $$const-i32))
|
||||
)
|
||||
|
||||
(func (export "as-if-condition") (result i32)
|
||||
(if (result i32) (call $$const-i32) (then (i32.const 1)) (else (i32.const 2)))
|
||||
)
|
||||
|
||||
(func (export "as-br_if-first") (result i32)
|
||||
(block (result i32) (br_if 0 (call $$const-i32) (i32.const 2)))
|
||||
)
|
||||
(func (export "as-br_if-last") (result i32)
|
||||
(block (result i32) (br_if 0 (i32.const 2) (call $$const-i32)))
|
||||
)
|
||||
|
||||
(func (export "as-br_table-first") (result i32)
|
||||
(block (result i32) (call $$const-i32) (i32.const 2) (br_table 0 0))
|
||||
)
|
||||
(func (export "as-br_table-last") (result i32)
|
||||
(block (result i32) (i32.const 2) (call $$const-i32) (br_table 0 0))
|
||||
)
|
||||
|
||||
(func $$func (param i32 i32) (result i32) (local.get 0))
|
||||
(type $$check (func (param i32 i32) (result i32)))
|
||||
(table funcref (elem $$func))
|
||||
(func (export "as-call_indirect-first") (result i32)
|
||||
(block (result i32)
|
||||
(call_indirect (type $$check)
|
||||
(call $$const-i32) (i32.const 2) (i32.const 0)
|
||||
)
|
||||
)
|
||||
)
|
||||
(func (export "as-call_indirect-mid") (result i32)
|
||||
(block (result i32)
|
||||
(call_indirect (type $$check)
|
||||
(i32.const 2) (call $$const-i32) (i32.const 0)
|
||||
)
|
||||
)
|
||||
)
|
||||
(func (export "as-call_indirect-last") (result i32)
|
||||
(block (result i32)
|
||||
(call_indirect (type $$check)
|
||||
(i32.const 1) (i32.const 2) (call $$const-i32)
|
||||
)
|
||||
)
|
||||
)
|
||||
|
||||
(func (export "as-store-first")
|
||||
(call $$const-i32) (i32.const 1) (i32.store)
|
||||
)
|
||||
(func (export "as-store-last")
|
||||
(i32.const 10) (call $$const-i32) (i32.store)
|
||||
)
|
||||
|
||||
(func (export "as-memory.grow-value") (result i32)
|
||||
(memory.grow (call $$const-i32))
|
||||
)
|
||||
(func (export "as-return-value") (result i32)
|
||||
(call $$const-i32) (return)
|
||||
)
|
||||
(func (export "as-drop-operand")
|
||||
(call $$const-i32) (drop)
|
||||
)
|
||||
(func (export "as-br-value") (result i32)
|
||||
(block (result i32) (br 0 (call $$const-i32)))
|
||||
)
|
||||
(func (export "as-local.set-value") (result i32)
|
||||
(local i32) (local.set 0 (call $$const-i32)) (local.get 0)
|
||||
)
|
||||
(func (export "as-local.tee-value") (result i32)
|
||||
(local i32) (local.tee 0 (call $$const-i32))
|
||||
)
|
||||
(global $$a (mut i32) (i32.const 10))
|
||||
(func (export "as-global.set-value") (result i32)
|
||||
(global.set $$a (call $$const-i32))
|
||||
(global.get $$a)
|
||||
)
|
||||
(func (export "as-load-operand") (result i32)
|
||||
(i32.load (call $$const-i32))
|
||||
)
|
||||
|
||||
(func $$dummy (param i32) (result i32) (local.get 0))
|
||||
(func $$du (param f32) (result f32) (local.get 0))
|
||||
(func (export "as-unary-operand") (result f32)
|
||||
(block (result f32) (f32.sqrt (call $$du (f32.const 0x0p+0))))
|
||||
)
|
||||
|
||||
(func (export "as-binary-left") (result i32)
|
||||
(block (result i32) (i32.add (call $$dummy (i32.const 1)) (i32.const 10)))
|
||||
)
|
||||
(func (export "as-binary-right") (result i32)
|
||||
(block (result i32) (i32.sub (i32.const 10) (call $$dummy (i32.const 1))))
|
||||
)
|
||||
|
||||
(func (export "as-test-operand") (result i32)
|
||||
(block (result i32) (i32.eqz (call $$dummy (i32.const 1))))
|
||||
)
|
||||
|
||||
(func (export "as-compare-left") (result i32)
|
||||
(block (result i32) (i32.le_u (call $$dummy (i32.const 1)) (i32.const 10)))
|
||||
)
|
||||
(func (export "as-compare-right") (result i32)
|
||||
(block (result i32) (i32.ne (i32.const 10) (call $$dummy (i32.const 1))))
|
||||
)
|
||||
|
||||
(func (export "as-convert-operand") (result i64)
|
||||
(block (result i64) (i64.extend_i32_s (call $$dummy (i32.const 1))))
|
||||
)
|
||||
|
||||
;; Test correct argument passing
|
||||
|
||||
(func $$return-from-long-argument-list-helper (param f32 i32 i32 f64 f32 f32 f32 f64 f32 i32 i32 f32 f64 i64 i64 i32 i64 i64 f32 i64 i64 i64 i32 f32 f32 f32 f64 f32 i32 i64 f32 f64 f64 f32 i32 f32 f32 f64 i64 f64 i32 i64 f32 f64 i32 i32 i32 i64 f64 i32 i64 i64 f64 f64 f64 f64 f64 f64 i32 f32 f64 f64 i32 i64 f32 f32 f32 i32 f64 f64 f64 f64 f64 f32 i64 i64 i32 i32 i32 f32 f64 i32 i64 f32 f32 f32 i32 i32 f32 f64 i64 f32 f64 f32 f32 f32 i32 f32 i64 i32) (result i32)
|
||||
(local.get 99)
|
||||
)
|
||||
|
||||
(func (export "return-from-long-argument-list") (param i32) (result i32)
|
||||
(call $$return-from-long-argument-list-helper (f32.const 0) (i32.const 0) (i32.const 0) (f64.const 0) (f32.const 0) (f32.const 0) (f32.const 0) (f64.const 0) (f32.const 0) (i32.const 0) (i32.const 0) (f32.const 0) (f64.const 0) (i64.const 0) (i64.const 0) (i32.const 0) (i64.const 0) (i64.const 0) (f32.const 0) (i64.const 0) (i64.const 0) (i64.const 0) (i32.const 0) (f32.const 0) (f32.const 0) (f32.const 0) (f64.const 0) (f32.const 0) (i32.const 0) (i64.const 0) (f32.const 0) (f64.const 0) (f64.const 0) (f32.const 0) (i32.const 0) (f32.const 0) (f32.const 0) (f64.const 0) (i64.const 0) (f64.const 0) (i32.const 0) (i64.const 0) (f32.const 0) (f64.const 0) (i32.const 0) (i32.const 0) (i32.const 0) (i64.const 0) (f64.const 0) (i32.const 0) (i64.const 0) (i64.const 0) (f64.const 0) (f64.const 0) (f64.const 0) (f64.const 0) (f64.const 0) (f64.const 0) (i32.const 0) (f32.const 0) (f64.const 0) (f64.const 0) (i32.const 0) (i64.const 0) (f32.const 0) (f32.const 0) (f32.const 0) (i32.const 0) (f64.const 0) (f64.const 0) (f64.const 0) (f64.const 0) (f64.const 0) (f32.const 0) (i64.const 0) (i64.const 0) (i32.const 0) (i32.const 0) (i32.const 0) (f32.const 0) (f64.const 0) (i32.const 0) (i64.const 0) (f32.const 0) (f32.const 0) (f32.const 0) (i32.const 0) (i32.const 0) (f32.const 0) (f64.const 0) (i64.const 0) (f32.const 0) (f64.const 0) (f32.const 0) (f32.const 0) (f32.const 0) (i32.const 0) (f32.const 0) (i64.const 0) (local.get 0))
|
||||
)
|
||||
)`);
|
||||
|
||||
// ./test/core/call.wast:240
|
||||
assert_return(() => invoke($0, `type-i32`, []), [value("i32", 306)]);
|
||||
|
||||
// ./test/core/call.wast:241
|
||||
assert_return(() => invoke($0, `type-i64`, []), [value("i64", 356n)]);
|
||||
|
||||
// ./test/core/call.wast:242
|
||||
assert_return(() => invoke($0, `type-f32`, []), [value("f32", 3890)]);
|
||||
|
||||
// ./test/core/call.wast:243
|
||||
assert_return(() => invoke($0, `type-f64`, []), [value("f64", 3940)]);
|
||||
|
||||
// ./test/core/call.wast:245
|
||||
assert_return(() => invoke($0, `type-first-i32`, []), [value("i32", 32)]);
|
||||
|
||||
// ./test/core/call.wast:246
|
||||
assert_return(() => invoke($0, `type-first-i64`, []), [value("i64", 64n)]);
|
||||
|
||||
// ./test/core/call.wast:247
|
||||
assert_return(() => invoke($0, `type-first-f32`, []), [value("f32", 1.32)]);
|
||||
|
||||
// ./test/core/call.wast:248
|
||||
assert_return(() => invoke($0, `type-first-f64`, []), [value("f64", 1.64)]);
|
||||
|
||||
// ./test/core/call.wast:250
|
||||
assert_return(() => invoke($0, `type-second-i32`, []), [value("i32", 32)]);
|
||||
|
||||
// ./test/core/call.wast:251
|
||||
assert_return(() => invoke($0, `type-second-i64`, []), [value("i64", 64n)]);
|
||||
|
||||
// ./test/core/call.wast:252
|
||||
assert_return(() => invoke($0, `type-second-f32`, []), [value("f32", 32)]);
|
||||
|
||||
// ./test/core/call.wast:253
|
||||
assert_return(() => invoke($0, `type-second-f64`, []), [value("f64", 64.1)]);
|
||||
|
||||
// ./test/core/call.wast:255
|
||||
assert_return(() => invoke($0, `fac`, [0n]), [value("i64", 1n)]);
|
||||
|
||||
// ./test/core/call.wast:256
|
||||
assert_return(() => invoke($0, `fac`, [1n]), [value("i64", 1n)]);
|
||||
|
||||
// ./test/core/call.wast:257
|
||||
assert_return(() => invoke($0, `fac`, [5n]), [value("i64", 120n)]);
|
||||
|
||||
// ./test/core/call.wast:258
|
||||
assert_return(() => invoke($0, `fac`, [25n]), [
|
||||
value("i64", 7034535277573963776n),
|
||||
]);
|
||||
|
||||
// ./test/core/call.wast:259
|
||||
assert_return(() => invoke($0, `fac-acc`, [0n, 1n]), [value("i64", 1n)]);
|
||||
|
||||
// ./test/core/call.wast:260
|
||||
assert_return(() => invoke($0, `fac-acc`, [1n, 1n]), [value("i64", 1n)]);
|
||||
|
||||
// ./test/core/call.wast:261
|
||||
assert_return(() => invoke($0, `fac-acc`, [5n, 1n]), [value("i64", 120n)]);
|
||||
|
||||
// ./test/core/call.wast:262
|
||||
assert_return(() => invoke($0, `fac-acc`, [25n, 1n]), [
|
||||
value("i64", 7034535277573963776n),
|
||||
]);
|
||||
|
||||
// ./test/core/call.wast:267
|
||||
assert_return(() => invoke($0, `fib`, [0n]), [value("i64", 1n)]);
|
||||
|
||||
// ./test/core/call.wast:268
|
||||
assert_return(() => invoke($0, `fib`, [1n]), [value("i64", 1n)]);
|
||||
|
||||
// ./test/core/call.wast:269
|
||||
assert_return(() => invoke($0, `fib`, [2n]), [value("i64", 2n)]);
|
||||
|
||||
// ./test/core/call.wast:270
|
||||
assert_return(() => invoke($0, `fib`, [5n]), [value("i64", 8n)]);
|
||||
|
||||
// ./test/core/call.wast:271
|
||||
assert_return(() => invoke($0, `fib`, [20n]), [value("i64", 10946n)]);
|
||||
|
||||
// ./test/core/call.wast:273
|
||||
assert_return(() => invoke($0, `even`, [0n]), [value("i32", 44)]);
|
||||
|
||||
// ./test/core/call.wast:274
|
||||
assert_return(() => invoke($0, `even`, [1n]), [value("i32", 99)]);
|
||||
|
||||
// ./test/core/call.wast:275
|
||||
assert_return(() => invoke($0, `even`, [100n]), [value("i32", 44)]);
|
||||
|
||||
// ./test/core/call.wast:276
|
||||
assert_return(() => invoke($0, `even`, [77n]), [value("i32", 99)]);
|
||||
|
||||
// ./test/core/call.wast:277
|
||||
assert_return(() => invoke($0, `odd`, [0n]), [value("i32", 99)]);
|
||||
|
||||
// ./test/core/call.wast:278
|
||||
assert_return(() => invoke($0, `odd`, [1n]), [value("i32", 44)]);
|
||||
|
||||
// ./test/core/call.wast:279
|
||||
assert_return(() => invoke($0, `odd`, [200n]), [value("i32", 99)]);
|
||||
|
||||
// ./test/core/call.wast:280
|
||||
assert_return(() => invoke($0, `odd`, [77n]), [value("i32", 44)]);
|
||||
|
||||
// ./test/core/call.wast:282
|
||||
assert_exhaustion(() => invoke($0, `runaway`, []), `call stack exhausted`);
|
||||
|
||||
// ./test/core/call.wast:283
|
||||
assert_exhaustion(
|
||||
() => invoke($0, `mutual-runaway`, []),
|
||||
`call stack exhausted`,
|
||||
);
|
||||
|
||||
// ./test/core/call.wast:285
|
||||
assert_return(() => invoke($0, `as-select-first`, []), [value("i32", 306)]);
|
||||
|
||||
// ./test/core/call.wast:286
|
||||
assert_return(() => invoke($0, `as-select-mid`, []), [value("i32", 2)]);
|
||||
|
||||
// ./test/core/call.wast:287
|
||||
assert_return(() => invoke($0, `as-select-last`, []), [value("i32", 2)]);
|
||||
|
||||
// ./test/core/call.wast:289
|
||||
assert_return(() => invoke($0, `as-if-condition`, []), [value("i32", 1)]);
|
||||
|
||||
// ./test/core/call.wast:291
|
||||
assert_return(() => invoke($0, `as-br_if-first`, []), [value("i32", 306)]);
|
||||
|
||||
// ./test/core/call.wast:292
|
||||
assert_return(() => invoke($0, `as-br_if-last`, []), [value("i32", 2)]);
|
||||
|
||||
// ./test/core/call.wast:294
|
||||
assert_return(() => invoke($0, `as-br_table-first`, []), [value("i32", 306)]);
|
||||
|
||||
// ./test/core/call.wast:295
|
||||
assert_return(() => invoke($0, `as-br_table-last`, []), [value("i32", 2)]);
|
||||
|
||||
// ./test/core/call.wast:297
|
||||
assert_return(() => invoke($0, `as-call_indirect-first`, []), [
|
||||
value("i32", 306),
|
||||
]);
|
||||
|
||||
// ./test/core/call.wast:298
|
||||
assert_return(() => invoke($0, `as-call_indirect-mid`, []), [value("i32", 2)]);
|
||||
|
||||
// ./test/core/call.wast:299
|
||||
assert_trap(() => invoke($0, `as-call_indirect-last`, []), `undefined element`);
|
||||
|
||||
// ./test/core/call.wast:301
|
||||
assert_return(() => invoke($0, `as-store-first`, []), []);
|
||||
|
||||
// ./test/core/call.wast:302
|
||||
assert_return(() => invoke($0, `as-store-last`, []), []);
|
||||
|
||||
// ./test/core/call.wast:304
|
||||
assert_return(() => invoke($0, `as-memory.grow-value`, []), [value("i32", 1)]);
|
||||
|
||||
// ./test/core/call.wast:305
|
||||
assert_return(() => invoke($0, `as-return-value`, []), [value("i32", 306)]);
|
||||
|
||||
// ./test/core/call.wast:306
|
||||
assert_return(() => invoke($0, `as-drop-operand`, []), []);
|
||||
|
||||
// ./test/core/call.wast:307
|
||||
assert_return(() => invoke($0, `as-br-value`, []), [value("i32", 306)]);
|
||||
|
||||
// ./test/core/call.wast:308
|
||||
assert_return(() => invoke($0, `as-local.set-value`, []), [value("i32", 306)]);
|
||||
|
||||
// ./test/core/call.wast:309
|
||||
assert_return(() => invoke($0, `as-local.tee-value`, []), [value("i32", 306)]);
|
||||
|
||||
// ./test/core/call.wast:310
|
||||
assert_return(() => invoke($0, `as-global.set-value`, []), [value("i32", 306)]);
|
||||
|
||||
// ./test/core/call.wast:311
|
||||
assert_return(() => invoke($0, `as-load-operand`, []), [value("i32", 1)]);
|
||||
|
||||
// ./test/core/call.wast:313
|
||||
assert_return(() => invoke($0, `as-unary-operand`, []), [value("f32", 0)]);
|
||||
|
||||
// ./test/core/call.wast:314
|
||||
assert_return(() => invoke($0, `as-binary-left`, []), [value("i32", 11)]);
|
||||
|
||||
// ./test/core/call.wast:315
|
||||
assert_return(() => invoke($0, `as-binary-right`, []), [value("i32", 9)]);
|
||||
|
||||
// ./test/core/call.wast:316
|
||||
assert_return(() => invoke($0, `as-test-operand`, []), [value("i32", 0)]);
|
||||
|
||||
// ./test/core/call.wast:317
|
||||
assert_return(() => invoke($0, `as-compare-left`, []), [value("i32", 1)]);
|
||||
|
||||
// ./test/core/call.wast:318
|
||||
assert_return(() => invoke($0, `as-compare-right`, []), [value("i32", 1)]);
|
||||
|
||||
// ./test/core/call.wast:319
|
||||
assert_return(() => invoke($0, `as-convert-operand`, []), [value("i64", 1n)]);
|
||||
|
||||
// ./test/core/call.wast:321
|
||||
assert_return(() => invoke($0, `return-from-long-argument-list`, [42]), [
|
||||
value("i32", 42),
|
||||
]);
|
||||
|
||||
// ./test/core/call.wast:325
|
||||
assert_invalid(() =>
|
||||
instantiate(`(module
|
||||
(func $$type-void-vs-num (i32.eqz (call 1)))
|
||||
(func)
|
||||
)`), `type mismatch`);
|
||||
|
||||
// ./test/core/call.wast:332
|
||||
assert_invalid(() =>
|
||||
instantiate(`(module
|
||||
(func $$type-num-vs-num (i32.eqz (call 1)))
|
||||
(func (result i64) (i64.const 1))
|
||||
)`), `type mismatch`);
|
||||
|
||||
// ./test/core/call.wast:340
|
||||
assert_invalid(() =>
|
||||
instantiate(`(module
|
||||
(func $$arity-0-vs-1 (call 1))
|
||||
(func (param i32))
|
||||
)`), `type mismatch`);
|
||||
|
||||
// ./test/core/call.wast:347
|
||||
assert_invalid(() =>
|
||||
instantiate(`(module
|
||||
(func $$arity-0-vs-2 (call 1))
|
||||
(func (param f64 i32))
|
||||
)`), `type mismatch`);
|
||||
|
||||
// ./test/core/call.wast:354
|
||||
assert_invalid(() =>
|
||||
instantiate(`(module
|
||||
(func $$arity-1-vs-0 (call 1 (i32.const 1)))
|
||||
(func)
|
||||
)`), `type mismatch`);
|
||||
|
||||
// ./test/core/call.wast:361
|
||||
assert_invalid(() =>
|
||||
instantiate(`(module
|
||||
(func $$arity-2-vs-0 (call 1 (f64.const 2) (i32.const 1)))
|
||||
(func)
|
||||
)`), `type mismatch`);
|
||||
|
||||
// ./test/core/call.wast:369
|
||||
assert_invalid(() =>
|
||||
instantiate(`(module
|
||||
(func $$type-first-void-vs-num (call 1 (nop) (i32.const 1)))
|
||||
(func (param i32 i32))
|
||||
)`), `type mismatch`);
|
||||
|
||||
// ./test/core/call.wast:376
|
||||
assert_invalid(() =>
|
||||
instantiate(`(module
|
||||
(func $$type-second-void-vs-num (call 1 (i32.const 1) (nop)))
|
||||
(func (param i32 i32))
|
||||
)`), `type mismatch`);
|
||||
|
||||
// ./test/core/call.wast:383
|
||||
assert_invalid(() =>
|
||||
instantiate(`(module
|
||||
(func $$type-first-num-vs-num (call 1 (f64.const 1) (i32.const 1)))
|
||||
(func (param i32 f64))
|
||||
)`), `type mismatch`);
|
||||
|
||||
// ./test/core/call.wast:390
|
||||
assert_invalid(() =>
|
||||
instantiate(`(module
|
||||
(func $$type-second-num-vs-num (call 1 (i32.const 1) (f64.const 1)))
|
||||
(func (param f64 i32))
|
||||
)`), `type mismatch`);
|
||||
|
||||
// ./test/core/call.wast:398
|
||||
assert_invalid(() =>
|
||||
instantiate(`(module
|
||||
(func $$type-first-empty-in-block
|
||||
(block (call 1))
|
||||
)
|
||||
(func (param i32))
|
||||
)`), `type mismatch`);
|
||||
|
||||
// ./test/core/call.wast:407
|
||||
assert_invalid(() =>
|
||||
instantiate(`(module
|
||||
(func $$type-second-empty-in-block
|
||||
(block (call 1 (i32.const 0)))
|
||||
)
|
||||
(func (param i32 i32))
|
||||
)`), `type mismatch`);
|
||||
|
||||
// ./test/core/call.wast:416
|
||||
assert_invalid(() =>
|
||||
instantiate(`(module
|
||||
(func $$type-first-empty-in-loop
|
||||
(loop (call 1))
|
||||
)
|
||||
(func (param i32))
|
||||
)`), `type mismatch`);
|
||||
|
||||
// ./test/core/call.wast:425
|
||||
assert_invalid(() =>
|
||||
instantiate(`(module
|
||||
(func $$type-second-empty-in-loop
|
||||
(loop (call 1 (i32.const 0)))
|
||||
)
|
||||
(func (param i32 i32))
|
||||
)`), `type mismatch`);
|
||||
|
||||
// ./test/core/call.wast:434
|
||||
assert_invalid(() =>
|
||||
instantiate(`(module
|
||||
(func $$type-first-empty-in-then
|
||||
(if (i32.const 0) (then (call 1)))
|
||||
)
|
||||
(func (param i32))
|
||||
)`), `type mismatch`);
|
||||
|
||||
// ./test/core/call.wast:443
|
||||
assert_invalid(() =>
|
||||
instantiate(`(module
|
||||
(func $$type-second-empty-in-then
|
||||
(if (i32.const 0) (then (call 1 (i32.const 0))))
|
||||
)
|
||||
(func (param i32 i32))
|
||||
)`), `type mismatch`);
|
||||
|
||||
// ./test/core/call.wast:456
|
||||
assert_invalid(
|
||||
() => instantiate(`(module (func $$unbound-func (call 1)))`),
|
||||
`unknown function`,
|
||||
);
|
||||
|
||||
// ./test/core/call.wast:460
|
||||
assert_invalid(
|
||||
() => instantiate(`(module (func $$large-func (call 1012321300)))`),
|
||||
`unknown function`,
|
||||
);
|
1237
js/src/jit-test/tests/wasm/spec/threads/call_indirect.wast.js
Normal file
1237
js/src/jit-test/tests/wasm/spec/threads/call_indirect.wast.js
Normal file
File diff suppressed because it is too large
Load Diff
4078
js/src/jit-test/tests/wasm/spec/threads/const.wast.js
Normal file
4078
js/src/jit-test/tests/wasm/spec/threads/const.wast.js
Normal file
File diff suppressed because it is too large
Load Diff
2762
js/src/jit-test/tests/wasm/spec/threads/conversions.wast.js
Normal file
2762
js/src/jit-test/tests/wasm/spec/threads/conversions.wast.js
Normal file
File diff suppressed because it is too large
Load Diff
132
js/src/jit-test/tests/wasm/spec/threads/custom.wast.js
Normal file
132
js/src/jit-test/tests/wasm/spec/threads/custom.wast.js
Normal file
@ -0,0 +1,132 @@
|
||||
/* Copyright 2021 Mozilla Foundation
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
// ./test/core/custom.wast
|
||||
|
||||
// ./test/core/custom.wast:1
|
||||
let $0 = instantiate(`(module binary
|
||||
"\\00asm" "\\01\\00\\00\\00"
|
||||
"\\00\\24\\10" "a custom section" "this is the payload"
|
||||
"\\00\\20\\10" "a custom section" "this is payload"
|
||||
"\\00\\11\\10" "a custom section" ""
|
||||
"\\00\\10\\00" "" "this is payload"
|
||||
"\\00\\01\\00" "" ""
|
||||
"\\00\\24\\10" "\\00\\00custom sectio\\00" "this is the payload"
|
||||
"\\00\\24\\10" "\\ef\\bb\\bfa custom sect" "this is the payload"
|
||||
"\\00\\24\\10" "a custom sect\\e2\\8c\\a3" "this is the payload"
|
||||
"\\00\\1f\\16" "module within a module" "\\00asm" "\\01\\00\\00\\00"
|
||||
)`);
|
||||
|
||||
// ./test/core/custom.wast:14
|
||||
let $1 = instantiate(`(module binary
|
||||
"\\00asm" "\\01\\00\\00\\00"
|
||||
"\\00\\0e\\06" "custom" "payload"
|
||||
"\\00\\0e\\06" "custom" "payload"
|
||||
"\\01\\01\\00" ;; type section
|
||||
"\\00\\0e\\06" "custom" "payload"
|
||||
"\\00\\0e\\06" "custom" "payload"
|
||||
"\\02\\01\\00" ;; import section
|
||||
"\\00\\0e\\06" "custom" "payload"
|
||||
"\\00\\0e\\06" "custom" "payload"
|
||||
"\\03\\01\\00" ;; function section
|
||||
"\\00\\0e\\06" "custom" "payload"
|
||||
"\\00\\0e\\06" "custom" "payload"
|
||||
"\\04\\01\\00" ;; table section
|
||||
"\\00\\0e\\06" "custom" "payload"
|
||||
"\\00\\0e\\06" "custom" "payload"
|
||||
"\\05\\01\\00" ;; memory section
|
||||
"\\00\\0e\\06" "custom" "payload"
|
||||
"\\00\\0e\\06" "custom" "payload"
|
||||
"\\06\\01\\00" ;; global section
|
||||
"\\00\\0e\\06" "custom" "payload"
|
||||
"\\00\\0e\\06" "custom" "payload"
|
||||
"\\07\\01\\00" ;; export section
|
||||
"\\00\\0e\\06" "custom" "payload"
|
||||
"\\00\\0e\\06" "custom" "payload"
|
||||
"\\09\\01\\00" ;; element section
|
||||
"\\00\\0e\\06" "custom" "payload"
|
||||
"\\00\\0e\\06" "custom" "payload"
|
||||
"\\0a\\01\\00" ;; code section
|
||||
"\\00\\0e\\06" "custom" "payload"
|
||||
"\\00\\0e\\06" "custom" "payload"
|
||||
"\\0b\\01\\00" ;; data section
|
||||
"\\00\\0e\\06" "custom" "payload"
|
||||
"\\00\\0e\\06" "custom" "payload"
|
||||
)`);
|
||||
|
||||
// ./test/core/custom.wast:50
|
||||
let $2 = instantiate(`(module binary
|
||||
"\\00asm" "\\01\\00\\00\\00"
|
||||
"\\01\\07\\01\\60\\02\\7f\\7f\\01\\7f" ;; type section
|
||||
"\\00\\1a\\06" "custom" "this is the payload" ;; custom section
|
||||
"\\03\\02\\01\\00" ;; function section
|
||||
"\\07\\0a\\01\\06\\61\\64\\64\\54\\77\\6f\\00\\00" ;; export section
|
||||
"\\0a\\09\\01\\07\\00\\20\\00\\20\\01\\6a\\0b" ;; code section
|
||||
"\\00\\1b\\07" "custom2" "this is the payload" ;; custom section
|
||||
)`);
|
||||
|
||||
// ./test/core/custom.wast:60
|
||||
assert_malformed(() =>
|
||||
instantiate(`(module binary
|
||||
"\\00asm" "\\01\\00\\00\\00"
|
||||
"\\00"
|
||||
)`), `unexpected end`);
|
||||
|
||||
// ./test/core/custom.wast:68
|
||||
assert_malformed(() =>
|
||||
instantiate(`(module binary
|
||||
"\\00asm" "\\01\\00\\00\\00"
|
||||
"\\00\\00"
|
||||
)`), `unexpected end`);
|
||||
|
||||
// ./test/core/custom.wast:76
|
||||
assert_malformed(() =>
|
||||
instantiate(`(module binary
|
||||
"\\00asm" "\\01\\00\\00\\00"
|
||||
"\\00\\00\\00\\05\\01\\00\\07\\00\\00"
|
||||
)`), `unexpected end`);
|
||||
|
||||
// ./test/core/custom.wast:84
|
||||
assert_malformed(() =>
|
||||
instantiate(`(module binary
|
||||
"\\00asm" "\\01\\00\\00\\00"
|
||||
"\\00\\26\\10" "a custom section" "this is the payload"
|
||||
)`), `unexpected end`);
|
||||
|
||||
// ./test/core/custom.wast:92
|
||||
assert_malformed(() =>
|
||||
instantiate(`(module binary
|
||||
"\\00asm" "\\01\\00\\00\\00"
|
||||
"\\00\\25\\10" "a custom section" "this is the payload"
|
||||
"\\00\\24\\10" "a custom section" "this is the payload"
|
||||
)`), `invalid section id`);
|
||||
|
||||
// ./test/core/custom.wast:101
|
||||
assert_malformed(() =>
|
||||
instantiate(`(module binary
|
||||
"\\00asm" "\\01\\00\\00\\00"
|
||||
"\\01\\07\\01\\60\\02\\7f\\7f\\01\\7f" ;; type section
|
||||
"\\00\\25\\10" "a custom section" "this is the payload" ;; invalid length!
|
||||
"\\03\\02\\01\\00" ;; function section
|
||||
"\\0a\\09\\01\\07\\00\\20\\00\\20\\01\\6a\\0b" ;; code section
|
||||
"\\00\\1b\\07" "custom2" "this is the payload" ;; custom section
|
||||
)`), `function and code section have inconsistent lengths`);
|
||||
|
||||
// ./test/core/custom.wast:114
|
||||
assert_malformed(() =>
|
||||
instantiate(`(module binary
|
||||
"\\00asm\\01\\00\\00\\00"
|
||||
"\\00asm\\01\\00\\00\\00"
|
||||
)`), `length out of bounds`);
|
1
js/src/jit-test/tests/wasm/spec/threads/directives.txt
Normal file
1
js/src/jit-test/tests/wasm/spec/threads/directives.txt
Normal file
@ -0,0 +1 @@
|
||||
|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(); local-include:harness/harness.js; skip-if: !wasmThreadsEnabled()
|
131
js/src/jit-test/tests/wasm/spec/threads/fac.wast.js
Normal file
131
js/src/jit-test/tests/wasm/spec/threads/fac.wast.js
Normal file
@ -0,0 +1,131 @@
|
||||
/* Copyright 2021 Mozilla Foundation
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
// ./test/core/fac.wast
|
||||
|
||||
// ./test/core/fac.wast:1
|
||||
let $0 = instantiate(`(module
|
||||
;; Recursive factorial
|
||||
(func (export "fac-rec") (param i64) (result i64)
|
||||
(if (result i64) (i64.eq (local.get 0) (i64.const 0))
|
||||
(then (i64.const 1))
|
||||
(else
|
||||
(i64.mul (local.get 0) (call 0 (i64.sub (local.get 0) (i64.const 1))))
|
||||
)
|
||||
)
|
||||
)
|
||||
|
||||
;; Recursive factorial named
|
||||
(func $$fac-rec-named (export "fac-rec-named") (param $$n i64) (result i64)
|
||||
(if (result i64) (i64.eq (local.get $$n) (i64.const 0))
|
||||
(then (i64.const 1))
|
||||
(else
|
||||
(i64.mul
|
||||
(local.get $$n)
|
||||
(call $$fac-rec-named (i64.sub (local.get $$n) (i64.const 1)))
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
|
||||
;; Iterative factorial
|
||||
(func (export "fac-iter") (param i64) (result i64)
|
||||
(local i64 i64)
|
||||
(local.set 1 (local.get 0))
|
||||
(local.set 2 (i64.const 1))
|
||||
(block
|
||||
(loop
|
||||
(if
|
||||
(i64.eq (local.get 1) (i64.const 0))
|
||||
(then (br 2))
|
||||
(else
|
||||
(local.set 2 (i64.mul (local.get 1) (local.get 2)))
|
||||
(local.set 1 (i64.sub (local.get 1) (i64.const 1)))
|
||||
)
|
||||
)
|
||||
(br 0)
|
||||
)
|
||||
)
|
||||
(local.get 2)
|
||||
)
|
||||
|
||||
;; Iterative factorial named
|
||||
(func (export "fac-iter-named") (param $$n i64) (result i64)
|
||||
(local $$i i64)
|
||||
(local $$res i64)
|
||||
(local.set $$i (local.get $$n))
|
||||
(local.set $$res (i64.const 1))
|
||||
(block $$done
|
||||
(loop $$loop
|
||||
(if
|
||||
(i64.eq (local.get $$i) (i64.const 0))
|
||||
(then (br $$done))
|
||||
(else
|
||||
(local.set $$res (i64.mul (local.get $$i) (local.get $$res)))
|
||||
(local.set $$i (i64.sub (local.get $$i) (i64.const 1)))
|
||||
)
|
||||
)
|
||||
(br $$loop)
|
||||
)
|
||||
)
|
||||
(local.get $$res)
|
||||
)
|
||||
|
||||
;; Optimized factorial.
|
||||
(func (export "fac-opt") (param i64) (result i64)
|
||||
(local i64)
|
||||
(local.set 1 (i64.const 1))
|
||||
(block
|
||||
(br_if 0 (i64.lt_s (local.get 0) (i64.const 2)))
|
||||
(loop
|
||||
(local.set 1 (i64.mul (local.get 1) (local.get 0)))
|
||||
(local.set 0 (i64.add (local.get 0) (i64.const -1)))
|
||||
(br_if 0 (i64.gt_s (local.get 0) (i64.const 1)))
|
||||
)
|
||||
)
|
||||
(local.get 1)
|
||||
)
|
||||
)`);
|
||||
|
||||
// ./test/core/fac.wast:84
|
||||
assert_return(() => invoke($0, `fac-rec`, [25n]), [
|
||||
value("i64", 7034535277573963776n),
|
||||
]);
|
||||
|
||||
// ./test/core/fac.wast:85
|
||||
assert_return(() => invoke($0, `fac-iter`, [25n]), [
|
||||
value("i64", 7034535277573963776n),
|
||||
]);
|
||||
|
||||
// ./test/core/fac.wast:86
|
||||
assert_return(() => invoke($0, `fac-rec-named`, [25n]), [
|
||||
value("i64", 7034535277573963776n),
|
||||
]);
|
||||
|
||||
// ./test/core/fac.wast:87
|
||||
assert_return(() => invoke($0, `fac-iter-named`, [25n]), [
|
||||
value("i64", 7034535277573963776n),
|
||||
]);
|
||||
|
||||
// ./test/core/fac.wast:88
|
||||
assert_return(() => invoke($0, `fac-opt`, [25n]), [
|
||||
value("i64", 7034535277573963776n),
|
||||
]);
|
||||
|
||||
// ./test/core/fac.wast:89
|
||||
assert_exhaustion(
|
||||
() => invoke($0, `fac-rec`, [1073741824n]),
|
||||
`call stack exhausted`,
|
||||
);
|
388
js/src/jit-test/tests/wasm/spec/threads/float_memory.wast.js
Normal file
388
js/src/jit-test/tests/wasm/spec/threads/float_memory.wast.js
Normal file
@ -0,0 +1,388 @@
|
||||
/* Copyright 2021 Mozilla Foundation
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
// ./test/core/float_memory.wast
|
||||
|
||||
// ./test/core/float_memory.wast:5
|
||||
let $0 = instantiate(`(module
|
||||
(memory (data "\\00\\00\\a0\\7f"))
|
||||
|
||||
(func (export "f32.load") (result f32) (f32.load (i32.const 0)))
|
||||
(func (export "i32.load") (result i32) (i32.load (i32.const 0)))
|
||||
(func (export "f32.store") (f32.store (i32.const 0) (f32.const nan:0x200000)))
|
||||
(func (export "i32.store") (i32.store (i32.const 0) (i32.const 0x7fa00000)))
|
||||
(func (export "reset") (i32.store (i32.const 0) (i32.const 0)))
|
||||
)`);
|
||||
|
||||
// ./test/core/float_memory.wast:15
|
||||
assert_return(() => invoke($0, `i32.load`, []), [value("i32", 2141192192)]);
|
||||
|
||||
// ./test/core/float_memory.wast:16
|
||||
assert_return(() => invoke($0, `f32.load`, []), [
|
||||
bytes("f32", [0x0, 0x0, 0xa0, 0x7f]),
|
||||
]);
|
||||
|
||||
// ./test/core/float_memory.wast:17
|
||||
invoke($0, `reset`, []);
|
||||
|
||||
// ./test/core/float_memory.wast:18
|
||||
assert_return(() => invoke($0, `i32.load`, []), [value("i32", 0)]);
|
||||
|
||||
// ./test/core/float_memory.wast:19
|
||||
assert_return(() => invoke($0, `f32.load`, []), [value("f32", 0)]);
|
||||
|
||||
// ./test/core/float_memory.wast:20
|
||||
invoke($0, `f32.store`, []);
|
||||
|
||||
// ./test/core/float_memory.wast:21
|
||||
assert_return(() => invoke($0, `i32.load`, []), [value("i32", 2141192192)]);
|
||||
|
||||
// ./test/core/float_memory.wast:22
|
||||
assert_return(() => invoke($0, `f32.load`, []), [
|
||||
bytes("f32", [0x0, 0x0, 0xa0, 0x7f]),
|
||||
]);
|
||||
|
||||
// ./test/core/float_memory.wast:23
|
||||
invoke($0, `reset`, []);
|
||||
|
||||
// ./test/core/float_memory.wast:24
|
||||
assert_return(() => invoke($0, `i32.load`, []), [value("i32", 0)]);
|
||||
|
||||
// ./test/core/float_memory.wast:25
|
||||
assert_return(() => invoke($0, `f32.load`, []), [value("f32", 0)]);
|
||||
|
||||
// ./test/core/float_memory.wast:26
|
||||
invoke($0, `i32.store`, []);
|
||||
|
||||
// ./test/core/float_memory.wast:27
|
||||
assert_return(() => invoke($0, `i32.load`, []), [value("i32", 2141192192)]);
|
||||
|
||||
// ./test/core/float_memory.wast:28
|
||||
assert_return(() => invoke($0, `f32.load`, []), [
|
||||
bytes("f32", [0x0, 0x0, 0xa0, 0x7f]),
|
||||
]);
|
||||
|
||||
// ./test/core/float_memory.wast:30
|
||||
let $1 = instantiate(`(module
|
||||
(memory (data "\\00\\00\\00\\00\\00\\00\\f4\\7f"))
|
||||
|
||||
(func (export "f64.load") (result f64) (f64.load (i32.const 0)))
|
||||
(func (export "i64.load") (result i64) (i64.load (i32.const 0)))
|
||||
(func (export "f64.store") (f64.store (i32.const 0) (f64.const nan:0x4000000000000)))
|
||||
(func (export "i64.store") (i64.store (i32.const 0) (i64.const 0x7ff4000000000000)))
|
||||
(func (export "reset") (i64.store (i32.const 0) (i64.const 0)))
|
||||
)`);
|
||||
|
||||
// ./test/core/float_memory.wast:40
|
||||
assert_return(() => invoke($1, `i64.load`, []), [
|
||||
value("i64", 9219994337134247936n),
|
||||
]);
|
||||
|
||||
// ./test/core/float_memory.wast:41
|
||||
assert_return(() => invoke($1, `f64.load`, []), [
|
||||
bytes("f64", [0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xf4, 0x7f]),
|
||||
]);
|
||||
|
||||
// ./test/core/float_memory.wast:42
|
||||
invoke($1, `reset`, []);
|
||||
|
||||
// ./test/core/float_memory.wast:43
|
||||
assert_return(() => invoke($1, `i64.load`, []), [value("i64", 0n)]);
|
||||
|
||||
// ./test/core/float_memory.wast:44
|
||||
assert_return(() => invoke($1, `f64.load`, []), [value("f64", 0)]);
|
||||
|
||||
// ./test/core/float_memory.wast:45
|
||||
invoke($1, `f64.store`, []);
|
||||
|
||||
// ./test/core/float_memory.wast:46
|
||||
assert_return(() => invoke($1, `i64.load`, []), [
|
||||
value("i64", 9219994337134247936n),
|
||||
]);
|
||||
|
||||
// ./test/core/float_memory.wast:47
|
||||
assert_return(() => invoke($1, `f64.load`, []), [
|
||||
bytes("f64", [0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xf4, 0x7f]),
|
||||
]);
|
||||
|
||||
// ./test/core/float_memory.wast:48
|
||||
invoke($1, `reset`, []);
|
||||
|
||||
// ./test/core/float_memory.wast:49
|
||||
assert_return(() => invoke($1, `i64.load`, []), [value("i64", 0n)]);
|
||||
|
||||
// ./test/core/float_memory.wast:50
|
||||
assert_return(() => invoke($1, `f64.load`, []), [value("f64", 0)]);
|
||||
|
||||
// ./test/core/float_memory.wast:51
|
||||
invoke($1, `i64.store`, []);
|
||||
|
||||
// ./test/core/float_memory.wast:52
|
||||
assert_return(() => invoke($1, `i64.load`, []), [
|
||||
value("i64", 9219994337134247936n),
|
||||
]);
|
||||
|
||||
// ./test/core/float_memory.wast:53
|
||||
assert_return(() => invoke($1, `f64.load`, []), [
|
||||
bytes("f64", [0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xf4, 0x7f]),
|
||||
]);
|
||||
|
||||
// ./test/core/float_memory.wast:57
|
||||
let $2 = instantiate(`(module
|
||||
(memory (data "\\00\\00\\00\\a0\\7f"))
|
||||
|
||||
(func (export "f32.load") (result f32) (f32.load (i32.const 1)))
|
||||
(func (export "i32.load") (result i32) (i32.load (i32.const 1)))
|
||||
(func (export "f32.store") (f32.store (i32.const 1) (f32.const nan:0x200000)))
|
||||
(func (export "i32.store") (i32.store (i32.const 1) (i32.const 0x7fa00000)))
|
||||
(func (export "reset") (i32.store (i32.const 1) (i32.const 0)))
|
||||
)`);
|
||||
|
||||
// ./test/core/float_memory.wast:67
|
||||
assert_return(() => invoke($2, `i32.load`, []), [value("i32", 2141192192)]);
|
||||
|
||||
// ./test/core/float_memory.wast:68
|
||||
assert_return(() => invoke($2, `f32.load`, []), [
|
||||
bytes("f32", [0x0, 0x0, 0xa0, 0x7f]),
|
||||
]);
|
||||
|
||||
// ./test/core/float_memory.wast:69
|
||||
invoke($2, `reset`, []);
|
||||
|
||||
// ./test/core/float_memory.wast:70
|
||||
assert_return(() => invoke($2, `i32.load`, []), [value("i32", 0)]);
|
||||
|
||||
// ./test/core/float_memory.wast:71
|
||||
assert_return(() => invoke($2, `f32.load`, []), [value("f32", 0)]);
|
||||
|
||||
// ./test/core/float_memory.wast:72
|
||||
invoke($2, `f32.store`, []);
|
||||
|
||||
// ./test/core/float_memory.wast:73
|
||||
assert_return(() => invoke($2, `i32.load`, []), [value("i32", 2141192192)]);
|
||||
|
||||
// ./test/core/float_memory.wast:74
|
||||
assert_return(() => invoke($2, `f32.load`, []), [
|
||||
bytes("f32", [0x0, 0x0, 0xa0, 0x7f]),
|
||||
]);
|
||||
|
||||
// ./test/core/float_memory.wast:75
|
||||
invoke($2, `reset`, []);
|
||||
|
||||
// ./test/core/float_memory.wast:76
|
||||
assert_return(() => invoke($2, `i32.load`, []), [value("i32", 0)]);
|
||||
|
||||
// ./test/core/float_memory.wast:77
|
||||
assert_return(() => invoke($2, `f32.load`, []), [value("f32", 0)]);
|
||||
|
||||
// ./test/core/float_memory.wast:78
|
||||
invoke($2, `i32.store`, []);
|
||||
|
||||
// ./test/core/float_memory.wast:79
|
||||
assert_return(() => invoke($2, `i32.load`, []), [value("i32", 2141192192)]);
|
||||
|
||||
// ./test/core/float_memory.wast:80
|
||||
assert_return(() => invoke($2, `f32.load`, []), [
|
||||
bytes("f32", [0x0, 0x0, 0xa0, 0x7f]),
|
||||
]);
|
||||
|
||||
// ./test/core/float_memory.wast:82
|
||||
let $3 = instantiate(`(module
|
||||
(memory (data "\\00\\00\\00\\00\\00\\00\\00\\f4\\7f"))
|
||||
|
||||
(func (export "f64.load") (result f64) (f64.load (i32.const 1)))
|
||||
(func (export "i64.load") (result i64) (i64.load (i32.const 1)))
|
||||
(func (export "f64.store") (f64.store (i32.const 1) (f64.const nan:0x4000000000000)))
|
||||
(func (export "i64.store") (i64.store (i32.const 1) (i64.const 0x7ff4000000000000)))
|
||||
(func (export "reset") (i64.store (i32.const 1) (i64.const 0)))
|
||||
)`);
|
||||
|
||||
// ./test/core/float_memory.wast:92
|
||||
assert_return(() => invoke($3, `i64.load`, []), [
|
||||
value("i64", 9219994337134247936n),
|
||||
]);
|
||||
|
||||
// ./test/core/float_memory.wast:93
|
||||
assert_return(() => invoke($3, `f64.load`, []), [
|
||||
bytes("f64", [0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xf4, 0x7f]),
|
||||
]);
|
||||
|
||||
// ./test/core/float_memory.wast:94
|
||||
invoke($3, `reset`, []);
|
||||
|
||||
// ./test/core/float_memory.wast:95
|
||||
assert_return(() => invoke($3, `i64.load`, []), [value("i64", 0n)]);
|
||||
|
||||
// ./test/core/float_memory.wast:96
|
||||
assert_return(() => invoke($3, `f64.load`, []), [value("f64", 0)]);
|
||||
|
||||
// ./test/core/float_memory.wast:97
|
||||
invoke($3, `f64.store`, []);
|
||||
|
||||
// ./test/core/float_memory.wast:98
|
||||
assert_return(() => invoke($3, `i64.load`, []), [
|
||||
value("i64", 9219994337134247936n),
|
||||
]);
|
||||
|
||||
// ./test/core/float_memory.wast:99
|
||||
assert_return(() => invoke($3, `f64.load`, []), [
|
||||
bytes("f64", [0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xf4, 0x7f]),
|
||||
]);
|
||||
|
||||
// ./test/core/float_memory.wast:100
|
||||
invoke($3, `reset`, []);
|
||||
|
||||
// ./test/core/float_memory.wast:101
|
||||
assert_return(() => invoke($3, `i64.load`, []), [value("i64", 0n)]);
|
||||
|
||||
// ./test/core/float_memory.wast:102
|
||||
assert_return(() => invoke($3, `f64.load`, []), [value("f64", 0)]);
|
||||
|
||||
// ./test/core/float_memory.wast:103
|
||||
invoke($3, `i64.store`, []);
|
||||
|
||||
// ./test/core/float_memory.wast:104
|
||||
assert_return(() => invoke($3, `i64.load`, []), [
|
||||
value("i64", 9219994337134247936n),
|
||||
]);
|
||||
|
||||
// ./test/core/float_memory.wast:105
|
||||
assert_return(() => invoke($3, `f64.load`, []), [
|
||||
bytes("f64", [0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xf4, 0x7f]),
|
||||
]);
|
||||
|
||||
// ./test/core/float_memory.wast:109
|
||||
let $4 = instantiate(`(module
|
||||
(memory (data "\\01\\00\\d0\\7f"))
|
||||
|
||||
(func (export "f32.load") (result f32) (f32.load (i32.const 0)))
|
||||
(func (export "i32.load") (result i32) (i32.load (i32.const 0)))
|
||||
(func (export "f32.store") (f32.store (i32.const 0) (f32.const nan:0x500001)))
|
||||
(func (export "i32.store") (i32.store (i32.const 0) (i32.const 0x7fd00001)))
|
||||
(func (export "reset") (i32.store (i32.const 0) (i32.const 0)))
|
||||
)`);
|
||||
|
||||
// ./test/core/float_memory.wast:119
|
||||
assert_return(() => invoke($4, `i32.load`, []), [value("i32", 2144337921)]);
|
||||
|
||||
// ./test/core/float_memory.wast:120
|
||||
assert_return(() => invoke($4, `f32.load`, []), [
|
||||
bytes("f32", [0x1, 0x0, 0xd0, 0x7f]),
|
||||
]);
|
||||
|
||||
// ./test/core/float_memory.wast:121
|
||||
invoke($4, `reset`, []);
|
||||
|
||||
// ./test/core/float_memory.wast:122
|
||||
assert_return(() => invoke($4, `i32.load`, []), [value("i32", 0)]);
|
||||
|
||||
// ./test/core/float_memory.wast:123
|
||||
assert_return(() => invoke($4, `f32.load`, []), [value("f32", 0)]);
|
||||
|
||||
// ./test/core/float_memory.wast:124
|
||||
invoke($4, `f32.store`, []);
|
||||
|
||||
// ./test/core/float_memory.wast:125
|
||||
assert_return(() => invoke($4, `i32.load`, []), [value("i32", 2144337921)]);
|
||||
|
||||
// ./test/core/float_memory.wast:126
|
||||
assert_return(() => invoke($4, `f32.load`, []), [
|
||||
bytes("f32", [0x1, 0x0, 0xd0, 0x7f]),
|
||||
]);
|
||||
|
||||
// ./test/core/float_memory.wast:127
|
||||
invoke($4, `reset`, []);
|
||||
|
||||
// ./test/core/float_memory.wast:128
|
||||
assert_return(() => invoke($4, `i32.load`, []), [value("i32", 0)]);
|
||||
|
||||
// ./test/core/float_memory.wast:129
|
||||
assert_return(() => invoke($4, `f32.load`, []), [value("f32", 0)]);
|
||||
|
||||
// ./test/core/float_memory.wast:130
|
||||
invoke($4, `i32.store`, []);
|
||||
|
||||
// ./test/core/float_memory.wast:131
|
||||
assert_return(() => invoke($4, `i32.load`, []), [value("i32", 2144337921)]);
|
||||
|
||||
// ./test/core/float_memory.wast:132
|
||||
assert_return(() => invoke($4, `f32.load`, []), [
|
||||
bytes("f32", [0x1, 0x0, 0xd0, 0x7f]),
|
||||
]);
|
||||
|
||||
// ./test/core/float_memory.wast:134
|
||||
let $5 = instantiate(`(module
|
||||
(memory (data "\\01\\00\\00\\00\\00\\00\\fc\\7f"))
|
||||
|
||||
(func (export "f64.load") (result f64) (f64.load (i32.const 0)))
|
||||
(func (export "i64.load") (result i64) (i64.load (i32.const 0)))
|
||||
(func (export "f64.store") (f64.store (i32.const 0) (f64.const nan:0xc000000000001)))
|
||||
(func (export "i64.store") (i64.store (i32.const 0) (i64.const 0x7ffc000000000001)))
|
||||
(func (export "reset") (i64.store (i32.const 0) (i64.const 0)))
|
||||
)`);
|
||||
|
||||
// ./test/core/float_memory.wast:144
|
||||
assert_return(() => invoke($5, `i64.load`, []), [
|
||||
value("i64", 9222246136947933185n),
|
||||
]);
|
||||
|
||||
// ./test/core/float_memory.wast:145
|
||||
assert_return(() => invoke($5, `f64.load`, []), [
|
||||
bytes("f64", [0x1, 0x0, 0x0, 0x0, 0x0, 0x0, 0xfc, 0x7f]),
|
||||
]);
|
||||
|
||||
// ./test/core/float_memory.wast:146
|
||||
invoke($5, `reset`, []);
|
||||
|
||||
// ./test/core/float_memory.wast:147
|
||||
assert_return(() => invoke($5, `i64.load`, []), [value("i64", 0n)]);
|
||||
|
||||
// ./test/core/float_memory.wast:148
|
||||
assert_return(() => invoke($5, `f64.load`, []), [value("f64", 0)]);
|
||||
|
||||
// ./test/core/float_memory.wast:149
|
||||
invoke($5, `f64.store`, []);
|
||||
|
||||
// ./test/core/float_memory.wast:150
|
||||
assert_return(() => invoke($5, `i64.load`, []), [
|
||||
value("i64", 9222246136947933185n),
|
||||
]);
|
||||
|
||||
// ./test/core/float_memory.wast:151
|
||||
assert_return(() => invoke($5, `f64.load`, []), [
|
||||
bytes("f64", [0x1, 0x0, 0x0, 0x0, 0x0, 0x0, 0xfc, 0x7f]),
|
||||
]);
|
||||
|
||||
// ./test/core/float_memory.wast:152
|
||||
invoke($5, `reset`, []);
|
||||
|
||||
// ./test/core/float_memory.wast:153
|
||||
assert_return(() => invoke($5, `i64.load`, []), [value("i64", 0n)]);
|
||||
|
||||
// ./test/core/float_memory.wast:154
|
||||
assert_return(() => invoke($5, `f64.load`, []), [value("f64", 0)]);
|
||||
|
||||
// ./test/core/float_memory.wast:155
|
||||
invoke($5, `i64.store`, []);
|
||||
|
||||
// ./test/core/float_memory.wast:156
|
||||
assert_return(() => invoke($5, `i64.load`, []), [
|
||||
value("i64", 9222246136947933185n),
|
||||
]);
|
||||
|
||||
// ./test/core/float_memory.wast:157
|
||||
assert_return(() => invoke($5, `f64.load`, []), [
|
||||
bytes("f64", [0x1, 0x0, 0x0, 0x0, 0x0, 0x0, 0xfc, 0x7f]),
|
||||
]);
|
@ -0,0 +1 @@
|
||||
|jit-test| skip-if: true
|
339
js/src/jit-test/tests/wasm/spec/threads/harness/harness.js
Normal file
339
js/src/jit-test/tests/wasm/spec/threads/harness/harness.js
Normal file
@ -0,0 +1,339 @@
|
||||
"use strict";
|
||||
|
||||
/* Copyright 2021 Mozilla Foundation
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
if (!wasmIsSupported()) {
|
||||
quit();
|
||||
}
|
||||
|
||||
function bytes(type, bytes) {
|
||||
var typedBuffer = new Uint8Array(bytes);
|
||||
return wasmGlobalFromArrayBuffer(type, typedBuffer.buffer);
|
||||
}
|
||||
function value(type, value) {
|
||||
return new WebAssembly.Global({
|
||||
value: type,
|
||||
mutable: false,
|
||||
}, value);
|
||||
}
|
||||
|
||||
function i8x16(elements) {
|
||||
let typedBuffer = new Uint8Array(elements);
|
||||
return wasmGlobalFromArrayBuffer("v128", typedBuffer.buffer);
|
||||
}
|
||||
function i16x8(elements) {
|
||||
let typedBuffer = new Uint16Array(elements);
|
||||
return wasmGlobalFromArrayBuffer("v128", typedBuffer.buffer);
|
||||
}
|
||||
function i32x4(elements) {
|
||||
let typedBuffer = new Uint32Array(elements);
|
||||
return wasmGlobalFromArrayBuffer("v128", typedBuffer.buffer);
|
||||
}
|
||||
function i64x2(elements) {
|
||||
let typedBuffer = new BigUint64Array(elements);
|
||||
return wasmGlobalFromArrayBuffer("v128", typedBuffer.buffer);
|
||||
}
|
||||
function f32x4(elements) {
|
||||
let typedBuffer = new Float32Array(elements);
|
||||
return wasmGlobalFromArrayBuffer("v128", typedBuffer.buffer);
|
||||
}
|
||||
function f64x2(elements) {
|
||||
let typedBuffer = new Float64Array(elements);
|
||||
return wasmGlobalFromArrayBuffer("v128", typedBuffer.buffer);
|
||||
}
|
||||
|
||||
class F32x4Pattern {
|
||||
constructor(x, y, z, w) {
|
||||
this.x = x;
|
||||
this.y = y;
|
||||
this.z = z;
|
||||
this.w = w;
|
||||
}
|
||||
}
|
||||
|
||||
class F64x2Pattern {
|
||||
constructor(x, y) {
|
||||
this.x = x;
|
||||
this.y = y;
|
||||
}
|
||||
}
|
||||
|
||||
let externrefs = {};
|
||||
let externsym = Symbol("externref");
|
||||
function externref(s) {
|
||||
if (!(s in externrefs)) externrefs[s] = { [externsym]: s };
|
||||
return externrefs[s];
|
||||
}
|
||||
function is_externref(x) {
|
||||
return (x !== null && externsym in x) ? 1 : 0;
|
||||
}
|
||||
function is_funcref(x) {
|
||||
return typeof x === "function" ? 1 : 0;
|
||||
}
|
||||
function eq_externref(x, y) {
|
||||
return x === y ? 1 : 0;
|
||||
}
|
||||
function eq_funcref(x, y) {
|
||||
return x === y ? 1 : 0;
|
||||
}
|
||||
|
||||
let spectest = {
|
||||
externref: externref,
|
||||
is_externref: is_externref,
|
||||
is_funcref: is_funcref,
|
||||
eq_externref: eq_externref,
|
||||
eq_funcref: eq_funcref,
|
||||
print: console.log.bind(console),
|
||||
print_i32: console.log.bind(console),
|
||||
print_i32_f32: console.log.bind(console),
|
||||
print_f64_f64: console.log.bind(console),
|
||||
print_f32: console.log.bind(console),
|
||||
print_f64: console.log.bind(console),
|
||||
global_i32: 666,
|
||||
global_i64: 666n,
|
||||
global_f32: 666,
|
||||
global_f64: 666,
|
||||
table: new WebAssembly.Table({
|
||||
initial: 10,
|
||||
maximum: 20,
|
||||
element: "anyfunc",
|
||||
}),
|
||||
memory: new WebAssembly.Memory({ initial: 1, maximum: 2 }),
|
||||
};
|
||||
|
||||
let linkage = {
|
||||
spectest,
|
||||
};
|
||||
|
||||
function getInstance(instanceish) {
|
||||
if (typeof instanceish === "string") {
|
||||
assertEq(
|
||||
instanceish in linkage,
|
||||
true,
|
||||
`'${instanceish}'' must be registered`,
|
||||
);
|
||||
return linkage[instanceish];
|
||||
}
|
||||
return instanceish;
|
||||
}
|
||||
|
||||
function instantiate(source) {
|
||||
let bytecode = wasmTextToBinary(source);
|
||||
let module = new WebAssembly.Module(bytecode);
|
||||
let instance = new WebAssembly.Instance(module, linkage);
|
||||
return instance.exports;
|
||||
}
|
||||
|
||||
function register(instanceish, name) {
|
||||
linkage[name] = getInstance(instanceish);
|
||||
}
|
||||
|
||||
function invoke(instanceish, field, params) {
|
||||
let func = getInstance(instanceish)[field];
|
||||
assertEq(func instanceof Function, true, "expected a function");
|
||||
return wasmLosslessInvoke(func, ...params);
|
||||
}
|
||||
|
||||
function get(instanceish, field) {
|
||||
let global = getInstance(instanceish)[field];
|
||||
assertEq(
|
||||
global instanceof WebAssembly.Global,
|
||||
true,
|
||||
"expected a WebAssembly.Global",
|
||||
);
|
||||
return global;
|
||||
}
|
||||
|
||||
function assert_trap(thunk, message) {
|
||||
try {
|
||||
thunk();
|
||||
assertEq("normal return", "trap");
|
||||
} catch (err) {
|
||||
assertEq(
|
||||
err instanceof WebAssembly.RuntimeError,
|
||||
true,
|
||||
"expected trap",
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
let StackOverflow;
|
||||
try {
|
||||
(function f() {
|
||||
1 + f();
|
||||
})();
|
||||
} catch (e) {
|
||||
StackOverflow = e.constructor;
|
||||
}
|
||||
function assert_exhaustion(thunk, message) {
|
||||
try {
|
||||
thunk();
|
||||
assertEq("normal return", "exhaustion");
|
||||
} catch (err) {
|
||||
assertEq(
|
||||
err instanceof StackOverflow,
|
||||
true,
|
||||
"expected exhaustion",
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
function assert_invalid(thunk, message) {
|
||||
try {
|
||||
thunk();
|
||||
assertEq("valid module", "invalid module");
|
||||
} catch (err) {
|
||||
assertEq(
|
||||
err instanceof WebAssembly.LinkError ||
|
||||
err instanceof WebAssembly.CompileError,
|
||||
true,
|
||||
"expected an invalid module",
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
function assert_unlinkable(thunk, message) {
|
||||
try {
|
||||
thunk();
|
||||
assertEq(true, false, "expected an unlinkable module");
|
||||
} catch (err) {
|
||||
assertEq(
|
||||
err instanceof WebAssembly.LinkError ||
|
||||
err instanceof WebAssembly.CompileError,
|
||||
true,
|
||||
"expected an unlinkable module",
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
function assert_malformed(thunk, message) {
|
||||
try {
|
||||
thunk();
|
||||
assertEq("valid module", "malformed module");
|
||||
} catch (err) {
|
||||
assertEq(
|
||||
err instanceof TypeError ||
|
||||
err instanceof SyntaxError ||
|
||||
err instanceof WebAssembly.CompileError ||
|
||||
err instanceof WebAssembly.LinkError,
|
||||
true,
|
||||
`expected a malformed module`,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
function assert_exception(thunk) {
|
||||
let thrown = false;
|
||||
try {
|
||||
thunk();
|
||||
} catch (err) {
|
||||
thrown = true;
|
||||
}
|
||||
assertEq(thrown, true, "expected an exception to be thrown");
|
||||
}
|
||||
|
||||
function assert_return(thunk, expected) {
|
||||
let results = thunk();
|
||||
|
||||
if (results === undefined) {
|
||||
results = [];
|
||||
} else if (!Array.isArray(results)) {
|
||||
results = [results];
|
||||
}
|
||||
if (!Array.isArray(expected)) {
|
||||
expected = [expected];
|
||||
}
|
||||
|
||||
if (!compareResults(results, expected)) {
|
||||
let got = results.map((x) => formatResult(x)).join(", ");
|
||||
let wanted = expected.map((x) => formatExpected(x)).join(", ");
|
||||
assertEq(
|
||||
`[${got}]`,
|
||||
`[${wanted}]`,
|
||||
);
|
||||
assertEq(true, false, `${got} !== ${wanted}`);
|
||||
}
|
||||
}
|
||||
|
||||
function formatResult(result) {
|
||||
if (typeof (result) === "object") {
|
||||
return wasmGlobalToString(result);
|
||||
} else {
|
||||
return `${result}`;
|
||||
}
|
||||
}
|
||||
|
||||
function formatExpected(expected) {
|
||||
if (
|
||||
expected === `f32_canonical_nan` ||
|
||||
expected === `f32_arithmetic_nan` ||
|
||||
expected === `f64_canonical_nan` ||
|
||||
expected === `f64_arithmetic_nan`
|
||||
) {
|
||||
return expected;
|
||||
} else if (expected instanceof F32x4Pattern) {
|
||||
return `f32x4(${formatExpected(expected.x)}, ${
|
||||
formatExpected(expected.y)
|
||||
}, ${formatExpected(expected.z)}, ${formatExpected(expected.w)})`;
|
||||
} else if (expected instanceof F64x2Pattern) {
|
||||
return `f64x2(${formatExpected(expected.x)}, ${
|
||||
formatExpected(expected.y)
|
||||
})`;
|
||||
} else if (typeof (expected) === "object") {
|
||||
return wasmGlobalToString(expected);
|
||||
} else {
|
||||
throw new Error("unknown expected result");
|
||||
}
|
||||
}
|
||||
|
||||
function compareResults(results, expected) {
|
||||
if (results.length !== expected.length) {
|
||||
return false;
|
||||
}
|
||||
for (let i in results) {
|
||||
if (!compareResult(results[i], expected[i])) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
function compareResult(result, expected) {
|
||||
if (
|
||||
expected === `canonical_nan` ||
|
||||
expected === `arithmetic_nan`
|
||||
) {
|
||||
return wasmGlobalIsNaN(result, expected);
|
||||
} else if (expected instanceof F32x4Pattern) {
|
||||
return compareResult(
|
||||
wasmGlobalExtractLane(result, "f32x4", 0),
|
||||
expected.x,
|
||||
) &&
|
||||
compareResult(wasmGlobalExtractLane(result, "f32x4", 1), expected.y) &&
|
||||
compareResult(wasmGlobalExtractLane(result, "f32x4", 2), expected.z) &&
|
||||
compareResult(wasmGlobalExtractLane(result, "f32x4", 3), expected.w);
|
||||
} else if (expected instanceof F64x2Pattern) {
|
||||
return compareResult(
|
||||
wasmGlobalExtractLane(result, "f64x2", 0),
|
||||
expected.x,
|
||||
) &&
|
||||
compareResult(wasmGlobalExtractLane(result, "f64x2", 1), expected.y);
|
||||
} else if (typeof (expected) === "object") {
|
||||
return wasmGlobalsEqual(result, expected);
|
||||
} else {
|
||||
throw new Error("unknown expected result");
|
||||
}
|
||||
}
|
2061
js/src/jit-test/tests/wasm/spec/threads/i32.wast.js
Normal file
2061
js/src/jit-test/tests/wasm/spec/threads/i32.wast.js
Normal file
File diff suppressed because it is too large
Load Diff
1779
js/src/jit-test/tests/wasm/spec/threads/i64.wast.js
Normal file
1779
js/src/jit-test/tests/wasm/spec/threads/i64.wast.js
Normal file
File diff suppressed because it is too large
Load Diff
1240
js/src/jit-test/tests/wasm/spec/threads/if.wast.js
Normal file
1240
js/src/jit-test/tests/wasm/spec/threads/if.wast.js
Normal file
File diff suppressed because it is too large
Load Diff
337
js/src/jit-test/tests/wasm/spec/threads/local_get.wast.js
Normal file
337
js/src/jit-test/tests/wasm/spec/threads/local_get.wast.js
Normal file
@ -0,0 +1,337 @@
|
||||
/* Copyright 2021 Mozilla Foundation
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
// ./test/core/local_get.wast
|
||||
|
||||
// ./test/core/local_get.wast:3
|
||||
let $0 = instantiate(`(module
|
||||
;; Typing
|
||||
|
||||
(func (export "type-local-i32") (result i32) (local i32) (local.get 0))
|
||||
(func (export "type-local-i64") (result i64) (local i64) (local.get 0))
|
||||
(func (export "type-local-f32") (result f32) (local f32) (local.get 0))
|
||||
(func (export "type-local-f64") (result f64) (local f64) (local.get 0))
|
||||
|
||||
(func (export "type-param-i32") (param i32) (result i32) (local.get 0))
|
||||
(func (export "type-param-i64") (param i64) (result i64) (local.get 0))
|
||||
(func (export "type-param-f32") (param f32) (result f32) (local.get 0))
|
||||
(func (export "type-param-f64") (param f64) (result f64) (local.get 0))
|
||||
|
||||
(func (export "type-mixed") (param i64 f32 f64 i32 i32)
|
||||
(local f32 i64 i64 f64)
|
||||
(drop (i64.eqz (local.get 0)))
|
||||
(drop (f32.neg (local.get 1)))
|
||||
(drop (f64.neg (local.get 2)))
|
||||
(drop (i32.eqz (local.get 3)))
|
||||
(drop (i32.eqz (local.get 4)))
|
||||
(drop (f32.neg (local.get 5)))
|
||||
(drop (i64.eqz (local.get 6)))
|
||||
(drop (i64.eqz (local.get 7)))
|
||||
(drop (f64.neg (local.get 8)))
|
||||
)
|
||||
|
||||
;; Reading
|
||||
|
||||
(func (export "read") (param i64 f32 f64 i32 i32) (result f64)
|
||||
(local f32 i64 i64 f64)
|
||||
(local.set 5 (f32.const 5.5))
|
||||
(local.set 6 (i64.const 6))
|
||||
(local.set 8 (f64.const 8))
|
||||
(f64.add
|
||||
(f64.convert_i64_u (local.get 0))
|
||||
(f64.add
|
||||
(f64.promote_f32 (local.get 1))
|
||||
(f64.add
|
||||
(local.get 2)
|
||||
(f64.add
|
||||
(f64.convert_i32_u (local.get 3))
|
||||
(f64.add
|
||||
(f64.convert_i32_s (local.get 4))
|
||||
(f64.add
|
||||
(f64.promote_f32 (local.get 5))
|
||||
(f64.add
|
||||
(f64.convert_i64_u (local.get 6))
|
||||
(f64.add
|
||||
(f64.convert_i64_u (local.get 7))
|
||||
(local.get 8)
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
|
||||
;; As parameter of control constructs and instructions
|
||||
|
||||
(func (export "as-block-value") (param i32) (result i32)
|
||||
(block (result i32) (local.get 0))
|
||||
)
|
||||
(func (export "as-loop-value") (param i32) (result i32)
|
||||
(loop (result i32) (local.get 0))
|
||||
)
|
||||
(func (export "as-br-value") (param i32) (result i32)
|
||||
(block (result i32) (br 0 (local.get 0)))
|
||||
)
|
||||
(func (export "as-br_if-value") (param i32) (result i32)
|
||||
(block $$l0 (result i32) (br_if $$l0 (local.get 0) (i32.const 1)))
|
||||
)
|
||||
|
||||
(func (export "as-br_if-value-cond") (param i32) (result i32)
|
||||
(block (result i32)
|
||||
(br_if 0 (local.get 0) (local.get 0))
|
||||
)
|
||||
)
|
||||
(func (export "as-br_table-value") (param i32) (result i32)
|
||||
(block
|
||||
(block
|
||||
(block
|
||||
(br_table 0 1 2 (local.get 0))
|
||||
(return (i32.const 0))
|
||||
)
|
||||
(return (i32.const 1))
|
||||
)
|
||||
(return (i32.const 2))
|
||||
)
|
||||
(i32.const 3)
|
||||
)
|
||||
|
||||
(func (export "as-return-value") (param i32) (result i32)
|
||||
(return (local.get 0))
|
||||
)
|
||||
|
||||
(func (export "as-if-then") (param i32) (result i32)
|
||||
(if (result i32) (local.get 0) (then (local.get 0)) (else (i32.const 0)))
|
||||
)
|
||||
(func (export "as-if-else") (param i32) (result i32)
|
||||
(if (result i32) (local.get 0) (then (i32.const 1)) (else (local.get 0)))
|
||||
)
|
||||
)`);
|
||||
|
||||
// ./test/core/local_get.wast:109
|
||||
assert_return(() => invoke($0, `type-local-i32`, []), [value("i32", 0)]);
|
||||
|
||||
// ./test/core/local_get.wast:110
|
||||
assert_return(() => invoke($0, `type-local-i64`, []), [value("i64", 0n)]);
|
||||
|
||||
// ./test/core/local_get.wast:111
|
||||
assert_return(() => invoke($0, `type-local-f32`, []), [value("f32", 0)]);
|
||||
|
||||
// ./test/core/local_get.wast:112
|
||||
assert_return(() => invoke($0, `type-local-f64`, []), [value("f64", 0)]);
|
||||
|
||||
// ./test/core/local_get.wast:114
|
||||
assert_return(() => invoke($0, `type-param-i32`, [2]), [value("i32", 2)]);
|
||||
|
||||
// ./test/core/local_get.wast:115
|
||||
assert_return(() => invoke($0, `type-param-i64`, [3n]), [value("i64", 3n)]);
|
||||
|
||||
// ./test/core/local_get.wast:116
|
||||
assert_return(() => invoke($0, `type-param-f32`, [value("f32", 4.4)]), [
|
||||
value("f32", 4.4),
|
||||
]);
|
||||
|
||||
// ./test/core/local_get.wast:117
|
||||
assert_return(() => invoke($0, `type-param-f64`, [value("f64", 5.5)]), [
|
||||
value("f64", 5.5),
|
||||
]);
|
||||
|
||||
// ./test/core/local_get.wast:119
|
||||
assert_return(() => invoke($0, `as-block-value`, [6]), [value("i32", 6)]);
|
||||
|
||||
// ./test/core/local_get.wast:120
|
||||
assert_return(() => invoke($0, `as-loop-value`, [7]), [value("i32", 7)]);
|
||||
|
||||
// ./test/core/local_get.wast:122
|
||||
assert_return(() => invoke($0, `as-br-value`, [8]), [value("i32", 8)]);
|
||||
|
||||
// ./test/core/local_get.wast:123
|
||||
assert_return(() => invoke($0, `as-br_if-value`, [9]), [value("i32", 9)]);
|
||||
|
||||
// ./test/core/local_get.wast:124
|
||||
assert_return(() => invoke($0, `as-br_if-value-cond`, [10]), [
|
||||
value("i32", 10),
|
||||
]);
|
||||
|
||||
// ./test/core/local_get.wast:125
|
||||
assert_return(() => invoke($0, `as-br_table-value`, [1]), [value("i32", 2)]);
|
||||
|
||||
// ./test/core/local_get.wast:127
|
||||
assert_return(() => invoke($0, `as-return-value`, [0]), [value("i32", 0)]);
|
||||
|
||||
// ./test/core/local_get.wast:129
|
||||
assert_return(() => invoke($0, `as-if-then`, [1]), [value("i32", 1)]);
|
||||
|
||||
// ./test/core/local_get.wast:130
|
||||
assert_return(() => invoke($0, `as-if-else`, [0]), [value("i32", 0)]);
|
||||
|
||||
// ./test/core/local_get.wast:132
|
||||
assert_return(
|
||||
() =>
|
||||
invoke($0, `type-mixed`, [1n, value("f32", 2.2), value("f64", 3.3), 4, 5]),
|
||||
[],
|
||||
);
|
||||
|
||||
// ./test/core/local_get.wast:138
|
||||
assert_return(
|
||||
() => invoke($0, `read`, [1n, value("f32", 2), value("f64", 3.3), 4, 5]),
|
||||
[value("f64", 34.8)],
|
||||
);
|
||||
|
||||
// ./test/core/local_get.wast:148
|
||||
assert_invalid(
|
||||
() =>
|
||||
instantiate(
|
||||
`(module (func $$type-local-num-vs-num (result i64) (local i32) (local.get 0)))`,
|
||||
),
|
||||
`type mismatch`,
|
||||
);
|
||||
|
||||
// ./test/core/local_get.wast:152
|
||||
assert_invalid(
|
||||
() =>
|
||||
instantiate(
|
||||
`(module (func $$type-local-num-vs-num (result i32) (local f32) (i32.eqz (local.get 0))))`,
|
||||
),
|
||||
`type mismatch`,
|
||||
);
|
||||
|
||||
// ./test/core/local_get.wast:156
|
||||
assert_invalid(
|
||||
() =>
|
||||
instantiate(
|
||||
`(module (func $$type-local-num-vs-num (result f64) (local f64 i64) (f64.neg (local.get 1))))`,
|
||||
),
|
||||
`type mismatch`,
|
||||
);
|
||||
|
||||
// ./test/core/local_get.wast:164
|
||||
assert_invalid(
|
||||
() =>
|
||||
instantiate(
|
||||
`(module (func $$type-param-num-vs-num (param i32) (result i64) (local.get 0)))`,
|
||||
),
|
||||
`type mismatch`,
|
||||
);
|
||||
|
||||
// ./test/core/local_get.wast:168
|
||||
assert_invalid(
|
||||
() =>
|
||||
instantiate(
|
||||
`(module (func $$type-param-num-vs-num (param f32) (result i32) (i32.eqz (local.get 0))))`,
|
||||
),
|
||||
`type mismatch`,
|
||||
);
|
||||
|
||||
// ./test/core/local_get.wast:172
|
||||
assert_invalid(
|
||||
() =>
|
||||
instantiate(
|
||||
`(module (func $$type-param-num-vs-num (param f64 i64) (result f64) (f64.neg (local.get 1))))`,
|
||||
),
|
||||
`type mismatch`,
|
||||
);
|
||||
|
||||
// ./test/core/local_get.wast:180
|
||||
assert_invalid(
|
||||
() =>
|
||||
instantiate(
|
||||
`(module (func $$type-empty-vs-i32 (local i32) (local.get 0)))`,
|
||||
),
|
||||
`type mismatch`,
|
||||
);
|
||||
|
||||
// ./test/core/local_get.wast:184
|
||||
assert_invalid(
|
||||
() =>
|
||||
instantiate(
|
||||
`(module (func $$type-empty-vs-i64 (local i64) (local.get 0)))`,
|
||||
),
|
||||
`type mismatch`,
|
||||
);
|
||||
|
||||
// ./test/core/local_get.wast:188
|
||||
assert_invalid(
|
||||
() =>
|
||||
instantiate(
|
||||
`(module (func $$type-empty-vs-f32 (local f32) (local.get 0)))`,
|
||||
),
|
||||
`type mismatch`,
|
||||
);
|
||||
|
||||
// ./test/core/local_get.wast:192
|
||||
assert_invalid(
|
||||
() =>
|
||||
instantiate(
|
||||
`(module (func $$type-empty-vs-f64 (local f64) (local.get 0)))`,
|
||||
),
|
||||
`type mismatch`,
|
||||
);
|
||||
|
||||
// ./test/core/local_get.wast:200
|
||||
assert_invalid(
|
||||
() =>
|
||||
instantiate(
|
||||
`(module (func $$unbound-local (local i32 i64) (local.get 3)))`,
|
||||
),
|
||||
`unknown local`,
|
||||
);
|
||||
|
||||
// ./test/core/local_get.wast:204
|
||||
assert_invalid(
|
||||
() =>
|
||||
instantiate(
|
||||
`(module (func $$large-local (local i32 i64) (local.get 14324343)))`,
|
||||
),
|
||||
`unknown local`,
|
||||
);
|
||||
|
||||
// ./test/core/local_get.wast:209
|
||||
assert_invalid(
|
||||
() =>
|
||||
instantiate(
|
||||
`(module (func $$unbound-param (param i32 i64) (local.get 2)))`,
|
||||
),
|
||||
`unknown local`,
|
||||
);
|
||||
|
||||
// ./test/core/local_get.wast:213
|
||||
assert_invalid(
|
||||
() =>
|
||||
instantiate(
|
||||
`(module (func $$large-param (param i32 i64) (local.get 714324343)))`,
|
||||
),
|
||||
`unknown local`,
|
||||
);
|
||||
|
||||
// ./test/core/local_get.wast:218
|
||||
assert_invalid(
|
||||
() =>
|
||||
instantiate(
|
||||
`(module (func $$unbound-mixed (param i32) (local i32 i64) (local.get 3)))`,
|
||||
),
|
||||
`unknown local`,
|
||||
);
|
||||
|
||||
// ./test/core/local_get.wast:222
|
||||
assert_invalid(
|
||||
() =>
|
||||
instantiate(
|
||||
`(module (func $$large-mixed (param i64) (local i32 i64) (local.get 214324343)))`,
|
||||
),
|
||||
`unknown local`,
|
||||
);
|
857
js/src/jit-test/tests/wasm/spec/threads/local_tee.wast.js
Normal file
857
js/src/jit-test/tests/wasm/spec/threads/local_tee.wast.js
Normal file
@ -0,0 +1,857 @@
|
||||
/* Copyright 2021 Mozilla Foundation
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
// ./test/core/local_tee.wast
|
||||
|
||||
// ./test/core/local_tee.wast:3
|
||||
let $0 = instantiate(`(module
|
||||
;; Typing
|
||||
|
||||
(func (export "type-local-i32") (result i32) (local i32) (local.tee 0 (i32.const 0)))
|
||||
(func (export "type-local-i64") (result i64) (local i64) (local.tee 0 (i64.const 0)))
|
||||
(func (export "type-local-f32") (result f32) (local f32) (local.tee 0 (f32.const 0)))
|
||||
(func (export "type-local-f64") (result f64) (local f64) (local.tee 0 (f64.const 0)))
|
||||
|
||||
(func (export "type-param-i32") (param i32) (result i32) (local.tee 0 (i32.const 10)))
|
||||
(func (export "type-param-i64") (param i64) (result i64) (local.tee 0 (i64.const 11)))
|
||||
(func (export "type-param-f32") (param f32) (result f32) (local.tee 0 (f32.const 11.1)))
|
||||
(func (export "type-param-f64") (param f64) (result f64) (local.tee 0 (f64.const 12.2)))
|
||||
|
||||
(func (export "type-mixed") (param i64 f32 f64 i32 i32) (local f32 i64 i64 f64)
|
||||
(drop (i64.eqz (local.tee 0 (i64.const 0))))
|
||||
(drop (f32.neg (local.tee 1 (f32.const 0))))
|
||||
(drop (f64.neg (local.tee 2 (f64.const 0))))
|
||||
(drop (i32.eqz (local.tee 3 (i32.const 0))))
|
||||
(drop (i32.eqz (local.tee 4 (i32.const 0))))
|
||||
(drop (f32.neg (local.tee 5 (f32.const 0))))
|
||||
(drop (i64.eqz (local.tee 6 (i64.const 0))))
|
||||
(drop (i64.eqz (local.tee 7 (i64.const 0))))
|
||||
(drop (f64.neg (local.tee 8 (f64.const 0))))
|
||||
)
|
||||
|
||||
;; Writing
|
||||
|
||||
(func (export "write") (param i64 f32 f64 i32 i32) (result i64) (local f32 i64 i64 f64)
|
||||
(drop (local.tee 1 (f32.const -0.3)))
|
||||
(drop (local.tee 3 (i32.const 40)))
|
||||
(drop (local.tee 4 (i32.const -7)))
|
||||
(drop (local.tee 5 (f32.const 5.5)))
|
||||
(drop (local.tee 6 (i64.const 6)))
|
||||
(drop (local.tee 8 (f64.const 8)))
|
||||
(i64.trunc_f64_s
|
||||
(f64.add
|
||||
(f64.convert_i64_u (local.get 0))
|
||||
(f64.add
|
||||
(f64.promote_f32 (local.get 1))
|
||||
(f64.add
|
||||
(local.get 2)
|
||||
(f64.add
|
||||
(f64.convert_i32_u (local.get 3))
|
||||
(f64.add
|
||||
(f64.convert_i32_s (local.get 4))
|
||||
(f64.add
|
||||
(f64.promote_f32 (local.get 5))
|
||||
(f64.add
|
||||
(f64.convert_i64_u (local.get 6))
|
||||
(f64.add
|
||||
(f64.convert_i64_u (local.get 7))
|
||||
(local.get 8)
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
|
||||
;; Result
|
||||
|
||||
(func (export "result") (param i64 f32 f64 i32 i32) (result f64)
|
||||
(local f32 i64 i64 f64)
|
||||
(f64.add
|
||||
(f64.convert_i64_u (local.tee 0 (i64.const 1)))
|
||||
(f64.add
|
||||
(f64.promote_f32 (local.tee 1 (f32.const 2)))
|
||||
(f64.add
|
||||
(local.tee 2 (f64.const 3.3))
|
||||
(f64.add
|
||||
(f64.convert_i32_u (local.tee 3 (i32.const 4)))
|
||||
(f64.add
|
||||
(f64.convert_i32_s (local.tee 4 (i32.const 5)))
|
||||
(f64.add
|
||||
(f64.promote_f32 (local.tee 5 (f32.const 5.5)))
|
||||
(f64.add
|
||||
(f64.convert_i64_u (local.tee 6 (i64.const 6)))
|
||||
(f64.add
|
||||
(f64.convert_i64_u (local.tee 7 (i64.const 0)))
|
||||
(local.tee 8 (f64.const 8))
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
|
||||
(func $$dummy)
|
||||
|
||||
(func (export "as-block-first") (param i32) (result i32)
|
||||
(block (result i32) (local.tee 0 (i32.const 1)) (call $$dummy))
|
||||
)
|
||||
(func (export "as-block-mid") (param i32) (result i32)
|
||||
(block (result i32) (call $$dummy) (local.tee 0 (i32.const 1)) (call $$dummy))
|
||||
)
|
||||
(func (export "as-block-last") (param i32) (result i32)
|
||||
(block (result i32) (call $$dummy) (call $$dummy) (local.tee 0 (i32.const 1)))
|
||||
)
|
||||
|
||||
(func (export "as-loop-first") (param i32) (result i32)
|
||||
(loop (result i32) (local.tee 0 (i32.const 3)) (call $$dummy))
|
||||
)
|
||||
(func (export "as-loop-mid") (param i32) (result i32)
|
||||
(loop (result i32) (call $$dummy) (local.tee 0 (i32.const 4)) (call $$dummy))
|
||||
)
|
||||
(func (export "as-loop-last") (param i32) (result i32)
|
||||
(loop (result i32) (call $$dummy) (call $$dummy) (local.tee 0 (i32.const 5)))
|
||||
)
|
||||
|
||||
(func (export "as-br-value") (param i32) (result i32)
|
||||
(block (result i32) (br 0 (local.tee 0 (i32.const 9))))
|
||||
)
|
||||
|
||||
(func (export "as-br_if-cond") (param i32)
|
||||
(block (br_if 0 (local.tee 0 (i32.const 1))))
|
||||
)
|
||||
(func (export "as-br_if-value") (param i32) (result i32)
|
||||
(block (result i32)
|
||||
(drop (br_if 0 (local.tee 0 (i32.const 8)) (i32.const 1))) (i32.const 7)
|
||||
)
|
||||
)
|
||||
(func (export "as-br_if-value-cond") (param i32) (result i32)
|
||||
(block (result i32)
|
||||
(drop (br_if 0 (i32.const 6) (local.tee 0 (i32.const 9)))) (i32.const 7)
|
||||
)
|
||||
)
|
||||
|
||||
(func (export "as-br_table-index") (param i32)
|
||||
(block (br_table 0 0 0 (local.tee 0 (i32.const 0))))
|
||||
)
|
||||
(func (export "as-br_table-value") (param i32) (result i32)
|
||||
(block (result i32)
|
||||
(br_table 0 0 0 (local.tee 0 (i32.const 10)) (i32.const 1)) (i32.const 7)
|
||||
)
|
||||
)
|
||||
(func (export "as-br_table-value-index") (param i32) (result i32)
|
||||
(block (result i32)
|
||||
(br_table 0 0 (i32.const 6) (local.tee 0 (i32.const 11))) (i32.const 7)
|
||||
)
|
||||
)
|
||||
|
||||
(func (export "as-return-value") (param i32) (result i32)
|
||||
(return (local.tee 0 (i32.const 7)))
|
||||
)
|
||||
|
||||
(func (export "as-if-cond") (param i32) (result i32)
|
||||
(if (result i32) (local.tee 0 (i32.const 2))
|
||||
(then (i32.const 0)) (else (i32.const 1))
|
||||
)
|
||||
)
|
||||
(func (export "as-if-then") (param i32) (result i32)
|
||||
(if (result i32) (local.get 0)
|
||||
(then (local.tee 0 (i32.const 3))) (else (local.get 0))
|
||||
)
|
||||
)
|
||||
(func (export "as-if-else") (param i32) (result i32)
|
||||
(if (result i32) (local.get 0)
|
||||
(then (local.get 0)) (else (local.tee 0 (i32.const 4)))
|
||||
)
|
||||
)
|
||||
|
||||
(func (export "as-select-first") (param i32 i32) (result i32)
|
||||
(select (local.tee 0 (i32.const 5)) (local.get 0) (local.get 1))
|
||||
)
|
||||
(func (export "as-select-second") (param i32 i32) (result i32)
|
||||
(select (local.get 0) (local.tee 0 (i32.const 6)) (local.get 1))
|
||||
)
|
||||
(func (export "as-select-cond") (param i32) (result i32)
|
||||
(select (i32.const 0) (i32.const 1) (local.tee 0 (i32.const 7)))
|
||||
)
|
||||
|
||||
(func $$f (param i32 i32 i32) (result i32) (i32.const -1))
|
||||
(func (export "as-call-first") (param i32) (result i32)
|
||||
(call $$f (local.tee 0 (i32.const 12)) (i32.const 2) (i32.const 3))
|
||||
)
|
||||
(func (export "as-call-mid") (param i32) (result i32)
|
||||
(call $$f (i32.const 1) (local.tee 0 (i32.const 13)) (i32.const 3))
|
||||
)
|
||||
(func (export "as-call-last") (param i32) (result i32)
|
||||
(call $$f (i32.const 1) (i32.const 2) (local.tee 0 (i32.const 14)))
|
||||
)
|
||||
|
||||
(type $$sig (func (param i32 i32 i32) (result i32)))
|
||||
(table funcref (elem $$f))
|
||||
(func (export "as-call_indirect-first") (param i32) (result i32)
|
||||
(call_indirect (type $$sig)
|
||||
(local.tee 0 (i32.const 1)) (i32.const 2) (i32.const 3) (i32.const 0)
|
||||
)
|
||||
)
|
||||
(func (export "as-call_indirect-mid") (param i32) (result i32)
|
||||
(call_indirect (type $$sig)
|
||||
(i32.const 1) (local.tee 0 (i32.const 2)) (i32.const 3) (i32.const 0)
|
||||
)
|
||||
)
|
||||
(func (export "as-call_indirect-last") (param i32) (result i32)
|
||||
(call_indirect (type $$sig)
|
||||
(i32.const 1) (i32.const 2) (local.tee 0 (i32.const 3)) (i32.const 0)
|
||||
)
|
||||
)
|
||||
(func (export "as-call_indirect-index") (param i32) (result i32)
|
||||
(call_indirect (type $$sig)
|
||||
(i32.const 1) (i32.const 2) (i32.const 3) (local.tee 0 (i32.const 0))
|
||||
)
|
||||
)
|
||||
|
||||
(func (export "as-local.set-value") (local i32)
|
||||
(local.set 0 (local.tee 0 (i32.const 1)))
|
||||
)
|
||||
(func (export "as-local.tee-value") (param i32) (result i32)
|
||||
(local.tee 0 (local.tee 0 (i32.const 1)))
|
||||
)
|
||||
(global $$g (mut i32) (i32.const 0))
|
||||
(func (export "as-global.set-value") (local i32)
|
||||
(global.set $$g (local.tee 0 (i32.const 1)))
|
||||
)
|
||||
|
||||
(memory 1)
|
||||
(func (export "as-load-address") (param i32) (result i32)
|
||||
(i32.load (local.tee 0 (i32.const 1)))
|
||||
)
|
||||
(func (export "as-loadN-address") (param i32) (result i32)
|
||||
(i32.load8_s (local.tee 0 (i32.const 3)))
|
||||
)
|
||||
|
||||
(func (export "as-store-address") (param i32)
|
||||
(i32.store (local.tee 0 (i32.const 30)) (i32.const 7))
|
||||
)
|
||||
(func (export "as-store-value") (param i32)
|
||||
(i32.store (i32.const 2) (local.tee 0 (i32.const 1)))
|
||||
)
|
||||
|
||||
(func (export "as-storeN-address") (param i32)
|
||||
(i32.store8 (local.tee 0 (i32.const 1)) (i32.const 7))
|
||||
)
|
||||
(func (export "as-storeN-value") (param i32)
|
||||
(i32.store16 (i32.const 2) (local.tee 0 (i32.const 1)))
|
||||
)
|
||||
|
||||
(func (export "as-unary-operand") (param f32) (result f32)
|
||||
(f32.neg (local.tee 0 (f32.const nan:0x0f1e2)))
|
||||
)
|
||||
|
||||
(func (export "as-binary-left") (param i32) (result i32)
|
||||
(i32.add (local.tee 0 (i32.const 3)) (i32.const 10))
|
||||
)
|
||||
(func (export "as-binary-right") (param i32) (result i32)
|
||||
(i32.sub (i32.const 10) (local.tee 0 (i32.const 4)))
|
||||
)
|
||||
|
||||
(func (export "as-test-operand") (param i32) (result i32)
|
||||
(i32.eqz (local.tee 0 (i32.const 0)))
|
||||
)
|
||||
|
||||
(func (export "as-compare-left") (param i32) (result i32)
|
||||
(i32.le_s (local.tee 0 (i32.const 43)) (i32.const 10))
|
||||
)
|
||||
(func (export "as-compare-right") (param i32) (result i32)
|
||||
(i32.ne (i32.const 10) (local.tee 0 (i32.const 42)))
|
||||
)
|
||||
|
||||
(func (export "as-convert-operand") (param i64) (result i32)
|
||||
(i32.wrap_i64 (local.tee 0 (i64.const 41)))
|
||||
)
|
||||
|
||||
(func (export "as-memory.grow-size") (param i32) (result i32)
|
||||
(memory.grow (local.tee 0 (i32.const 40)))
|
||||
)
|
||||
|
||||
)`);
|
||||
|
||||
// ./test/core/local_tee.wast:280
|
||||
assert_return(() => invoke($0, `type-local-i32`, []), [value("i32", 0)]);
|
||||
|
||||
// ./test/core/local_tee.wast:281
|
||||
assert_return(() => invoke($0, `type-local-i64`, []), [value("i64", 0n)]);
|
||||
|
||||
// ./test/core/local_tee.wast:282
|
||||
assert_return(() => invoke($0, `type-local-f32`, []), [value("f32", 0)]);
|
||||
|
||||
// ./test/core/local_tee.wast:283
|
||||
assert_return(() => invoke($0, `type-local-f64`, []), [value("f64", 0)]);
|
||||
|
||||
// ./test/core/local_tee.wast:285
|
||||
assert_return(() => invoke($0, `type-param-i32`, [2]), [value("i32", 10)]);
|
||||
|
||||
// ./test/core/local_tee.wast:286
|
||||
assert_return(() => invoke($0, `type-param-i64`, [3n]), [value("i64", 11n)]);
|
||||
|
||||
// ./test/core/local_tee.wast:287
|
||||
assert_return(() => invoke($0, `type-param-f32`, [value("f32", 4.4)]), [
|
||||
value("f32", 11.1),
|
||||
]);
|
||||
|
||||
// ./test/core/local_tee.wast:288
|
||||
assert_return(() => invoke($0, `type-param-f64`, [value("f64", 5.5)]), [
|
||||
value("f64", 12.2),
|
||||
]);
|
||||
|
||||
// ./test/core/local_tee.wast:290
|
||||
assert_return(() => invoke($0, `as-block-first`, [0]), [value("i32", 1)]);
|
||||
|
||||
// ./test/core/local_tee.wast:291
|
||||
assert_return(() => invoke($0, `as-block-mid`, [0]), [value("i32", 1)]);
|
||||
|
||||
// ./test/core/local_tee.wast:292
|
||||
assert_return(() => invoke($0, `as-block-last`, [0]), [value("i32", 1)]);
|
||||
|
||||
// ./test/core/local_tee.wast:294
|
||||
assert_return(() => invoke($0, `as-loop-first`, [0]), [value("i32", 3)]);
|
||||
|
||||
// ./test/core/local_tee.wast:295
|
||||
assert_return(() => invoke($0, `as-loop-mid`, [0]), [value("i32", 4)]);
|
||||
|
||||
// ./test/core/local_tee.wast:296
|
||||
assert_return(() => invoke($0, `as-loop-last`, [0]), [value("i32", 5)]);
|
||||
|
||||
// ./test/core/local_tee.wast:298
|
||||
assert_return(() => invoke($0, `as-br-value`, [0]), [value("i32", 9)]);
|
||||
|
||||
// ./test/core/local_tee.wast:300
|
||||
assert_return(() => invoke($0, `as-br_if-cond`, [0]), []);
|
||||
|
||||
// ./test/core/local_tee.wast:301
|
||||
assert_return(() => invoke($0, `as-br_if-value`, [0]), [value("i32", 8)]);
|
||||
|
||||
// ./test/core/local_tee.wast:302
|
||||
assert_return(() => invoke($0, `as-br_if-value-cond`, [0]), [value("i32", 6)]);
|
||||
|
||||
// ./test/core/local_tee.wast:304
|
||||
assert_return(() => invoke($0, `as-br_table-index`, [0]), []);
|
||||
|
||||
// ./test/core/local_tee.wast:305
|
||||
assert_return(() => invoke($0, `as-br_table-value`, [0]), [value("i32", 10)]);
|
||||
|
||||
// ./test/core/local_tee.wast:306
|
||||
assert_return(() => invoke($0, `as-br_table-value-index`, [0]), [
|
||||
value("i32", 6),
|
||||
]);
|
||||
|
||||
// ./test/core/local_tee.wast:308
|
||||
assert_return(() => invoke($0, `as-return-value`, [0]), [value("i32", 7)]);
|
||||
|
||||
// ./test/core/local_tee.wast:310
|
||||
assert_return(() => invoke($0, `as-if-cond`, [0]), [value("i32", 0)]);
|
||||
|
||||
// ./test/core/local_tee.wast:311
|
||||
assert_return(() => invoke($0, `as-if-then`, [1]), [value("i32", 3)]);
|
||||
|
||||
// ./test/core/local_tee.wast:312
|
||||
assert_return(() => invoke($0, `as-if-else`, [0]), [value("i32", 4)]);
|
||||
|
||||
// ./test/core/local_tee.wast:314
|
||||
assert_return(() => invoke($0, `as-select-first`, [0, 1]), [value("i32", 5)]);
|
||||
|
||||
// ./test/core/local_tee.wast:315
|
||||
assert_return(() => invoke($0, `as-select-second`, [0, 0]), [value("i32", 6)]);
|
||||
|
||||
// ./test/core/local_tee.wast:316
|
||||
assert_return(() => invoke($0, `as-select-cond`, [0]), [value("i32", 0)]);
|
||||
|
||||
// ./test/core/local_tee.wast:318
|
||||
assert_return(() => invoke($0, `as-call-first`, [0]), [value("i32", -1)]);
|
||||
|
||||
// ./test/core/local_tee.wast:319
|
||||
assert_return(() => invoke($0, `as-call-mid`, [0]), [value("i32", -1)]);
|
||||
|
||||
// ./test/core/local_tee.wast:320
|
||||
assert_return(() => invoke($0, `as-call-last`, [0]), [value("i32", -1)]);
|
||||
|
||||
// ./test/core/local_tee.wast:322
|
||||
assert_return(() => invoke($0, `as-call_indirect-first`, [0]), [
|
||||
value("i32", -1),
|
||||
]);
|
||||
|
||||
// ./test/core/local_tee.wast:323
|
||||
assert_return(() => invoke($0, `as-call_indirect-mid`, [0]), [
|
||||
value("i32", -1),
|
||||
]);
|
||||
|
||||
// ./test/core/local_tee.wast:324
|
||||
assert_return(() => invoke($0, `as-call_indirect-last`, [0]), [
|
||||
value("i32", -1),
|
||||
]);
|
||||
|
||||
// ./test/core/local_tee.wast:325
|
||||
assert_return(() => invoke($0, `as-call_indirect-index`, [0]), [
|
||||
value("i32", -1),
|
||||
]);
|
||||
|
||||
// ./test/core/local_tee.wast:327
|
||||
assert_return(() => invoke($0, `as-local.set-value`, []), []);
|
||||
|
||||
// ./test/core/local_tee.wast:328
|
||||
assert_return(() => invoke($0, `as-local.tee-value`, [0]), [value("i32", 1)]);
|
||||
|
||||
// ./test/core/local_tee.wast:329
|
||||
assert_return(() => invoke($0, `as-global.set-value`, []), []);
|
||||
|
||||
// ./test/core/local_tee.wast:331
|
||||
assert_return(() => invoke($0, `as-load-address`, [0]), [value("i32", 0)]);
|
||||
|
||||
// ./test/core/local_tee.wast:332
|
||||
assert_return(() => invoke($0, `as-loadN-address`, [0]), [value("i32", 0)]);
|
||||
|
||||
// ./test/core/local_tee.wast:333
|
||||
assert_return(() => invoke($0, `as-store-address`, [0]), []);
|
||||
|
||||
// ./test/core/local_tee.wast:334
|
||||
assert_return(() => invoke($0, `as-store-value`, [0]), []);
|
||||
|
||||
// ./test/core/local_tee.wast:335
|
||||
assert_return(() => invoke($0, `as-storeN-address`, [0]), []);
|
||||
|
||||
// ./test/core/local_tee.wast:336
|
||||
assert_return(() => invoke($0, `as-storeN-value`, [0]), []);
|
||||
|
||||
// ./test/core/local_tee.wast:338
|
||||
assert_return(() => invoke($0, `as-unary-operand`, [value("f32", 0)]), [
|
||||
bytes("f32", [0xe2, 0xf1, 0x80, 0xff]),
|
||||
]);
|
||||
|
||||
// ./test/core/local_tee.wast:339
|
||||
assert_return(() => invoke($0, `as-binary-left`, [0]), [value("i32", 13)]);
|
||||
|
||||
// ./test/core/local_tee.wast:340
|
||||
assert_return(() => invoke($0, `as-binary-right`, [0]), [value("i32", 6)]);
|
||||
|
||||
// ./test/core/local_tee.wast:341
|
||||
assert_return(() => invoke($0, `as-test-operand`, [0]), [value("i32", 1)]);
|
||||
|
||||
// ./test/core/local_tee.wast:342
|
||||
assert_return(() => invoke($0, `as-compare-left`, [0]), [value("i32", 0)]);
|
||||
|
||||
// ./test/core/local_tee.wast:343
|
||||
assert_return(() => invoke($0, `as-compare-right`, [0]), [value("i32", 1)]);
|
||||
|
||||
// ./test/core/local_tee.wast:344
|
||||
assert_return(() => invoke($0, `as-convert-operand`, [0n]), [value("i32", 41)]);
|
||||
|
||||
// ./test/core/local_tee.wast:345
|
||||
assert_return(() => invoke($0, `as-memory.grow-size`, [0]), [value("i32", 1)]);
|
||||
|
||||
// ./test/core/local_tee.wast:347
|
||||
assert_return(
|
||||
() =>
|
||||
invoke($0, `type-mixed`, [1n, value("f32", 2.2), value("f64", 3.3), 4, 5]),
|
||||
[],
|
||||
);
|
||||
|
||||
// ./test/core/local_tee.wast:353
|
||||
assert_return(
|
||||
() => invoke($0, `write`, [1n, value("f32", 2), value("f64", 3.3), 4, 5]),
|
||||
[value("i64", 56n)],
|
||||
);
|
||||
|
||||
// ./test/core/local_tee.wast:360
|
||||
assert_return(
|
||||
() =>
|
||||
invoke($0, `result`, [-1n, value("f32", -2), value("f64", -3.3), -4, -5]),
|
||||
[value("f64", 34.8)],
|
||||
);
|
||||
|
||||
// ./test/core/local_tee.wast:370
|
||||
assert_invalid(
|
||||
() =>
|
||||
instantiate(
|
||||
`(module (func $$type-local-num-vs-num (result i64) (local i32) (local.tee 0 (i32.const 0))))`,
|
||||
),
|
||||
`type mismatch`,
|
||||
);
|
||||
|
||||
// ./test/core/local_tee.wast:374
|
||||
assert_invalid(
|
||||
() =>
|
||||
instantiate(
|
||||
`(module (func $$type-local-num-vs-num (local f32) (i32.eqz (local.tee 0 (f32.const 0)))))`,
|
||||
),
|
||||
`type mismatch`,
|
||||
);
|
||||
|
||||
// ./test/core/local_tee.wast:378
|
||||
assert_invalid(
|
||||
() =>
|
||||
instantiate(
|
||||
`(module (func $$type-local-num-vs-num (local f64 i64) (f64.neg (local.tee 1 (i64.const 0)))))`,
|
||||
),
|
||||
`type mismatch`,
|
||||
);
|
||||
|
||||
// ./test/core/local_tee.wast:383
|
||||
assert_invalid(
|
||||
() =>
|
||||
instantiate(
|
||||
`(module (func $$type-local-arg-void-vs-num (local i32) (local.tee 0 (nop))))`,
|
||||
),
|
||||
`type mismatch`,
|
||||
);
|
||||
|
||||
// ./test/core/local_tee.wast:387
|
||||
assert_invalid(
|
||||
() =>
|
||||
instantiate(
|
||||
`(module (func $$type-local-arg-num-vs-num (local i32) (local.tee 0 (f32.const 0))))`,
|
||||
),
|
||||
`type mismatch`,
|
||||
);
|
||||
|
||||
// ./test/core/local_tee.wast:391
|
||||
assert_invalid(
|
||||
() =>
|
||||
instantiate(
|
||||
`(module (func $$type-local-arg-num-vs-num (local f32) (local.tee 0 (f64.const 0))))`,
|
||||
),
|
||||
`type mismatch`,
|
||||
);
|
||||
|
||||
// ./test/core/local_tee.wast:395
|
||||
assert_invalid(
|
||||
() =>
|
||||
instantiate(
|
||||
`(module (func $$type-local-arg-num-vs-num (local f64 i64) (local.tee 1 (f64.const 0))))`,
|
||||
),
|
||||
`type mismatch`,
|
||||
);
|
||||
|
||||
// ./test/core/local_tee.wast:403
|
||||
assert_invalid(
|
||||
() =>
|
||||
instantiate(
|
||||
`(module (func $$type-param-num-vs-num (param i32) (result i64) (local.get 0)))`,
|
||||
),
|
||||
`type mismatch`,
|
||||
);
|
||||
|
||||
// ./test/core/local_tee.wast:407
|
||||
assert_invalid(
|
||||
() =>
|
||||
instantiate(
|
||||
`(module (func $$type-param-num-vs-num (param f32) (i32.eqz (local.get 0))))`,
|
||||
),
|
||||
`type mismatch`,
|
||||
);
|
||||
|
||||
// ./test/core/local_tee.wast:411
|
||||
assert_invalid(
|
||||
() =>
|
||||
instantiate(
|
||||
`(module (func $$type-param-num-vs-num (param f64 i64) (f64.neg (local.get 1))))`,
|
||||
),
|
||||
`type mismatch`,
|
||||
);
|
||||
|
||||
// ./test/core/local_tee.wast:416
|
||||
assert_invalid(
|
||||
() =>
|
||||
instantiate(
|
||||
`(module (func $$type-param-arg-void-vs-num (param i32) (local.tee 0 (nop))))`,
|
||||
),
|
||||
`type mismatch`,
|
||||
);
|
||||
|
||||
// ./test/core/local_tee.wast:420
|
||||
assert_invalid(
|
||||
() =>
|
||||
instantiate(
|
||||
`(module (func $$type-param-arg-num-vs-num (param i32) (local.tee 0 (f32.const 0))))`,
|
||||
),
|
||||
`type mismatch`,
|
||||
);
|
||||
|
||||
// ./test/core/local_tee.wast:424
|
||||
assert_invalid(
|
||||
() =>
|
||||
instantiate(
|
||||
`(module (func $$type-param-arg-num-vs-num (param f32) (local.tee 0 (f64.const 0))))`,
|
||||
),
|
||||
`type mismatch`,
|
||||
);
|
||||
|
||||
// ./test/core/local_tee.wast:428
|
||||
assert_invalid(
|
||||
() =>
|
||||
instantiate(
|
||||
`(module (func $$type-param-arg-num-vs-num (param f64 i64) (local.tee 1 (f64.const 0))))`,
|
||||
),
|
||||
`type mismatch`,
|
||||
);
|
||||
|
||||
// ./test/core/local_tee.wast:433
|
||||
assert_invalid(() =>
|
||||
instantiate(`(module
|
||||
(func $$type-param-arg-empty-vs-num (param i32)
|
||||
(local.tee 0) (drop)
|
||||
)
|
||||
)`), `type mismatch`);
|
||||
|
||||
// ./test/core/local_tee.wast:441
|
||||
assert_invalid(() =>
|
||||
instantiate(`(module
|
||||
(func $$type-param-arg-empty-vs-num-in-block (param i32)
|
||||
(i32.const 0)
|
||||
(block (local.tee 0) (drop))
|
||||
)
|
||||
)`), `type mismatch`);
|
||||
|
||||
// ./test/core/local_tee.wast:450
|
||||
assert_invalid(() =>
|
||||
instantiate(`(module
|
||||
(func $$type-param-arg-empty-vs-num-in-loop (param i32)
|
||||
(i32.const 0)
|
||||
(loop (local.tee 0) (drop))
|
||||
)
|
||||
)`), `type mismatch`);
|
||||
|
||||
// ./test/core/local_tee.wast:459
|
||||
assert_invalid(() =>
|
||||
instantiate(`(module
|
||||
(func $$type-param-arg-empty-vs-num-in-then (param i32)
|
||||
(i32.const 0) (i32.const 0)
|
||||
(if (then (local.tee 0) (drop)))
|
||||
)
|
||||
)`), `type mismatch`);
|
||||
|
||||
// ./test/core/local_tee.wast:468
|
||||
assert_invalid(() =>
|
||||
instantiate(`(module
|
||||
(func $$type-param-arg-empty-vs-num-in-else (param i32)
|
||||
(i32.const 0) (i32.const 0)
|
||||
(if (result i32) (then (i32.const 0)) (else (local.tee 0))) (drop)
|
||||
)
|
||||
)`), `type mismatch`);
|
||||
|
||||
// ./test/core/local_tee.wast:477
|
||||
assert_invalid(() =>
|
||||
instantiate(`(module
|
||||
(func $$type-param-arg-empty-vs-num-in-br (param i32)
|
||||
(i32.const 0)
|
||||
(block (br 0 (local.tee 0)) (drop))
|
||||
)
|
||||
)`), `type mismatch`);
|
||||
|
||||
// ./test/core/local_tee.wast:486
|
||||
assert_invalid(() =>
|
||||
instantiate(`(module
|
||||
(func $$type-param-arg-empty-vs-num-in-br_if (param i32)
|
||||
(i32.const 0)
|
||||
(block (br_if 0 (local.tee 0) (i32.const 1)) (drop))
|
||||
)
|
||||
)`), `type mismatch`);
|
||||
|
||||
// ./test/core/local_tee.wast:495
|
||||
assert_invalid(() =>
|
||||
instantiate(`(module
|
||||
(func $$type-param-arg-empty-vs-num-in-br_table (param i32)
|
||||
(i32.const 0)
|
||||
(block (br_table 0 (local.tee 0)) (drop))
|
||||
)
|
||||
)`), `type mismatch`);
|
||||
|
||||
// ./test/core/local_tee.wast:504
|
||||
assert_invalid(() =>
|
||||
instantiate(`(module
|
||||
(func $$type-param-arg-empty-vs-num-in-return (param i32)
|
||||
(return (local.tee 0)) (drop)
|
||||
)
|
||||
)`), `type mismatch`);
|
||||
|
||||
// ./test/core/local_tee.wast:512
|
||||
assert_invalid(() =>
|
||||
instantiate(`(module
|
||||
(func $$type-param-arg-empty-vs-num-in-select (param i32)
|
||||
(select (local.tee 0) (i32.const 1) (i32.const 2)) (drop)
|
||||
)
|
||||
)`), `type mismatch`);
|
||||
|
||||
// ./test/core/local_tee.wast:520
|
||||
assert_invalid(() =>
|
||||
instantiate(`(module
|
||||
(func $$type-param-arg-empty-vs-num-in-call (param i32)
|
||||
(call 1 (local.tee 0)) (drop)
|
||||
)
|
||||
(func (param i32) (result i32) (local.get 0))
|
||||
)`), `type mismatch`);
|
||||
|
||||
// ./test/core/local_tee.wast:529
|
||||
assert_invalid(() =>
|
||||
instantiate(`(module
|
||||
(func $$f (param i32) (result i32) (local.get 0))
|
||||
(type $$sig (func (param i32) (result i32)))
|
||||
(table funcref (elem $$f))
|
||||
(func $$type-param-arg-empty-vs-num-in-call_indirect (param i32)
|
||||
(block (result i32)
|
||||
(call_indirect (type $$sig)
|
||||
(local.tee 0) (i32.const 0)
|
||||
)
|
||||
(drop)
|
||||
)
|
||||
)
|
||||
)`), `type mismatch`);
|
||||
|
||||
// ./test/core/local_tee.wast:545
|
||||
assert_invalid(() =>
|
||||
instantiate(`(module
|
||||
(func $$type-param-arg-empty-vs-num-in-local.set (param i32)
|
||||
(local.set 0 (local.tee 0)) (local.get 0) (drop)
|
||||
)
|
||||
)`), `type mismatch`);
|
||||
|
||||
// ./test/core/local_tee.wast:553
|
||||
assert_invalid(() =>
|
||||
instantiate(`(module
|
||||
(func $$type-param-arg-empty-vs-num-in-local.tee (param i32)
|
||||
(local.tee 0 (local.tee 0)) (drop)
|
||||
)
|
||||
)`), `type mismatch`);
|
||||
|
||||
// ./test/core/local_tee.wast:561
|
||||
assert_invalid(() =>
|
||||
instantiate(`(module
|
||||
(global $$x (mut i32) (i32.const 0))
|
||||
(func $$type-param-arg-empty-vs-num-in-global.set (param i32)
|
||||
(global.set $$x (local.tee 0)) (global.get $$x) (drop)
|
||||
)
|
||||
)`), `type mismatch`);
|
||||
|
||||
// ./test/core/local_tee.wast:570
|
||||
assert_invalid(() =>
|
||||
instantiate(`(module
|
||||
(memory 0)
|
||||
(func $$type-param-arg-empty-vs-num-in-memory.grow (param i32)
|
||||
(memory.grow (local.tee 0)) (drop)
|
||||
)
|
||||
)`), `type mismatch`);
|
||||
|
||||
// ./test/core/local_tee.wast:579
|
||||
assert_invalid(() =>
|
||||
instantiate(`(module
|
||||
(memory 0)
|
||||
(func $$type-param-arg-empty-vs-num-in-load (param i32)
|
||||
(i32.load (local.tee 0)) (drop)
|
||||
)
|
||||
)`), `type mismatch`);
|
||||
|
||||
// ./test/core/local_tee.wast:588
|
||||
assert_invalid(() =>
|
||||
instantiate(`(module
|
||||
(memory 1)
|
||||
(func $$type-param-arg-empty-vs-num-in-store (param i32)
|
||||
(i32.store (local.tee 0) (i32.const 1))
|
||||
)
|
||||
)`), `type mismatch`);
|
||||
|
||||
// ./test/core/local_tee.wast:601
|
||||
assert_invalid(
|
||||
() =>
|
||||
instantiate(
|
||||
`(module (func $$unbound-local (local i32 i64) (local.get 3)))`,
|
||||
),
|
||||
`unknown local`,
|
||||
);
|
||||
|
||||
// ./test/core/local_tee.wast:605
|
||||
assert_invalid(
|
||||
() =>
|
||||
instantiate(
|
||||
`(module (func $$large-local (local i32 i64) (local.get 14324343)))`,
|
||||
),
|
||||
`unknown local`,
|
||||
);
|
||||
|
||||
// ./test/core/local_tee.wast:610
|
||||
assert_invalid(
|
||||
() =>
|
||||
instantiate(
|
||||
`(module (func $$unbound-param (param i32 i64) (local.get 2)))`,
|
||||
),
|
||||
`unknown local`,
|
||||
);
|
||||
|
||||
// ./test/core/local_tee.wast:614
|
||||
assert_invalid(
|
||||
() =>
|
||||
instantiate(
|
||||
`(module (func $$large-param (local i32 i64) (local.get 714324343)))`,
|
||||
),
|
||||
`unknown local`,
|
||||
);
|
||||
|
||||
// ./test/core/local_tee.wast:619
|
||||
assert_invalid(
|
||||
() =>
|
||||
instantiate(
|
||||
`(module (func $$unbound-mixed (param i32) (local i32 i64) (local.get 3)))`,
|
||||
),
|
||||
`unknown local`,
|
||||
);
|
||||
|
||||
// ./test/core/local_tee.wast:623
|
||||
assert_invalid(
|
||||
() =>
|
||||
instantiate(
|
||||
`(module (func $$large-mixed (param i64) (local i32 i64) (local.get 214324343)))`,
|
||||
),
|
||||
`unknown local`,
|
||||
);
|
||||
|
||||
// ./test/core/local_tee.wast:628
|
||||
assert_invalid(
|
||||
() =>
|
||||
instantiate(
|
||||
`(module (func $$type-mixed-arg-num-vs-num (param f32) (local i32) (local.tee 1 (f32.const 0))))`,
|
||||
),
|
||||
`type mismatch`,
|
||||
);
|
||||
|
||||
// ./test/core/local_tee.wast:632
|
||||
assert_invalid(
|
||||
() =>
|
||||
instantiate(
|
||||
`(module (func $$type-mixed-arg-num-vs-num (param i64 i32) (local f32) (local.tee 1 (f32.const 0))))`,
|
||||
),
|
||||
`type mismatch`,
|
||||
);
|
||||
|
||||
// ./test/core/local_tee.wast:636
|
||||
assert_invalid(
|
||||
() =>
|
||||
instantiate(
|
||||
`(module (func $$type-mixed-arg-num-vs-num (param i64) (local f64 i64) (local.tee 1 (i64.const 0))))`,
|
||||
),
|
||||
`type mismatch`,
|
||||
);
|
665
js/src/jit-test/tests/wasm/spec/threads/loop.wast.js
Normal file
665
js/src/jit-test/tests/wasm/spec/threads/loop.wast.js
Normal file
@ -0,0 +1,665 @@
|
||||
/* Copyright 2021 Mozilla Foundation
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
// ./test/core/loop.wast
|
||||
|
||||
// ./test/core/loop.wast:3
|
||||
let $0 = instantiate(`(module
|
||||
(memory 1)
|
||||
|
||||
(func $$dummy)
|
||||
|
||||
(func (export "empty")
|
||||
(loop)
|
||||
(loop $$l)
|
||||
)
|
||||
|
||||
(func (export "singular") (result i32)
|
||||
(loop (nop))
|
||||
(loop (result i32) (i32.const 7))
|
||||
)
|
||||
|
||||
(func (export "multi") (result i32)
|
||||
(loop (call $$dummy) (call $$dummy) (call $$dummy) (call $$dummy))
|
||||
(loop (result i32) (call $$dummy) (call $$dummy) (call $$dummy) (i32.const 8))
|
||||
)
|
||||
|
||||
(func (export "nested") (result i32)
|
||||
(loop (result i32)
|
||||
(loop (call $$dummy) (block) (nop))
|
||||
(loop (result i32) (call $$dummy) (i32.const 9))
|
||||
)
|
||||
)
|
||||
|
||||
(func (export "deep") (result i32)
|
||||
(loop (result i32) (block (result i32)
|
||||
(loop (result i32) (block (result i32)
|
||||
(loop (result i32) (block (result i32)
|
||||
(loop (result i32) (block (result i32)
|
||||
(loop (result i32) (block (result i32)
|
||||
(loop (result i32) (block (result i32)
|
||||
(loop (result i32) (block (result i32)
|
||||
(loop (result i32) (block (result i32)
|
||||
(loop (result i32) (block (result i32)
|
||||
(loop (result i32) (block (result i32)
|
||||
(loop (result i32) (block (result i32)
|
||||
(loop (result i32) (block (result i32)
|
||||
(loop (result i32) (block (result i32)
|
||||
(loop (result i32) (block (result i32)
|
||||
(loop (result i32) (block (result i32)
|
||||
(loop (result i32) (block (result i32)
|
||||
(loop (result i32) (block (result i32)
|
||||
(loop (result i32) (block (result i32)
|
||||
(loop (result i32) (block (result i32)
|
||||
(loop (result i32) (block (result i32)
|
||||
(call $$dummy) (i32.const 150)
|
||||
))
|
||||
))
|
||||
))
|
||||
))
|
||||
))
|
||||
))
|
||||
))
|
||||
))
|
||||
))
|
||||
))
|
||||
))
|
||||
))
|
||||
))
|
||||
))
|
||||
))
|
||||
))
|
||||
))
|
||||
))
|
||||
))
|
||||
))
|
||||
)
|
||||
|
||||
(func (export "as-select-first") (result i32)
|
||||
(select (loop (result i32) (i32.const 1)) (i32.const 2) (i32.const 3))
|
||||
)
|
||||
(func (export "as-select-mid") (result i32)
|
||||
(select (i32.const 2) (loop (result i32) (i32.const 1)) (i32.const 3))
|
||||
)
|
||||
(func (export "as-select-last") (result i32)
|
||||
(select (i32.const 2) (i32.const 3) (loop (result i32) (i32.const 1)))
|
||||
)
|
||||
|
||||
(func (export "as-if-condition")
|
||||
(loop (result i32) (i32.const 1)) (if (then (call $$dummy)))
|
||||
)
|
||||
(func (export "as-if-then") (result i32)
|
||||
(if (result i32) (i32.const 1) (then (loop (result i32) (i32.const 1))) (else (i32.const 2)))
|
||||
)
|
||||
(func (export "as-if-else") (result i32)
|
||||
(if (result i32) (i32.const 1) (then (i32.const 2)) (else (loop (result i32) (i32.const 1))))
|
||||
)
|
||||
|
||||
(func (export "as-br_if-first") (result i32)
|
||||
(block (result i32) (br_if 0 (loop (result i32) (i32.const 1)) (i32.const 2)))
|
||||
)
|
||||
(func (export "as-br_if-last") (result i32)
|
||||
(block (result i32) (br_if 0 (i32.const 2) (loop (result i32) (i32.const 1))))
|
||||
)
|
||||
|
||||
(func (export "as-br_table-first") (result i32)
|
||||
(block (result i32) (loop (result i32) (i32.const 1)) (i32.const 2) (br_table 0 0))
|
||||
)
|
||||
(func (export "as-br_table-last") (result i32)
|
||||
(block (result i32) (i32.const 2) (loop (result i32) (i32.const 1)) (br_table 0 0))
|
||||
)
|
||||
|
||||
(func $$func (param i32 i32) (result i32) (local.get 0))
|
||||
(type $$check (func (param i32 i32) (result i32)))
|
||||
(table funcref (elem $$func))
|
||||
(func (export "as-call_indirect-first") (result i32)
|
||||
(block (result i32)
|
||||
(call_indirect (type $$check)
|
||||
(loop (result i32) (i32.const 1)) (i32.const 2) (i32.const 0)
|
||||
)
|
||||
)
|
||||
)
|
||||
(func (export "as-call_indirect-mid") (result i32)
|
||||
(block (result i32)
|
||||
(call_indirect (type $$check)
|
||||
(i32.const 2) (loop (result i32) (i32.const 1)) (i32.const 0)
|
||||
)
|
||||
)
|
||||
)
|
||||
(func (export "as-call_indirect-last") (result i32)
|
||||
(block (result i32)
|
||||
(call_indirect (type $$check)
|
||||
(i32.const 1) (i32.const 2) (loop (result i32) (i32.const 0))
|
||||
)
|
||||
)
|
||||
)
|
||||
|
||||
(func (export "as-store-first")
|
||||
(loop (result i32) (i32.const 1)) (i32.const 1) (i32.store)
|
||||
)
|
||||
(func (export "as-store-last")
|
||||
(i32.const 10) (loop (result i32) (i32.const 1)) (i32.store)
|
||||
)
|
||||
|
||||
(func (export "as-memory.grow-value") (result i32)
|
||||
(memory.grow (loop (result i32) (i32.const 1)))
|
||||
)
|
||||
|
||||
(func $$f (param i32) (result i32) (local.get 0))
|
||||
|
||||
(func (export "as-call-value") (result i32)
|
||||
(call $$f (loop (result i32) (i32.const 1)))
|
||||
)
|
||||
(func (export "as-return-value") (result i32)
|
||||
(loop (result i32) (i32.const 1)) (return)
|
||||
)
|
||||
(func (export "as-drop-operand")
|
||||
(drop (loop (result i32) (i32.const 1)))
|
||||
)
|
||||
(func (export "as-br-value") (result i32)
|
||||
(block (result i32) (br 0 (loop (result i32) (i32.const 1))))
|
||||
)
|
||||
(func (export "as-local.set-value") (result i32)
|
||||
(local i32) (local.set 0 (loop (result i32) (i32.const 1))) (local.get 0)
|
||||
)
|
||||
(func (export "as-local.tee-value") (result i32)
|
||||
(local i32) (local.tee 0 (loop (result i32) (i32.const 1)))
|
||||
)
|
||||
(global $$a (mut i32) (i32.const 0))
|
||||
(func (export "as-global.set-value") (result i32)
|
||||
(global.set $$a (loop (result i32) (i32.const 1)))
|
||||
(global.get $$a)
|
||||
)
|
||||
(func (export "as-load-operand") (result i32)
|
||||
(i32.load (loop (result i32) (i32.const 1)))
|
||||
)
|
||||
|
||||
(func (export "as-unary-operand") (result i32)
|
||||
(i32.ctz (loop (result i32) (call $$dummy) (i32.const 13)))
|
||||
)
|
||||
(func (export "as-binary-operand") (result i32)
|
||||
(i32.mul
|
||||
(loop (result i32) (call $$dummy) (i32.const 3))
|
||||
(loop (result i32) (call $$dummy) (i32.const 4))
|
||||
)
|
||||
)
|
||||
(func (export "as-test-operand") (result i32)
|
||||
(i32.eqz (loop (result i32) (call $$dummy) (i32.const 13)))
|
||||
)
|
||||
(func (export "as-compare-operand") (result i32)
|
||||
(f32.gt
|
||||
(loop (result f32) (call $$dummy) (f32.const 3))
|
||||
(loop (result f32) (call $$dummy) (f32.const 3))
|
||||
)
|
||||
)
|
||||
|
||||
(func (export "break-bare") (result i32)
|
||||
(block (loop (br 1) (br 0) (unreachable)))
|
||||
(block (loop (br_if 1 (i32.const 1)) (unreachable)))
|
||||
(block (loop (br_table 1 (i32.const 0)) (unreachable)))
|
||||
(block (loop (br_table 1 1 1 (i32.const 1)) (unreachable)))
|
||||
(i32.const 19)
|
||||
)
|
||||
(func (export "break-value") (result i32)
|
||||
(block (result i32)
|
||||
(loop (result i32) (br 1 (i32.const 18)) (br 0) (i32.const 19))
|
||||
)
|
||||
)
|
||||
(func (export "break-repeated") (result i32)
|
||||
(block (result i32)
|
||||
(loop (result i32)
|
||||
(br 1 (i32.const 18))
|
||||
(br 1 (i32.const 19))
|
||||
(drop (br_if 1 (i32.const 20) (i32.const 0)))
|
||||
(drop (br_if 1 (i32.const 20) (i32.const 1)))
|
||||
(br 1 (i32.const 21))
|
||||
(br_table 1 (i32.const 22) (i32.const 0))
|
||||
(br_table 1 1 1 (i32.const 23) (i32.const 1))
|
||||
(i32.const 21)
|
||||
)
|
||||
)
|
||||
)
|
||||
(func (export "break-inner") (result i32)
|
||||
(local i32)
|
||||
(local.set 0 (i32.const 0))
|
||||
(local.set 0 (i32.add (local.get 0) (block (result i32) (loop (result i32) (block (result i32) (br 2 (i32.const 0x1)))))))
|
||||
(local.set 0 (i32.add (local.get 0) (block (result i32) (loop (result i32) (loop (result i32) (br 2 (i32.const 0x2)))))))
|
||||
(local.set 0 (i32.add (local.get 0) (block (result i32) (loop (result i32) (block (result i32) (loop (result i32) (br 1 (i32.const 0x4))))))))
|
||||
(local.set 0 (i32.add (local.get 0) (block (result i32) (loop (result i32) (i32.ctz (br 1 (i32.const 0x8)))))))
|
||||
(local.set 0 (i32.add (local.get 0) (block (result i32) (loop (result i32) (i32.ctz (loop (result i32) (br 2 (i32.const 0x10))))))))
|
||||
(local.get 0)
|
||||
)
|
||||
(func (export "cont-inner") (result i32)
|
||||
(local i32)
|
||||
(local.set 0 (i32.const 0))
|
||||
(local.set 0 (i32.add (local.get 0) (loop (result i32) (loop (result i32) (br 1)))))
|
||||
(local.set 0 (i32.add (local.get 0) (loop (result i32) (i32.ctz (br 0)))))
|
||||
(local.set 0 (i32.add (local.get 0) (loop (result i32) (i32.ctz (loop (result i32) (br 1))))))
|
||||
(local.get 0)
|
||||
)
|
||||
|
||||
(func $$fx (export "effects") (result i32)
|
||||
(local i32)
|
||||
(block
|
||||
(loop
|
||||
(local.set 0 (i32.const 1))
|
||||
(local.set 0 (i32.mul (local.get 0) (i32.const 3)))
|
||||
(local.set 0 (i32.sub (local.get 0) (i32.const 5)))
|
||||
(local.set 0 (i32.mul (local.get 0) (i32.const 7)))
|
||||
(br 1)
|
||||
(local.set 0 (i32.mul (local.get 0) (i32.const 100)))
|
||||
)
|
||||
)
|
||||
(i32.eq (local.get 0) (i32.const -14))
|
||||
)
|
||||
|
||||
(func (export "while") (param i64) (result i64)
|
||||
(local i64)
|
||||
(local.set 1 (i64.const 1))
|
||||
(block
|
||||
(loop
|
||||
(br_if 1 (i64.eqz (local.get 0)))
|
||||
(local.set 1 (i64.mul (local.get 0) (local.get 1)))
|
||||
(local.set 0 (i64.sub (local.get 0) (i64.const 1)))
|
||||
(br 0)
|
||||
)
|
||||
)
|
||||
(local.get 1)
|
||||
)
|
||||
|
||||
(func (export "for") (param i64) (result i64)
|
||||
(local i64 i64)
|
||||
(local.set 1 (i64.const 1))
|
||||
(local.set 2 (i64.const 2))
|
||||
(block
|
||||
(loop
|
||||
(br_if 1 (i64.gt_u (local.get 2) (local.get 0)))
|
||||
(local.set 1 (i64.mul (local.get 1) (local.get 2)))
|
||||
(local.set 2 (i64.add (local.get 2) (i64.const 1)))
|
||||
(br 0)
|
||||
)
|
||||
)
|
||||
(local.get 1)
|
||||
)
|
||||
|
||||
(func (export "nesting") (param f32 f32) (result f32)
|
||||
(local f32 f32)
|
||||
(block
|
||||
(loop
|
||||
(br_if 1 (f32.eq (local.get 0) (f32.const 0)))
|
||||
(local.set 2 (local.get 1))
|
||||
(block
|
||||
(loop
|
||||
(br_if 1 (f32.eq (local.get 2) (f32.const 0)))
|
||||
(br_if 3 (f32.lt (local.get 2) (f32.const 0)))
|
||||
(local.set 3 (f32.add (local.get 3) (local.get 2)))
|
||||
(local.set 2 (f32.sub (local.get 2) (f32.const 2)))
|
||||
(br 0)
|
||||
)
|
||||
)
|
||||
(local.set 3 (f32.div (local.get 3) (local.get 0)))
|
||||
(local.set 0 (f32.sub (local.get 0) (f32.const 1)))
|
||||
(br 0)
|
||||
)
|
||||
)
|
||||
(local.get 3)
|
||||
)
|
||||
)`);
|
||||
|
||||
// ./test/core/loop.wast:305
|
||||
assert_return(() => invoke($0, `empty`, []), []);
|
||||
|
||||
// ./test/core/loop.wast:306
|
||||
assert_return(() => invoke($0, `singular`, []), [value("i32", 7)]);
|
||||
|
||||
// ./test/core/loop.wast:307
|
||||
assert_return(() => invoke($0, `multi`, []), [value("i32", 8)]);
|
||||
|
||||
// ./test/core/loop.wast:308
|
||||
assert_return(() => invoke($0, `nested`, []), [value("i32", 9)]);
|
||||
|
||||
// ./test/core/loop.wast:309
|
||||
assert_return(() => invoke($0, `deep`, []), [value("i32", 150)]);
|
||||
|
||||
// ./test/core/loop.wast:311
|
||||
assert_return(() => invoke($0, `as-select-first`, []), [value("i32", 1)]);
|
||||
|
||||
// ./test/core/loop.wast:312
|
||||
assert_return(() => invoke($0, `as-select-mid`, []), [value("i32", 2)]);
|
||||
|
||||
// ./test/core/loop.wast:313
|
||||
assert_return(() => invoke($0, `as-select-last`, []), [value("i32", 2)]);
|
||||
|
||||
// ./test/core/loop.wast:315
|
||||
assert_return(() => invoke($0, `as-if-condition`, []), []);
|
||||
|
||||
// ./test/core/loop.wast:316
|
||||
assert_return(() => invoke($0, `as-if-then`, []), [value("i32", 1)]);
|
||||
|
||||
// ./test/core/loop.wast:317
|
||||
assert_return(() => invoke($0, `as-if-else`, []), [value("i32", 2)]);
|
||||
|
||||
// ./test/core/loop.wast:319
|
||||
assert_return(() => invoke($0, `as-br_if-first`, []), [value("i32", 1)]);
|
||||
|
||||
// ./test/core/loop.wast:320
|
||||
assert_return(() => invoke($0, `as-br_if-last`, []), [value("i32", 2)]);
|
||||
|
||||
// ./test/core/loop.wast:322
|
||||
assert_return(() => invoke($0, `as-br_table-first`, []), [value("i32", 1)]);
|
||||
|
||||
// ./test/core/loop.wast:323
|
||||
assert_return(() => invoke($0, `as-br_table-last`, []), [value("i32", 2)]);
|
||||
|
||||
// ./test/core/loop.wast:325
|
||||
assert_return(() => invoke($0, `as-call_indirect-first`, []), [
|
||||
value("i32", 1),
|
||||
]);
|
||||
|
||||
// ./test/core/loop.wast:326
|
||||
assert_return(() => invoke($0, `as-call_indirect-mid`, []), [value("i32", 2)]);
|
||||
|
||||
// ./test/core/loop.wast:327
|
||||
assert_return(() => invoke($0, `as-call_indirect-last`, []), [value("i32", 1)]);
|
||||
|
||||
// ./test/core/loop.wast:329
|
||||
assert_return(() => invoke($0, `as-store-first`, []), []);
|
||||
|
||||
// ./test/core/loop.wast:330
|
||||
assert_return(() => invoke($0, `as-store-last`, []), []);
|
||||
|
||||
// ./test/core/loop.wast:332
|
||||
assert_return(() => invoke($0, `as-memory.grow-value`, []), [value("i32", 1)]);
|
||||
|
||||
// ./test/core/loop.wast:333
|
||||
assert_return(() => invoke($0, `as-call-value`, []), [value("i32", 1)]);
|
||||
|
||||
// ./test/core/loop.wast:334
|
||||
assert_return(() => invoke($0, `as-return-value`, []), [value("i32", 1)]);
|
||||
|
||||
// ./test/core/loop.wast:335
|
||||
assert_return(() => invoke($0, `as-drop-operand`, []), []);
|
||||
|
||||
// ./test/core/loop.wast:336
|
||||
assert_return(() => invoke($0, `as-br-value`, []), [value("i32", 1)]);
|
||||
|
||||
// ./test/core/loop.wast:337
|
||||
assert_return(() => invoke($0, `as-local.set-value`, []), [value("i32", 1)]);
|
||||
|
||||
// ./test/core/loop.wast:338
|
||||
assert_return(() => invoke($0, `as-local.tee-value`, []), [value("i32", 1)]);
|
||||
|
||||
// ./test/core/loop.wast:339
|
||||
assert_return(() => invoke($0, `as-global.set-value`, []), [value("i32", 1)]);
|
||||
|
||||
// ./test/core/loop.wast:340
|
||||
assert_return(() => invoke($0, `as-load-operand`, []), [value("i32", 1)]);
|
||||
|
||||
// ./test/core/loop.wast:342
|
||||
assert_return(() => invoke($0, `as-unary-operand`, []), [value("i32", 0)]);
|
||||
|
||||
// ./test/core/loop.wast:343
|
||||
assert_return(() => invoke($0, `as-binary-operand`, []), [value("i32", 12)]);
|
||||
|
||||
// ./test/core/loop.wast:344
|
||||
assert_return(() => invoke($0, `as-test-operand`, []), [value("i32", 0)]);
|
||||
|
||||
// ./test/core/loop.wast:345
|
||||
assert_return(() => invoke($0, `as-compare-operand`, []), [value("i32", 0)]);
|
||||
|
||||
// ./test/core/loop.wast:347
|
||||
assert_return(() => invoke($0, `break-bare`, []), [value("i32", 19)]);
|
||||
|
||||
// ./test/core/loop.wast:348
|
||||
assert_return(() => invoke($0, `break-value`, []), [value("i32", 18)]);
|
||||
|
||||
// ./test/core/loop.wast:349
|
||||
assert_return(() => invoke($0, `break-repeated`, []), [value("i32", 18)]);
|
||||
|
||||
// ./test/core/loop.wast:350
|
||||
assert_return(() => invoke($0, `break-inner`, []), [value("i32", 31)]);
|
||||
|
||||
// ./test/core/loop.wast:352
|
||||
assert_return(() => invoke($0, `effects`, []), [value("i32", 1)]);
|
||||
|
||||
// ./test/core/loop.wast:354
|
||||
assert_return(() => invoke($0, `while`, [0n]), [value("i64", 1n)]);
|
||||
|
||||
// ./test/core/loop.wast:355
|
||||
assert_return(() => invoke($0, `while`, [1n]), [value("i64", 1n)]);
|
||||
|
||||
// ./test/core/loop.wast:356
|
||||
assert_return(() => invoke($0, `while`, [2n]), [value("i64", 2n)]);
|
||||
|
||||
// ./test/core/loop.wast:357
|
||||
assert_return(() => invoke($0, `while`, [3n]), [value("i64", 6n)]);
|
||||
|
||||
// ./test/core/loop.wast:358
|
||||
assert_return(() => invoke($0, `while`, [5n]), [value("i64", 120n)]);
|
||||
|
||||
// ./test/core/loop.wast:359
|
||||
assert_return(() => invoke($0, `while`, [20n]), [
|
||||
value("i64", 2432902008176640000n),
|
||||
]);
|
||||
|
||||
// ./test/core/loop.wast:361
|
||||
assert_return(() => invoke($0, `for`, [0n]), [value("i64", 1n)]);
|
||||
|
||||
// ./test/core/loop.wast:362
|
||||
assert_return(() => invoke($0, `for`, [1n]), [value("i64", 1n)]);
|
||||
|
||||
// ./test/core/loop.wast:363
|
||||
assert_return(() => invoke($0, `for`, [2n]), [value("i64", 2n)]);
|
||||
|
||||
// ./test/core/loop.wast:364
|
||||
assert_return(() => invoke($0, `for`, [3n]), [value("i64", 6n)]);
|
||||
|
||||
// ./test/core/loop.wast:365
|
||||
assert_return(() => invoke($0, `for`, [5n]), [value("i64", 120n)]);
|
||||
|
||||
// ./test/core/loop.wast:366
|
||||
assert_return(() => invoke($0, `for`, [20n]), [
|
||||
value("i64", 2432902008176640000n),
|
||||
]);
|
||||
|
||||
// ./test/core/loop.wast:368
|
||||
assert_return(() => invoke($0, `nesting`, [value("f32", 0), value("f32", 7)]), [
|
||||
value("f32", 0),
|
||||
]);
|
||||
|
||||
// ./test/core/loop.wast:369
|
||||
assert_return(() => invoke($0, `nesting`, [value("f32", 7), value("f32", 0)]), [
|
||||
value("f32", 0),
|
||||
]);
|
||||
|
||||
// ./test/core/loop.wast:370
|
||||
assert_return(() => invoke($0, `nesting`, [value("f32", 1), value("f32", 1)]), [
|
||||
value("f32", 1),
|
||||
]);
|
||||
|
||||
// ./test/core/loop.wast:371
|
||||
assert_return(() => invoke($0, `nesting`, [value("f32", 1), value("f32", 2)]), [
|
||||
value("f32", 2),
|
||||
]);
|
||||
|
||||
// ./test/core/loop.wast:372
|
||||
assert_return(() => invoke($0, `nesting`, [value("f32", 1), value("f32", 3)]), [
|
||||
value("f32", 4),
|
||||
]);
|
||||
|
||||
// ./test/core/loop.wast:373
|
||||
assert_return(() => invoke($0, `nesting`, [value("f32", 1), value("f32", 4)]), [
|
||||
value("f32", 6),
|
||||
]);
|
||||
|
||||
// ./test/core/loop.wast:374
|
||||
assert_return(
|
||||
() => invoke($0, `nesting`, [value("f32", 1), value("f32", 100)]),
|
||||
[value("f32", 2550)],
|
||||
);
|
||||
|
||||
// ./test/core/loop.wast:375
|
||||
assert_return(
|
||||
() => invoke($0, `nesting`, [value("f32", 1), value("f32", 101)]),
|
||||
[value("f32", 2601)],
|
||||
);
|
||||
|
||||
// ./test/core/loop.wast:376
|
||||
assert_return(() => invoke($0, `nesting`, [value("f32", 2), value("f32", 1)]), [
|
||||
value("f32", 1),
|
||||
]);
|
||||
|
||||
// ./test/core/loop.wast:377
|
||||
assert_return(() => invoke($0, `nesting`, [value("f32", 3), value("f32", 1)]), [
|
||||
value("f32", 1),
|
||||
]);
|
||||
|
||||
// ./test/core/loop.wast:378
|
||||
assert_return(
|
||||
() => invoke($0, `nesting`, [value("f32", 10), value("f32", 1)]),
|
||||
[value("f32", 1)],
|
||||
);
|
||||
|
||||
// ./test/core/loop.wast:379
|
||||
assert_return(() => invoke($0, `nesting`, [value("f32", 2), value("f32", 2)]), [
|
||||
value("f32", 3),
|
||||
]);
|
||||
|
||||
// ./test/core/loop.wast:380
|
||||
assert_return(() => invoke($0, `nesting`, [value("f32", 2), value("f32", 3)]), [
|
||||
value("f32", 4),
|
||||
]);
|
||||
|
||||
// ./test/core/loop.wast:381
|
||||
assert_return(() => invoke($0, `nesting`, [value("f32", 7), value("f32", 4)]), [
|
||||
value("f32", 10.309524),
|
||||
]);
|
||||
|
||||
// ./test/core/loop.wast:382
|
||||
assert_return(
|
||||
() => invoke($0, `nesting`, [value("f32", 7), value("f32", 100)]),
|
||||
[value("f32", 4381.548)],
|
||||
);
|
||||
|
||||
// ./test/core/loop.wast:383
|
||||
assert_return(
|
||||
() => invoke($0, `nesting`, [value("f32", 7), value("f32", 101)]),
|
||||
[value("f32", 2601)],
|
||||
);
|
||||
|
||||
// ./test/core/loop.wast:385
|
||||
assert_invalid(
|
||||
() => instantiate(`(module (func $$type-empty-i32 (result i32) (loop)))`),
|
||||
`type mismatch`,
|
||||
);
|
||||
|
||||
// ./test/core/loop.wast:389
|
||||
assert_invalid(
|
||||
() => instantiate(`(module (func $$type-empty-i64 (result i64) (loop)))`),
|
||||
`type mismatch`,
|
||||
);
|
||||
|
||||
// ./test/core/loop.wast:393
|
||||
assert_invalid(
|
||||
() => instantiate(`(module (func $$type-empty-f32 (result f32) (loop)))`),
|
||||
`type mismatch`,
|
||||
);
|
||||
|
||||
// ./test/core/loop.wast:397
|
||||
assert_invalid(
|
||||
() => instantiate(`(module (func $$type-empty-f64 (result f64) (loop)))`),
|
||||
`type mismatch`,
|
||||
);
|
||||
|
||||
// ./test/core/loop.wast:402
|
||||
assert_invalid(() =>
|
||||
instantiate(`(module (func $$type-value-num-vs-void
|
||||
(loop (i32.const 1))
|
||||
))`), `type mismatch`);
|
||||
|
||||
// ./test/core/loop.wast:408
|
||||
assert_invalid(
|
||||
() =>
|
||||
instantiate(`(module (func $$type-value-empty-vs-num (result i32)
|
||||
(loop (result i32))
|
||||
))`),
|
||||
`type mismatch`,
|
||||
);
|
||||
|
||||
// ./test/core/loop.wast:414
|
||||
assert_invalid(
|
||||
() =>
|
||||
instantiate(`(module (func $$type-value-void-vs-num (result i32)
|
||||
(loop (result i32) (nop))
|
||||
))`),
|
||||
`type mismatch`,
|
||||
);
|
||||
|
||||
// ./test/core/loop.wast:420
|
||||
assert_invalid(
|
||||
() =>
|
||||
instantiate(`(module (func $$type-value-num-vs-num (result i32)
|
||||
(loop (result i32) (f32.const 0))
|
||||
))`),
|
||||
`type mismatch`,
|
||||
);
|
||||
|
||||
// ./test/core/loop.wast:426
|
||||
assert_invalid(
|
||||
() =>
|
||||
instantiate(`(module (func $$type-value-unreached-select (result i32)
|
||||
(loop (result i64) (select (unreachable) (unreachable) (unreachable)))
|
||||
))`),
|
||||
`type mismatch`,
|
||||
);
|
||||
|
||||
// ./test/core/loop.wast:433
|
||||
assert_invalid(() =>
|
||||
instantiate(`(module
|
||||
(func $$type-value-empty-in-block
|
||||
(i32.const 0)
|
||||
(block (loop (result i32)) (drop))
|
||||
)
|
||||
)`), `type mismatch`);
|
||||
|
||||
// ./test/core/loop.wast:442
|
||||
assert_invalid(() =>
|
||||
instantiate(`(module
|
||||
(func $$type-value-empty-in-loop
|
||||
(i32.const 0)
|
||||
(loop (loop (result i32)) (drop))
|
||||
)
|
||||
)`), `type mismatch`);
|
||||
|
||||
// ./test/core/loop.wast:451
|
||||
assert_invalid(() =>
|
||||
instantiate(`(module
|
||||
(func $$type-value-empty-in-then
|
||||
(i32.const 0) (i32.const 0)
|
||||
(if (then (loop (result i32)) (drop)))
|
||||
)
|
||||
)`), `type mismatch`);
|
||||
|
||||
// ./test/core/loop.wast:462
|
||||
assert_malformed(
|
||||
() => instantiate(`(func loop end $$l) `),
|
||||
`mismatching label`,
|
||||
);
|
||||
|
||||
// ./test/core/loop.wast:466
|
||||
assert_malformed(
|
||||
() => instantiate(`(func loop $$a end $$l) `),
|
||||
`mismatching label`,
|
||||
);
|
434
js/src/jit-test/tests/wasm/spec/threads/memory.wast.js
Normal file
434
js/src/jit-test/tests/wasm/spec/threads/memory.wast.js
Normal file
@ -0,0 +1,434 @@
|
||||
/* Copyright 2021 Mozilla Foundation
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
// ./test/core/memory.wast
|
||||
|
||||
// ./test/core/memory.wast:3
|
||||
let $0 = instantiate(`(module (memory 0 0))`);
|
||||
|
||||
// ./test/core/memory.wast:4
|
||||
let $1 = instantiate(`(module (memory 0 1))`);
|
||||
|
||||
// ./test/core/memory.wast:5
|
||||
let $2 = instantiate(`(module (memory 1 256))`);
|
||||
|
||||
// ./test/core/memory.wast:6
|
||||
let $3 = instantiate(`(module (memory 0 65536))`);
|
||||
|
||||
// ./test/core/memory.wast:7
|
||||
let $4 = instantiate(`(module (memory 0 0 shared))`);
|
||||
|
||||
// ./test/core/memory.wast:8
|
||||
let $5 = instantiate(`(module (memory 1 2 shared))`);
|
||||
|
||||
// ./test/core/memory.wast:10
|
||||
assert_invalid(
|
||||
() => instantiate(`(module (memory 1 shared))`),
|
||||
`shared memory must have maximum`,
|
||||
);
|
||||
|
||||
// ./test/core/memory.wast:12
|
||||
assert_invalid(
|
||||
() => instantiate(`(module (memory 0) (memory 0))`),
|
||||
`multiple memories`,
|
||||
);
|
||||
|
||||
// ./test/core/memory.wast:13
|
||||
assert_invalid(
|
||||
() =>
|
||||
instantiate(`(module (memory (import "spectest" "memory") 0) (memory 0))`),
|
||||
`multiple memories`,
|
||||
);
|
||||
|
||||
// ./test/core/memory.wast:15
|
||||
let $6 = instantiate(
|
||||
`(module (memory (data)) (func (export "memsize") (result i32) (memory.size)))`,
|
||||
);
|
||||
|
||||
// ./test/core/memory.wast:16
|
||||
assert_return(() => invoke($6, `memsize`, []), [value("i32", 0)]);
|
||||
|
||||
// ./test/core/memory.wast:17
|
||||
let $7 = instantiate(
|
||||
`(module (memory (data "")) (func (export "memsize") (result i32) (memory.size)))`,
|
||||
);
|
||||
|
||||
// ./test/core/memory.wast:18
|
||||
assert_return(() => invoke($7, `memsize`, []), [value("i32", 0)]);
|
||||
|
||||
// ./test/core/memory.wast:19
|
||||
let $8 = instantiate(
|
||||
`(module (memory (data "x")) (func (export "memsize") (result i32) (memory.size)))`,
|
||||
);
|
||||
|
||||
// ./test/core/memory.wast:20
|
||||
assert_return(() => invoke($8, `memsize`, []), [value("i32", 1)]);
|
||||
|
||||
// ./test/core/memory.wast:22
|
||||
assert_invalid(
|
||||
() => instantiate(`(module (data (i32.const 0)))`),
|
||||
`unknown memory`,
|
||||
);
|
||||
|
||||
// ./test/core/memory.wast:23
|
||||
assert_invalid(
|
||||
() => instantiate(`(module (data (i32.const 0) ""))`),
|
||||
`unknown memory`,
|
||||
);
|
||||
|
||||
// ./test/core/memory.wast:24
|
||||
assert_invalid(
|
||||
() => instantiate(`(module (data (i32.const 0) "x"))`),
|
||||
`unknown memory`,
|
||||
);
|
||||
|
||||
// ./test/core/memory.wast:26
|
||||
assert_invalid(
|
||||
() => instantiate(`(module (func (drop (f32.load (i32.const 0)))))`),
|
||||
`unknown memory`,
|
||||
);
|
||||
|
||||
// ./test/core/memory.wast:30
|
||||
assert_invalid(
|
||||
() => instantiate(`(module (func (f32.store (i32.const 0) (f32.const 0))))`),
|
||||
`unknown memory`,
|
||||
);
|
||||
|
||||
// ./test/core/memory.wast:34
|
||||
assert_invalid(
|
||||
() => instantiate(`(module (func (drop (i32.load8_s (i32.const 0)))))`),
|
||||
`unknown memory`,
|
||||
);
|
||||
|
||||
// ./test/core/memory.wast:38
|
||||
assert_invalid(
|
||||
() => instantiate(`(module (func (i32.store8 (i32.const 0) (i32.const 0))))`),
|
||||
`unknown memory`,
|
||||
);
|
||||
|
||||
// ./test/core/memory.wast:42
|
||||
assert_invalid(
|
||||
() => instantiate(`(module (func (drop (memory.size))))`),
|
||||
`unknown memory`,
|
||||
);
|
||||
|
||||
// ./test/core/memory.wast:46
|
||||
assert_invalid(
|
||||
() => instantiate(`(module (func (drop (memory.grow (i32.const 0)))))`),
|
||||
`unknown memory`,
|
||||
);
|
||||
|
||||
// ./test/core/memory.wast:52
|
||||
assert_invalid(
|
||||
() => instantiate(`(module (memory 1 0))`),
|
||||
`size minimum must not be greater than maximum`,
|
||||
);
|
||||
|
||||
// ./test/core/memory.wast:56
|
||||
assert_invalid(
|
||||
() => instantiate(`(module (memory 65537))`),
|
||||
`memory size must be at most 65536 pages (4GiB)`,
|
||||
);
|
||||
|
||||
// ./test/core/memory.wast:60
|
||||
assert_invalid(
|
||||
() => instantiate(`(module (memory 2147483648))`),
|
||||
`memory size must be at most 65536 pages (4GiB)`,
|
||||
);
|
||||
|
||||
// ./test/core/memory.wast:64
|
||||
assert_invalid(
|
||||
() => instantiate(`(module (memory 4294967295))`),
|
||||
`memory size must be at most 65536 pages (4GiB)`,
|
||||
);
|
||||
|
||||
// ./test/core/memory.wast:68
|
||||
assert_invalid(
|
||||
() => instantiate(`(module (memory 0 65537))`),
|
||||
`memory size must be at most 65536 pages (4GiB)`,
|
||||
);
|
||||
|
||||
// ./test/core/memory.wast:72
|
||||
assert_invalid(
|
||||
() => instantiate(`(module (memory 0 2147483648))`),
|
||||
`memory size must be at most 65536 pages (4GiB)`,
|
||||
);
|
||||
|
||||
// ./test/core/memory.wast:76
|
||||
assert_invalid(
|
||||
() => instantiate(`(module (memory 0 4294967295))`),
|
||||
`memory size must be at most 65536 pages (4GiB)`,
|
||||
);
|
||||
|
||||
// ./test/core/memory.wast:81
|
||||
let $9 = instantiate(`(module
|
||||
(memory 1)
|
||||
(data (i32.const 0) "ABC\\a7D") (data (i32.const 20) "WASM")
|
||||
|
||||
;; Data section
|
||||
(func (export "data") (result i32)
|
||||
(i32.and
|
||||
(i32.and
|
||||
(i32.and
|
||||
(i32.eq (i32.load8_u (i32.const 0)) (i32.const 65))
|
||||
(i32.eq (i32.load8_u (i32.const 3)) (i32.const 167))
|
||||
)
|
||||
(i32.and
|
||||
(i32.eq (i32.load8_u (i32.const 6)) (i32.const 0))
|
||||
(i32.eq (i32.load8_u (i32.const 19)) (i32.const 0))
|
||||
)
|
||||
)
|
||||
(i32.and
|
||||
(i32.and
|
||||
(i32.eq (i32.load8_u (i32.const 20)) (i32.const 87))
|
||||
(i32.eq (i32.load8_u (i32.const 23)) (i32.const 77))
|
||||
)
|
||||
(i32.and
|
||||
(i32.eq (i32.load8_u (i32.const 24)) (i32.const 0))
|
||||
(i32.eq (i32.load8_u (i32.const 1023)) (i32.const 0))
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
|
||||
;; Memory cast
|
||||
(func (export "cast") (result f64)
|
||||
(i64.store (i32.const 8) (i64.const -12345))
|
||||
(if
|
||||
(f64.eq
|
||||
(f64.load (i32.const 8))
|
||||
(f64.reinterpret_i64 (i64.const -12345))
|
||||
)
|
||||
(then (return (f64.const 0)))
|
||||
)
|
||||
(i64.store align=1 (i32.const 9) (i64.const 0))
|
||||
(i32.store16 align=1 (i32.const 15) (i32.const 16453))
|
||||
(f64.load align=1 (i32.const 9))
|
||||
)
|
||||
|
||||
;; Sign and zero extending memory loads
|
||||
(func (export "i32_load8_s") (param $$i i32) (result i32)
|
||||
(i32.store8 (i32.const 8) (local.get $$i))
|
||||
(i32.load8_s (i32.const 8))
|
||||
)
|
||||
(func (export "i32_load8_u") (param $$i i32) (result i32)
|
||||
(i32.store8 (i32.const 8) (local.get $$i))
|
||||
(i32.load8_u (i32.const 8))
|
||||
)
|
||||
(func (export "i32_load16_s") (param $$i i32) (result i32)
|
||||
(i32.store16 (i32.const 8) (local.get $$i))
|
||||
(i32.load16_s (i32.const 8))
|
||||
)
|
||||
(func (export "i32_load16_u") (param $$i i32) (result i32)
|
||||
(i32.store16 (i32.const 8) (local.get $$i))
|
||||
(i32.load16_u (i32.const 8))
|
||||
)
|
||||
(func (export "i64_load8_s") (param $$i i64) (result i64)
|
||||
(i64.store8 (i32.const 8) (local.get $$i))
|
||||
(i64.load8_s (i32.const 8))
|
||||
)
|
||||
(func (export "i64_load8_u") (param $$i i64) (result i64)
|
||||
(i64.store8 (i32.const 8) (local.get $$i))
|
||||
(i64.load8_u (i32.const 8))
|
||||
)
|
||||
(func (export "i64_load16_s") (param $$i i64) (result i64)
|
||||
(i64.store16 (i32.const 8) (local.get $$i))
|
||||
(i64.load16_s (i32.const 8))
|
||||
)
|
||||
(func (export "i64_load16_u") (param $$i i64) (result i64)
|
||||
(i64.store16 (i32.const 8) (local.get $$i))
|
||||
(i64.load16_u (i32.const 8))
|
||||
)
|
||||
(func (export "i64_load32_s") (param $$i i64) (result i64)
|
||||
(i64.store32 (i32.const 8) (local.get $$i))
|
||||
(i64.load32_s (i32.const 8))
|
||||
)
|
||||
(func (export "i64_load32_u") (param $$i i64) (result i64)
|
||||
(i64.store32 (i32.const 8) (local.get $$i))
|
||||
(i64.load32_u (i32.const 8))
|
||||
)
|
||||
)`);
|
||||
|
||||
// ./test/core/memory.wast:169
|
||||
assert_return(() => invoke($9, `data`, []), [value("i32", 1)]);
|
||||
|
||||
// ./test/core/memory.wast:170
|
||||
assert_return(() => invoke($9, `cast`, []), [value("f64", 42)]);
|
||||
|
||||
// ./test/core/memory.wast:172
|
||||
assert_return(() => invoke($9, `i32_load8_s`, [-1]), [value("i32", -1)]);
|
||||
|
||||
// ./test/core/memory.wast:173
|
||||
assert_return(() => invoke($9, `i32_load8_u`, [-1]), [value("i32", 255)]);
|
||||
|
||||
// ./test/core/memory.wast:174
|
||||
assert_return(() => invoke($9, `i32_load16_s`, [-1]), [value("i32", -1)]);
|
||||
|
||||
// ./test/core/memory.wast:175
|
||||
assert_return(() => invoke($9, `i32_load16_u`, [-1]), [value("i32", 65535)]);
|
||||
|
||||
// ./test/core/memory.wast:177
|
||||
assert_return(() => invoke($9, `i32_load8_s`, [100]), [value("i32", 100)]);
|
||||
|
||||
// ./test/core/memory.wast:178
|
||||
assert_return(() => invoke($9, `i32_load8_u`, [200]), [value("i32", 200)]);
|
||||
|
||||
// ./test/core/memory.wast:179
|
||||
assert_return(() => invoke($9, `i32_load16_s`, [20000]), [value("i32", 20000)]);
|
||||
|
||||
// ./test/core/memory.wast:180
|
||||
assert_return(() => invoke($9, `i32_load16_u`, [40000]), [value("i32", 40000)]);
|
||||
|
||||
// ./test/core/memory.wast:182
|
||||
assert_return(() => invoke($9, `i32_load8_s`, [-19110589]), [value("i32", 67)]);
|
||||
|
||||
// ./test/core/memory.wast:183
|
||||
assert_return(() => invoke($9, `i32_load8_s`, [878104047]), [
|
||||
value("i32", -17),
|
||||
]);
|
||||
|
||||
// ./test/core/memory.wast:184
|
||||
assert_return(() => invoke($9, `i32_load8_u`, [-19110589]), [value("i32", 67)]);
|
||||
|
||||
// ./test/core/memory.wast:185
|
||||
assert_return(() => invoke($9, `i32_load8_u`, [878104047]), [
|
||||
value("i32", 239),
|
||||
]);
|
||||
|
||||
// ./test/core/memory.wast:186
|
||||
assert_return(() => invoke($9, `i32_load16_s`, [-19110589]), [
|
||||
value("i32", 25923),
|
||||
]);
|
||||
|
||||
// ./test/core/memory.wast:187
|
||||
assert_return(() => invoke($9, `i32_load16_s`, [878104047]), [
|
||||
value("i32", -12817),
|
||||
]);
|
||||
|
||||
// ./test/core/memory.wast:188
|
||||
assert_return(() => invoke($9, `i32_load16_u`, [-19110589]), [
|
||||
value("i32", 25923),
|
||||
]);
|
||||
|
||||
// ./test/core/memory.wast:189
|
||||
assert_return(() => invoke($9, `i32_load16_u`, [878104047]), [
|
||||
value("i32", 52719),
|
||||
]);
|
||||
|
||||
// ./test/core/memory.wast:191
|
||||
assert_return(() => invoke($9, `i64_load8_s`, [-1n]), [value("i64", -1n)]);
|
||||
|
||||
// ./test/core/memory.wast:192
|
||||
assert_return(() => invoke($9, `i64_load8_u`, [-1n]), [value("i64", 255n)]);
|
||||
|
||||
// ./test/core/memory.wast:193
|
||||
assert_return(() => invoke($9, `i64_load16_s`, [-1n]), [value("i64", -1n)]);
|
||||
|
||||
// ./test/core/memory.wast:194
|
||||
assert_return(() => invoke($9, `i64_load16_u`, [-1n]), [value("i64", 65535n)]);
|
||||
|
||||
// ./test/core/memory.wast:195
|
||||
assert_return(() => invoke($9, `i64_load32_s`, [-1n]), [value("i64", -1n)]);
|
||||
|
||||
// ./test/core/memory.wast:196
|
||||
assert_return(() => invoke($9, `i64_load32_u`, [-1n]), [
|
||||
value("i64", 4294967295n),
|
||||
]);
|
||||
|
||||
// ./test/core/memory.wast:198
|
||||
assert_return(() => invoke($9, `i64_load8_s`, [100n]), [value("i64", 100n)]);
|
||||
|
||||
// ./test/core/memory.wast:199
|
||||
assert_return(() => invoke($9, `i64_load8_u`, [200n]), [value("i64", 200n)]);
|
||||
|
||||
// ./test/core/memory.wast:200
|
||||
assert_return(() => invoke($9, `i64_load16_s`, [20000n]), [
|
||||
value("i64", 20000n),
|
||||
]);
|
||||
|
||||
// ./test/core/memory.wast:201
|
||||
assert_return(() => invoke($9, `i64_load16_u`, [40000n]), [
|
||||
value("i64", 40000n),
|
||||
]);
|
||||
|
||||
// ./test/core/memory.wast:202
|
||||
assert_return(() => invoke($9, `i64_load32_s`, [20000n]), [
|
||||
value("i64", 20000n),
|
||||
]);
|
||||
|
||||
// ./test/core/memory.wast:203
|
||||
assert_return(() => invoke($9, `i64_load32_u`, [40000n]), [
|
||||
value("i64", 40000n),
|
||||
]);
|
||||
|
||||
// ./test/core/memory.wast:205
|
||||
assert_return(() => invoke($9, `i64_load8_s`, [-81985529755441853n]), [
|
||||
value("i64", 67n),
|
||||
]);
|
||||
|
||||
// ./test/core/memory.wast:206
|
||||
assert_return(() => invoke($9, `i64_load8_s`, [3771275841602506223n]), [
|
||||
value("i64", -17n),
|
||||
]);
|
||||
|
||||
// ./test/core/memory.wast:207
|
||||
assert_return(() => invoke($9, `i64_load8_u`, [-81985529755441853n]), [
|
||||
value("i64", 67n),
|
||||
]);
|
||||
|
||||
// ./test/core/memory.wast:208
|
||||
assert_return(() => invoke($9, `i64_load8_u`, [3771275841602506223n]), [
|
||||
value("i64", 239n),
|
||||
]);
|
||||
|
||||
// ./test/core/memory.wast:209
|
||||
assert_return(() => invoke($9, `i64_load16_s`, [-81985529755441853n]), [
|
||||
value("i64", 25923n),
|
||||
]);
|
||||
|
||||
// ./test/core/memory.wast:210
|
||||
assert_return(() => invoke($9, `i64_load16_s`, [3771275841602506223n]), [
|
||||
value("i64", -12817n),
|
||||
]);
|
||||
|
||||
// ./test/core/memory.wast:211
|
||||
assert_return(() => invoke($9, `i64_load16_u`, [-81985529755441853n]), [
|
||||
value("i64", 25923n),
|
||||
]);
|
||||
|
||||
// ./test/core/memory.wast:212
|
||||
assert_return(() => invoke($9, `i64_load16_u`, [3771275841602506223n]), [
|
||||
value("i64", 52719n),
|
||||
]);
|
||||
|
||||
// ./test/core/memory.wast:213
|
||||
assert_return(() => invoke($9, `i64_load32_s`, [-81985529755441853n]), [
|
||||
value("i64", 1446274371n),
|
||||
]);
|
||||
|
||||
// ./test/core/memory.wast:214
|
||||
assert_return(() => invoke($9, `i64_load32_s`, [3771275841602506223n]), [
|
||||
value("i64", -1732588049n),
|
||||
]);
|
||||
|
||||
// ./test/core/memory.wast:215
|
||||
assert_return(() => invoke($9, `i64_load32_u`, [-81985529755441853n]), [
|
||||
value("i64", 1446274371n),
|
||||
]);
|
||||
|
||||
// ./test/core/memory.wast:216
|
||||
assert_return(() => invoke($9, `i64_load32_u`, [3771275841602506223n]), [
|
||||
value("i64", 2562379247n),
|
||||
]);
|
562
js/src/jit-test/tests/wasm/spec/threads/memory_grow.wast.js
Normal file
562
js/src/jit-test/tests/wasm/spec/threads/memory_grow.wast.js
Normal file
@ -0,0 +1,562 @@
|
||||
/* Copyright 2021 Mozilla Foundation
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
// ./test/core/memory_grow.wast
|
||||
|
||||
// ./test/core/memory_grow.wast:1
|
||||
let $0 = instantiate(`(module
|
||||
(memory 0)
|
||||
|
||||
(func (export "load_at_zero") (result i32) (i32.load (i32.const 0)))
|
||||
(func (export "store_at_zero") (i32.store (i32.const 0) (i32.const 2)))
|
||||
|
||||
(func (export "load_at_page_size") (result i32) (i32.load (i32.const 0x10000)))
|
||||
(func (export "store_at_page_size") (i32.store (i32.const 0x10000) (i32.const 3)))
|
||||
|
||||
(func (export "grow") (param $$sz i32) (result i32) (memory.grow (local.get $$sz)))
|
||||
(func (export "size") (result i32) (memory.size))
|
||||
)`);
|
||||
|
||||
// ./test/core/memory_grow.wast:14
|
||||
assert_return(() => invoke($0, `size`, []), [value("i32", 0)]);
|
||||
|
||||
// ./test/core/memory_grow.wast:15
|
||||
assert_trap(
|
||||
() => invoke($0, `store_at_zero`, []),
|
||||
`out of bounds memory access`,
|
||||
);
|
||||
|
||||
// ./test/core/memory_grow.wast:16
|
||||
assert_trap(
|
||||
() => invoke($0, `load_at_zero`, []),
|
||||
`out of bounds memory access`,
|
||||
);
|
||||
|
||||
// ./test/core/memory_grow.wast:17
|
||||
assert_trap(
|
||||
() => invoke($0, `store_at_page_size`, []),
|
||||
`out of bounds memory access`,
|
||||
);
|
||||
|
||||
// ./test/core/memory_grow.wast:18
|
||||
assert_trap(
|
||||
() => invoke($0, `load_at_page_size`, []),
|
||||
`out of bounds memory access`,
|
||||
);
|
||||
|
||||
// ./test/core/memory_grow.wast:19
|
||||
assert_return(() => invoke($0, `grow`, [1]), [value("i32", 0)]);
|
||||
|
||||
// ./test/core/memory_grow.wast:20
|
||||
assert_return(() => invoke($0, `size`, []), [value("i32", 1)]);
|
||||
|
||||
// ./test/core/memory_grow.wast:21
|
||||
assert_return(() => invoke($0, `load_at_zero`, []), [value("i32", 0)]);
|
||||
|
||||
// ./test/core/memory_grow.wast:22
|
||||
assert_return(() => invoke($0, `store_at_zero`, []), []);
|
||||
|
||||
// ./test/core/memory_grow.wast:23
|
||||
assert_return(() => invoke($0, `load_at_zero`, []), [value("i32", 2)]);
|
||||
|
||||
// ./test/core/memory_grow.wast:24
|
||||
assert_trap(
|
||||
() => invoke($0, `store_at_page_size`, []),
|
||||
`out of bounds memory access`,
|
||||
);
|
||||
|
||||
// ./test/core/memory_grow.wast:25
|
||||
assert_trap(
|
||||
() => invoke($0, `load_at_page_size`, []),
|
||||
`out of bounds memory access`,
|
||||
);
|
||||
|
||||
// ./test/core/memory_grow.wast:26
|
||||
assert_return(() => invoke($0, `grow`, [4]), [value("i32", 1)]);
|
||||
|
||||
// ./test/core/memory_grow.wast:27
|
||||
assert_return(() => invoke($0, `size`, []), [value("i32", 5)]);
|
||||
|
||||
// ./test/core/memory_grow.wast:28
|
||||
assert_return(() => invoke($0, `load_at_zero`, []), [value("i32", 2)]);
|
||||
|
||||
// ./test/core/memory_grow.wast:29
|
||||
assert_return(() => invoke($0, `store_at_zero`, []), []);
|
||||
|
||||
// ./test/core/memory_grow.wast:30
|
||||
assert_return(() => invoke($0, `load_at_zero`, []), [value("i32", 2)]);
|
||||
|
||||
// ./test/core/memory_grow.wast:31
|
||||
assert_return(() => invoke($0, `load_at_page_size`, []), [value("i32", 0)]);
|
||||
|
||||
// ./test/core/memory_grow.wast:32
|
||||
assert_return(() => invoke($0, `store_at_page_size`, []), []);
|
||||
|
||||
// ./test/core/memory_grow.wast:33
|
||||
assert_return(() => invoke($0, `load_at_page_size`, []), [value("i32", 3)]);
|
||||
|
||||
// ./test/core/memory_grow.wast:36
|
||||
let $1 = instantiate(`(module
|
||||
(memory 0)
|
||||
(func (export "grow") (param i32) (result i32) (memory.grow (local.get 0)))
|
||||
)`);
|
||||
|
||||
// ./test/core/memory_grow.wast:41
|
||||
assert_return(() => invoke($1, `grow`, [0]), [value("i32", 0)]);
|
||||
|
||||
// ./test/core/memory_grow.wast:42
|
||||
assert_return(() => invoke($1, `grow`, [1]), [value("i32", 0)]);
|
||||
|
||||
// ./test/core/memory_grow.wast:43
|
||||
assert_return(() => invoke($1, `grow`, [0]), [value("i32", 1)]);
|
||||
|
||||
// ./test/core/memory_grow.wast:44
|
||||
assert_return(() => invoke($1, `grow`, [2]), [value("i32", 1)]);
|
||||
|
||||
// ./test/core/memory_grow.wast:45
|
||||
assert_return(() => invoke($1, `grow`, [800]), [value("i32", 3)]);
|
||||
|
||||
// ./test/core/memory_grow.wast:46
|
||||
assert_return(() => invoke($1, `grow`, [65536]), [value("i32", -1)]);
|
||||
|
||||
// ./test/core/memory_grow.wast:47
|
||||
assert_return(() => invoke($1, `grow`, [64736]), [value("i32", -1)]);
|
||||
|
||||
// ./test/core/memory_grow.wast:48
|
||||
assert_return(() => invoke($1, `grow`, [1]), [value("i32", 803)]);
|
||||
|
||||
// ./test/core/memory_grow.wast:50
|
||||
let $2 = instantiate(`(module
|
||||
(memory 0 10)
|
||||
(func (export "grow") (param i32) (result i32) (memory.grow (local.get 0)))
|
||||
)`);
|
||||
|
||||
// ./test/core/memory_grow.wast:55
|
||||
assert_return(() => invoke($2, `grow`, [0]), [value("i32", 0)]);
|
||||
|
||||
// ./test/core/memory_grow.wast:56
|
||||
assert_return(() => invoke($2, `grow`, [1]), [value("i32", 0)]);
|
||||
|
||||
// ./test/core/memory_grow.wast:57
|
||||
assert_return(() => invoke($2, `grow`, [1]), [value("i32", 1)]);
|
||||
|
||||
// ./test/core/memory_grow.wast:58
|
||||
assert_return(() => invoke($2, `grow`, [2]), [value("i32", 2)]);
|
||||
|
||||
// ./test/core/memory_grow.wast:59
|
||||
assert_return(() => invoke($2, `grow`, [6]), [value("i32", 4)]);
|
||||
|
||||
// ./test/core/memory_grow.wast:60
|
||||
assert_return(() => invoke($2, `grow`, [0]), [value("i32", 10)]);
|
||||
|
||||
// ./test/core/memory_grow.wast:61
|
||||
assert_return(() => invoke($2, `grow`, [1]), [value("i32", -1)]);
|
||||
|
||||
// ./test/core/memory_grow.wast:62
|
||||
assert_return(() => invoke($2, `grow`, [65536]), [value("i32", -1)]);
|
||||
|
||||
// ./test/core/memory_grow.wast:66
|
||||
let $3 = instantiate(`(module
|
||||
(memory 1)
|
||||
(func (export "grow") (param i32) (result i32)
|
||||
(memory.grow (local.get 0))
|
||||
)
|
||||
(func (export "check-memory-zero") (param i32 i32) (result i32)
|
||||
(local i32)
|
||||
(local.set 2 (i32.const 1))
|
||||
(block
|
||||
(loop
|
||||
(local.set 2 (i32.load8_u (local.get 0)))
|
||||
(br_if 1 (i32.ne (local.get 2) (i32.const 0)))
|
||||
(br_if 1 (i32.ge_u (local.get 0) (local.get 1)))
|
||||
(local.set 0 (i32.add (local.get 0) (i32.const 1)))
|
||||
(br_if 0 (i32.le_u (local.get 0) (local.get 1)))
|
||||
)
|
||||
)
|
||||
(local.get 2)
|
||||
)
|
||||
)`);
|
||||
|
||||
// ./test/core/memory_grow.wast:87
|
||||
assert_return(() => invoke($3, `check-memory-zero`, [0, 65535]), [
|
||||
value("i32", 0),
|
||||
]);
|
||||
|
||||
// ./test/core/memory_grow.wast:88
|
||||
assert_return(() => invoke($3, `grow`, [1]), [value("i32", 1)]);
|
||||
|
||||
// ./test/core/memory_grow.wast:89
|
||||
assert_return(() => invoke($3, `check-memory-zero`, [65536, 131071]), [
|
||||
value("i32", 0),
|
||||
]);
|
||||
|
||||
// ./test/core/memory_grow.wast:90
|
||||
assert_return(() => invoke($3, `grow`, [1]), [value("i32", 2)]);
|
||||
|
||||
// ./test/core/memory_grow.wast:91
|
||||
assert_return(() => invoke($3, `check-memory-zero`, [131072, 196607]), [
|
||||
value("i32", 0),
|
||||
]);
|
||||
|
||||
// ./test/core/memory_grow.wast:92
|
||||
assert_return(() => invoke($3, `grow`, [1]), [value("i32", 3)]);
|
||||
|
||||
// ./test/core/memory_grow.wast:93
|
||||
assert_return(() => invoke($3, `check-memory-zero`, [196608, 262143]), [
|
||||
value("i32", 0),
|
||||
]);
|
||||
|
||||
// ./test/core/memory_grow.wast:94
|
||||
assert_return(() => invoke($3, `grow`, [1]), [value("i32", 4)]);
|
||||
|
||||
// ./test/core/memory_grow.wast:95
|
||||
assert_return(() => invoke($3, `check-memory-zero`, [262144, 327679]), [
|
||||
value("i32", 0),
|
||||
]);
|
||||
|
||||
// ./test/core/memory_grow.wast:96
|
||||
assert_return(() => invoke($3, `grow`, [1]), [value("i32", 5)]);
|
||||
|
||||
// ./test/core/memory_grow.wast:97
|
||||
assert_return(() => invoke($3, `check-memory-zero`, [327680, 393215]), [
|
||||
value("i32", 0),
|
||||
]);
|
||||
|
||||
// ./test/core/memory_grow.wast:101
|
||||
let $4 = instantiate(`(module
|
||||
(memory 1)
|
||||
|
||||
(func (export "as-br-value") (result i32)
|
||||
(block (result i32) (br 0 (memory.grow (i32.const 0))))
|
||||
)
|
||||
|
||||
(func (export "as-br_if-cond")
|
||||
(block (br_if 0 (memory.grow (i32.const 0))))
|
||||
)
|
||||
(func (export "as-br_if-value") (result i32)
|
||||
(block (result i32)
|
||||
(drop (br_if 0 (memory.grow (i32.const 0)) (i32.const 1))) (i32.const 7)
|
||||
)
|
||||
)
|
||||
(func (export "as-br_if-value-cond") (result i32)
|
||||
(block (result i32)
|
||||
(drop (br_if 0 (i32.const 6) (memory.grow (i32.const 0)))) (i32.const 7)
|
||||
)
|
||||
)
|
||||
|
||||
(func (export "as-br_table-index")
|
||||
(block (br_table 0 0 0 (memory.grow (i32.const 0))))
|
||||
)
|
||||
(func (export "as-br_table-value") (result i32)
|
||||
(block (result i32)
|
||||
(br_table 0 0 0 (memory.grow (i32.const 0)) (i32.const 1)) (i32.const 7)
|
||||
)
|
||||
)
|
||||
(func (export "as-br_table-value-index") (result i32)
|
||||
(block (result i32)
|
||||
(br_table 0 0 (i32.const 6) (memory.grow (i32.const 0))) (i32.const 7)
|
||||
)
|
||||
)
|
||||
|
||||
(func (export "as-return-value") (result i32)
|
||||
(return (memory.grow (i32.const 0)))
|
||||
)
|
||||
|
||||
(func (export "as-if-cond") (result i32)
|
||||
(if (result i32) (memory.grow (i32.const 0))
|
||||
(then (i32.const 0)) (else (i32.const 1))
|
||||
)
|
||||
)
|
||||
(func (export "as-if-then") (result i32)
|
||||
(if (result i32) (i32.const 1)
|
||||
(then (memory.grow (i32.const 0))) (else (i32.const 0))
|
||||
)
|
||||
)
|
||||
(func (export "as-if-else") (result i32)
|
||||
(if (result i32) (i32.const 0)
|
||||
(then (i32.const 0)) (else (memory.grow (i32.const 0)))
|
||||
)
|
||||
)
|
||||
|
||||
(func (export "as-select-first") (param i32 i32) (result i32)
|
||||
(select (memory.grow (i32.const 0)) (local.get 0) (local.get 1))
|
||||
)
|
||||
(func (export "as-select-second") (param i32 i32) (result i32)
|
||||
(select (local.get 0) (memory.grow (i32.const 0)) (local.get 1))
|
||||
)
|
||||
(func (export "as-select-cond") (result i32)
|
||||
(select (i32.const 0) (i32.const 1) (memory.grow (i32.const 0)))
|
||||
)
|
||||
|
||||
(func $$f (param i32 i32 i32) (result i32) (i32.const -1))
|
||||
(func (export "as-call-first") (result i32)
|
||||
(call $$f (memory.grow (i32.const 0)) (i32.const 2) (i32.const 3))
|
||||
)
|
||||
(func (export "as-call-mid") (result i32)
|
||||
(call $$f (i32.const 1) (memory.grow (i32.const 0)) (i32.const 3))
|
||||
)
|
||||
(func (export "as-call-last") (result i32)
|
||||
(call $$f (i32.const 1) (i32.const 2) (memory.grow (i32.const 0)))
|
||||
)
|
||||
|
||||
(type $$sig (func (param i32 i32 i32) (result i32)))
|
||||
(table funcref (elem $$f))
|
||||
(func (export "as-call_indirect-first") (result i32)
|
||||
(call_indirect (type $$sig)
|
||||
(memory.grow (i32.const 0)) (i32.const 2) (i32.const 3) (i32.const 0)
|
||||
)
|
||||
)
|
||||
(func (export "as-call_indirect-mid") (result i32)
|
||||
(call_indirect (type $$sig)
|
||||
(i32.const 1) (memory.grow (i32.const 0)) (i32.const 3) (i32.const 0)
|
||||
)
|
||||
)
|
||||
(func (export "as-call_indirect-last") (result i32)
|
||||
(call_indirect (type $$sig)
|
||||
(i32.const 1) (i32.const 2) (memory.grow (i32.const 0)) (i32.const 0)
|
||||
)
|
||||
)
|
||||
(func (export "as-call_indirect-index") (result i32)
|
||||
(call_indirect (type $$sig)
|
||||
(i32.const 1) (i32.const 2) (i32.const 3) (memory.grow (i32.const 0))
|
||||
)
|
||||
)
|
||||
|
||||
(func (export "as-local.set-value") (local i32)
|
||||
(local.set 0 (memory.grow (i32.const 0)))
|
||||
)
|
||||
(func (export "as-local.tee-value") (result i32) (local i32)
|
||||
(local.tee 0 (memory.grow (i32.const 0)))
|
||||
)
|
||||
(global $$g (mut i32) (i32.const 0))
|
||||
(func (export "as-global.set-value") (local i32)
|
||||
(global.set $$g (memory.grow (i32.const 0)))
|
||||
)
|
||||
|
||||
(func (export "as-load-address") (result i32)
|
||||
(i32.load (memory.grow (i32.const 0)))
|
||||
)
|
||||
(func (export "as-loadN-address") (result i32)
|
||||
(i32.load8_s (memory.grow (i32.const 0)))
|
||||
)
|
||||
|
||||
(func (export "as-store-address")
|
||||
(i32.store (memory.grow (i32.const 0)) (i32.const 7))
|
||||
)
|
||||
(func (export "as-store-value")
|
||||
(i32.store (i32.const 2) (memory.grow (i32.const 0)))
|
||||
)
|
||||
|
||||
(func (export "as-storeN-address")
|
||||
(i32.store8 (memory.grow (i32.const 0)) (i32.const 7))
|
||||
)
|
||||
(func (export "as-storeN-value")
|
||||
(i32.store16 (i32.const 2) (memory.grow (i32.const 0)))
|
||||
)
|
||||
|
||||
(func (export "as-unary-operand") (result i32)
|
||||
(i32.clz (memory.grow (i32.const 0)))
|
||||
)
|
||||
|
||||
(func (export "as-binary-left") (result i32)
|
||||
(i32.add (memory.grow (i32.const 0)) (i32.const 10))
|
||||
)
|
||||
(func (export "as-binary-right") (result i32)
|
||||
(i32.sub (i32.const 10) (memory.grow (i32.const 0)))
|
||||
)
|
||||
|
||||
(func (export "as-test-operand") (result i32)
|
||||
(i32.eqz (memory.grow (i32.const 0)))
|
||||
)
|
||||
|
||||
(func (export "as-compare-left") (result i32)
|
||||
(i32.le_s (memory.grow (i32.const 0)) (i32.const 10))
|
||||
)
|
||||
(func (export "as-compare-right") (result i32)
|
||||
(i32.ne (i32.const 10) (memory.grow (i32.const 0)))
|
||||
)
|
||||
|
||||
(func (export "as-memory.grow-size") (result i32)
|
||||
(memory.grow (memory.grow (i32.const 0)))
|
||||
)
|
||||
)`);
|
||||
|
||||
// ./test/core/memory_grow.wast:259
|
||||
assert_return(() => invoke($4, `as-br-value`, []), [value("i32", 1)]);
|
||||
|
||||
// ./test/core/memory_grow.wast:261
|
||||
assert_return(() => invoke($4, `as-br_if-cond`, []), []);
|
||||
|
||||
// ./test/core/memory_grow.wast:262
|
||||
assert_return(() => invoke($4, `as-br_if-value`, []), [value("i32", 1)]);
|
||||
|
||||
// ./test/core/memory_grow.wast:263
|
||||
assert_return(() => invoke($4, `as-br_if-value-cond`, []), [value("i32", 6)]);
|
||||
|
||||
// ./test/core/memory_grow.wast:265
|
||||
assert_return(() => invoke($4, `as-br_table-index`, []), []);
|
||||
|
||||
// ./test/core/memory_grow.wast:266
|
||||
assert_return(() => invoke($4, `as-br_table-value`, []), [value("i32", 1)]);
|
||||
|
||||
// ./test/core/memory_grow.wast:267
|
||||
assert_return(() => invoke($4, `as-br_table-value-index`, []), [
|
||||
value("i32", 6),
|
||||
]);
|
||||
|
||||
// ./test/core/memory_grow.wast:269
|
||||
assert_return(() => invoke($4, `as-return-value`, []), [value("i32", 1)]);
|
||||
|
||||
// ./test/core/memory_grow.wast:271
|
||||
assert_return(() => invoke($4, `as-if-cond`, []), [value("i32", 0)]);
|
||||
|
||||
// ./test/core/memory_grow.wast:272
|
||||
assert_return(() => invoke($4, `as-if-then`, []), [value("i32", 1)]);
|
||||
|
||||
// ./test/core/memory_grow.wast:273
|
||||
assert_return(() => invoke($4, `as-if-else`, []), [value("i32", 1)]);
|
||||
|
||||
// ./test/core/memory_grow.wast:275
|
||||
assert_return(() => invoke($4, `as-select-first`, [0, 1]), [value("i32", 1)]);
|
||||
|
||||
// ./test/core/memory_grow.wast:276
|
||||
assert_return(() => invoke($4, `as-select-second`, [0, 0]), [value("i32", 1)]);
|
||||
|
||||
// ./test/core/memory_grow.wast:277
|
||||
assert_return(() => invoke($4, `as-select-cond`, []), [value("i32", 0)]);
|
||||
|
||||
// ./test/core/memory_grow.wast:279
|
||||
assert_return(() => invoke($4, `as-call-first`, []), [value("i32", -1)]);
|
||||
|
||||
// ./test/core/memory_grow.wast:280
|
||||
assert_return(() => invoke($4, `as-call-mid`, []), [value("i32", -1)]);
|
||||
|
||||
// ./test/core/memory_grow.wast:281
|
||||
assert_return(() => invoke($4, `as-call-last`, []), [value("i32", -1)]);
|
||||
|
||||
// ./test/core/memory_grow.wast:283
|
||||
assert_return(() => invoke($4, `as-call_indirect-first`, []), [
|
||||
value("i32", -1),
|
||||
]);
|
||||
|
||||
// ./test/core/memory_grow.wast:284
|
||||
assert_return(() => invoke($4, `as-call_indirect-mid`, []), [value("i32", -1)]);
|
||||
|
||||
// ./test/core/memory_grow.wast:285
|
||||
assert_return(() => invoke($4, `as-call_indirect-last`, []), [
|
||||
value("i32", -1),
|
||||
]);
|
||||
|
||||
// ./test/core/memory_grow.wast:286
|
||||
assert_trap(
|
||||
() => invoke($4, `as-call_indirect-index`, []),
|
||||
`undefined element`,
|
||||
);
|
||||
|
||||
// ./test/core/memory_grow.wast:288
|
||||
assert_return(() => invoke($4, `as-local.set-value`, []), []);
|
||||
|
||||
// ./test/core/memory_grow.wast:289
|
||||
assert_return(() => invoke($4, `as-local.tee-value`, []), [value("i32", 1)]);
|
||||
|
||||
// ./test/core/memory_grow.wast:290
|
||||
assert_return(() => invoke($4, `as-global.set-value`, []), []);
|
||||
|
||||
// ./test/core/memory_grow.wast:292
|
||||
assert_return(() => invoke($4, `as-load-address`, []), [value("i32", 0)]);
|
||||
|
||||
// ./test/core/memory_grow.wast:293
|
||||
assert_return(() => invoke($4, `as-loadN-address`, []), [value("i32", 0)]);
|
||||
|
||||
// ./test/core/memory_grow.wast:294
|
||||
assert_return(() => invoke($4, `as-store-address`, []), []);
|
||||
|
||||
// ./test/core/memory_grow.wast:295
|
||||
assert_return(() => invoke($4, `as-store-value`, []), []);
|
||||
|
||||
// ./test/core/memory_grow.wast:296
|
||||
assert_return(() => invoke($4, `as-storeN-address`, []), []);
|
||||
|
||||
// ./test/core/memory_grow.wast:297
|
||||
assert_return(() => invoke($4, `as-storeN-value`, []), []);
|
||||
|
||||
// ./test/core/memory_grow.wast:299
|
||||
assert_return(() => invoke($4, `as-unary-operand`, []), [value("i32", 31)]);
|
||||
|
||||
// ./test/core/memory_grow.wast:301
|
||||
assert_return(() => invoke($4, `as-binary-left`, []), [value("i32", 11)]);
|
||||
|
||||
// ./test/core/memory_grow.wast:302
|
||||
assert_return(() => invoke($4, `as-binary-right`, []), [value("i32", 9)]);
|
||||
|
||||
// ./test/core/memory_grow.wast:304
|
||||
assert_return(() => invoke($4, `as-test-operand`, []), [value("i32", 0)]);
|
||||
|
||||
// ./test/core/memory_grow.wast:306
|
||||
assert_return(() => invoke($4, `as-compare-left`, []), [value("i32", 1)]);
|
||||
|
||||
// ./test/core/memory_grow.wast:307
|
||||
assert_return(() => invoke($4, `as-compare-right`, []), [value("i32", 1)]);
|
||||
|
||||
// ./test/core/memory_grow.wast:309
|
||||
assert_return(() => invoke($4, `as-memory.grow-size`, []), [value("i32", 1)]);
|
||||
|
||||
// ./test/core/memory_grow.wast:312
|
||||
assert_invalid(() =>
|
||||
instantiate(`(module
|
||||
(memory 0)
|
||||
(func $$type-size-empty
|
||||
(memory.grow) (drop)
|
||||
)
|
||||
)`), `type mismatch`);
|
||||
|
||||
// ./test/core/memory_grow.wast:321
|
||||
assert_invalid(() =>
|
||||
instantiate(`(module
|
||||
(memory 0)
|
||||
(func $$type-size-empty-in-block
|
||||
(i32.const 0)
|
||||
(block (memory.grow) (drop))
|
||||
)
|
||||
)`), `type mismatch`);
|
||||
|
||||
// ./test/core/memory_grow.wast:331
|
||||
assert_invalid(() =>
|
||||
instantiate(`(module
|
||||
(memory 0)
|
||||
(func $$type-size-empty-in-loop
|
||||
(i32.const 0)
|
||||
(loop (memory.grow) (drop))
|
||||
)
|
||||
)`), `type mismatch`);
|
||||
|
||||
// ./test/core/memory_grow.wast:341
|
||||
assert_invalid(() =>
|
||||
instantiate(`(module
|
||||
(memory 0)
|
||||
(func $$type-size-empty-in-then
|
||||
(i32.const 0) (i32.const 0)
|
||||
(if (then (memory.grow) (drop)))
|
||||
)
|
||||
)`), `type mismatch`);
|
||||
|
||||
// ./test/core/memory_grow.wast:355
|
||||
assert_invalid(
|
||||
() =>
|
||||
instantiate(
|
||||
`(module (memory 1) (func (result i32) (memory.grow (f32.const 0))))`,
|
||||
),
|
||||
`type mismatch`,
|
||||
);
|
763
js/src/jit-test/tests/wasm/spec/threads/select.wast.js
Normal file
763
js/src/jit-test/tests/wasm/spec/threads/select.wast.js
Normal file
@ -0,0 +1,763 @@
|
||||
/* Copyright 2021 Mozilla Foundation
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
// ./test/core/select.wast
|
||||
|
||||
// ./test/core/select.wast:1
|
||||
let $0 = instantiate(`(module
|
||||
|
||||
(memory 1)
|
||||
|
||||
(func $$dummy)
|
||||
|
||||
(func (export "select_i32") (param $$lhs i32) (param $$rhs i32) (param $$cond i32) (result i32)
|
||||
(select (local.get $$lhs) (local.get $$rhs) (local.get $$cond)))
|
||||
|
||||
(func (export "select_i64") (param $$lhs i64) (param $$rhs i64) (param $$cond i32) (result i64)
|
||||
(select (local.get $$lhs) (local.get $$rhs) (local.get $$cond)))
|
||||
|
||||
(func (export "select_f32") (param $$lhs f32) (param $$rhs f32) (param $$cond i32) (result f32)
|
||||
(select (local.get $$lhs) (local.get $$rhs) (local.get $$cond)))
|
||||
|
||||
(func (export "select_f64") (param $$lhs f64) (param $$rhs f64) (param $$cond i32) (result f64)
|
||||
(select (local.get $$lhs) (local.get $$rhs) (local.get $$cond)))
|
||||
|
||||
;; Check that both sides of the select are evaluated
|
||||
(func (export "select_trap_l") (param $$cond i32) (result i32)
|
||||
(select (unreachable) (i32.const 0) (local.get $$cond))
|
||||
)
|
||||
(func (export "select_trap_r") (param $$cond i32) (result i32)
|
||||
(select (i32.const 0) (unreachable) (local.get $$cond))
|
||||
)
|
||||
|
||||
(func (export "select_unreached")
|
||||
(unreachable) (select)
|
||||
(unreachable) (i32.const 0) (select)
|
||||
(unreachable) (i32.const 0) (i32.const 0) (select)
|
||||
(unreachable) (f32.const 0) (i32.const 0) (select)
|
||||
(unreachable)
|
||||
)
|
||||
|
||||
;; As the argument of control constructs and instructions
|
||||
|
||||
(func (export "as-select-first") (param i32) (result i32)
|
||||
(select (select (i32.const 0) (i32.const 1) (local.get 0)) (i32.const 2) (i32.const 3))
|
||||
)
|
||||
(func (export "as-select-mid") (param i32) (result i32)
|
||||
(select (i32.const 2) (select (i32.const 0) (i32.const 1) (local.get 0)) (i32.const 3))
|
||||
)
|
||||
(func (export "as-select-last") (param i32) (result i32)
|
||||
(select (i32.const 2) (i32.const 3) (select (i32.const 0) (i32.const 1) (local.get 0)))
|
||||
)
|
||||
|
||||
(func (export "as-loop-first") (param i32) (result i32)
|
||||
(loop (result i32) (select (i32.const 2) (i32.const 3) (local.get 0)) (call $$dummy) (call $$dummy))
|
||||
)
|
||||
(func (export "as-loop-mid") (param i32) (result i32)
|
||||
(loop (result i32) (call $$dummy) (select (i32.const 2) (i32.const 3) (local.get 0)) (call $$dummy))
|
||||
)
|
||||
(func (export "as-loop-last") (param i32) (result i32)
|
||||
(loop (result i32) (call $$dummy) (call $$dummy) (select (i32.const 2) (i32.const 3) (local.get 0)))
|
||||
)
|
||||
|
||||
(func (export "as-if-condition") (param i32)
|
||||
(select (i32.const 2) (i32.const 3) (local.get 0)) (if (then (call $$dummy)))
|
||||
)
|
||||
(func (export "as-if-then") (param i32) (result i32)
|
||||
(if (result i32) (i32.const 1) (then (select (i32.const 2) (i32.const 3) (local.get 0))) (else (i32.const 4)))
|
||||
)
|
||||
(func (export "as-if-else") (param i32) (result i32)
|
||||
(if (result i32) (i32.const 0) (then (i32.const 2)) (else (select (i32.const 2) (i32.const 3) (local.get 0))))
|
||||
)
|
||||
|
||||
(func (export "as-br_if-first") (param i32) (result i32)
|
||||
(block (result i32) (br_if 0 (select (i32.const 2) (i32.const 3) (local.get 0)) (i32.const 4)))
|
||||
)
|
||||
(func (export "as-br_if-last") (param i32) (result i32)
|
||||
(block (result i32) (br_if 0 (i32.const 2) (select (i32.const 2) (i32.const 3) (local.get 0))))
|
||||
)
|
||||
|
||||
(func (export "as-br_table-first") (param i32) (result i32)
|
||||
(block (result i32) (select (i32.const 2) (i32.const 3) (local.get 0)) (i32.const 2) (br_table 0 0))
|
||||
)
|
||||
(func (export "as-br_table-last") (param i32) (result i32)
|
||||
(block (result i32) (i32.const 2) (select (i32.const 2) (i32.const 3) (local.get 0)) (br_table 0 0))
|
||||
)
|
||||
|
||||
(func $$func (param i32 i32) (result i32) (local.get 0))
|
||||
(type $$check (func (param i32 i32) (result i32)))
|
||||
(table funcref (elem $$func))
|
||||
(func (export "as-call_indirect-first") (param i32) (result i32)
|
||||
(block (result i32)
|
||||
(call_indirect (type $$check)
|
||||
(select (i32.const 2) (i32.const 3) (local.get 0)) (i32.const 1) (i32.const 0)
|
||||
)
|
||||
)
|
||||
)
|
||||
(func (export "as-call_indirect-mid") (param i32) (result i32)
|
||||
(block (result i32)
|
||||
(call_indirect (type $$check)
|
||||
(i32.const 1) (select (i32.const 2) (i32.const 3) (local.get 0)) (i32.const 0)
|
||||
)
|
||||
)
|
||||
)
|
||||
(func (export "as-call_indirect-last") (param i32) (result i32)
|
||||
(block (result i32)
|
||||
(call_indirect (type $$check)
|
||||
(i32.const 1) (i32.const 4) (select (i32.const 2) (i32.const 3) (local.get 0))
|
||||
)
|
||||
)
|
||||
)
|
||||
|
||||
(func (export "as-store-first") (param i32)
|
||||
(select (i32.const 0) (i32.const 4) (local.get 0)) (i32.const 1) (i32.store)
|
||||
)
|
||||
(func (export "as-store-last") (param i32)
|
||||
(i32.const 8) (select (i32.const 1) (i32.const 2) (local.get 0)) (i32.store)
|
||||
)
|
||||
|
||||
(func (export "as-memory.grow-value") (param i32) (result i32)
|
||||
(memory.grow (select (i32.const 1) (i32.const 2) (local.get 0)))
|
||||
)
|
||||
|
||||
(func $$f (param i32) (result i32) (local.get 0))
|
||||
|
||||
(func (export "as-call-value") (param i32) (result i32)
|
||||
(call $$f (select (i32.const 1) (i32.const 2) (local.get 0)))
|
||||
)
|
||||
(func (export "as-return-value") (param i32) (result i32)
|
||||
(select (i32.const 1) (i32.const 2) (local.get 0)) (return)
|
||||
)
|
||||
(func (export "as-drop-operand") (param i32)
|
||||
(drop (select (i32.const 1) (i32.const 2) (local.get 0)))
|
||||
)
|
||||
(func (export "as-br-value") (param i32) (result i32)
|
||||
(block (result i32) (br 0 (select (i32.const 1) (i32.const 2) (local.get 0))))
|
||||
)
|
||||
(func (export "as-local.set-value") (param i32) (result i32)
|
||||
(local i32) (local.set 0 (select (i32.const 1) (i32.const 2) (local.get 0))) (local.get 0)
|
||||
)
|
||||
(func (export "as-local.tee-value") (param i32) (result i32)
|
||||
(local.tee 0 (select (i32.const 1) (i32.const 2) (local.get 0)))
|
||||
)
|
||||
(global $$a (mut i32) (i32.const 10))
|
||||
(func (export "as-global.set-value") (param i32) (result i32)
|
||||
(global.set $$a (select (i32.const 1) (i32.const 2) (local.get 0)))
|
||||
(global.get $$a)
|
||||
)
|
||||
(func (export "as-load-operand") (param i32) (result i32)
|
||||
(i32.load (select (i32.const 0) (i32.const 4) (local.get 0)))
|
||||
)
|
||||
|
||||
(func (export "as-unary-operand") (param i32) (result i32)
|
||||
(i32.eqz (select (i32.const 0) (i32.const 1) (local.get 0)))
|
||||
)
|
||||
(func (export "as-binary-operand") (param i32) (result i32)
|
||||
(i32.mul
|
||||
(select (i32.const 1) (i32.const 2) (local.get 0))
|
||||
(select (i32.const 1) (i32.const 2) (local.get 0))
|
||||
)
|
||||
)
|
||||
(func (export "as-test-operand") (param i32) (result i32)
|
||||
(block (result i32)
|
||||
(i32.eqz (select (i32.const 0) (i32.const 1) (local.get 0)))
|
||||
)
|
||||
)
|
||||
|
||||
(func (export "as-compare-left") (param i32) (result i32)
|
||||
(block (result i32)
|
||||
(i32.le_s (select (i32.const 1) (i32.const 2) (local.get 0)) (i32.const 1))
|
||||
)
|
||||
)
|
||||
(func (export "as-compare-right") (param i32) (result i32)
|
||||
(block (result i32)
|
||||
(i32.ne (i32.const 1) (select (i32.const 0) (i32.const 1) (local.get 0)))
|
||||
)
|
||||
)
|
||||
|
||||
(func (export "as-convert-operand") (param i32) (result i32)
|
||||
(block (result i32)
|
||||
(i32.wrap_i64 (select (i64.const 1) (i64.const 0) (local.get 0)))
|
||||
)
|
||||
)
|
||||
|
||||
)`);
|
||||
|
||||
// ./test/core/select.wast:180
|
||||
assert_return(() => invoke($0, `select_i32`, [1, 2, 1]), [value("i32", 1)]);
|
||||
|
||||
// ./test/core/select.wast:181
|
||||
assert_return(() => invoke($0, `select_i64`, [2n, 1n, 1]), [value("i64", 2n)]);
|
||||
|
||||
// ./test/core/select.wast:182
|
||||
assert_return(
|
||||
() => invoke($0, `select_f32`, [value("f32", 1), value("f32", 2), 1]),
|
||||
[value("f32", 1)],
|
||||
);
|
||||
|
||||
// ./test/core/select.wast:183
|
||||
assert_return(
|
||||
() => invoke($0, `select_f64`, [value("f64", 1), value("f64", 2), 1]),
|
||||
[value("f64", 1)],
|
||||
);
|
||||
|
||||
// ./test/core/select.wast:185
|
||||
assert_return(() => invoke($0, `select_i32`, [1, 2, 0]), [value("i32", 2)]);
|
||||
|
||||
// ./test/core/select.wast:186
|
||||
assert_return(() => invoke($0, `select_i32`, [2, 1, 0]), [value("i32", 1)]);
|
||||
|
||||
// ./test/core/select.wast:187
|
||||
assert_return(() => invoke($0, `select_i64`, [2n, 1n, -1]), [value("i64", 2n)]);
|
||||
|
||||
// ./test/core/select.wast:188
|
||||
assert_return(() => invoke($0, `select_i64`, [2n, 1n, -252645136]), [
|
||||
value("i64", 2n),
|
||||
]);
|
||||
|
||||
// ./test/core/select.wast:190
|
||||
assert_return(
|
||||
() =>
|
||||
invoke($0, `select_f32`, [
|
||||
bytes("f32", [0x0, 0x0, 0xc0, 0x7f]),
|
||||
value("f32", 1),
|
||||
1,
|
||||
]),
|
||||
[bytes("f32", [0x0, 0x0, 0xc0, 0x7f])],
|
||||
);
|
||||
|
||||
// ./test/core/select.wast:191
|
||||
assert_return(
|
||||
() =>
|
||||
invoke($0, `select_f32`, [
|
||||
bytes("f32", [0x4, 0x3, 0x82, 0x7f]),
|
||||
value("f32", 1),
|
||||
1,
|
||||
]),
|
||||
[bytes("f32", [0x4, 0x3, 0x82, 0x7f])],
|
||||
);
|
||||
|
||||
// ./test/core/select.wast:192
|
||||
assert_return(
|
||||
() =>
|
||||
invoke($0, `select_f32`, [
|
||||
bytes("f32", [0x0, 0x0, 0xc0, 0x7f]),
|
||||
value("f32", 1),
|
||||
0,
|
||||
]),
|
||||
[value("f32", 1)],
|
||||
);
|
||||
|
||||
// ./test/core/select.wast:193
|
||||
assert_return(
|
||||
() =>
|
||||
invoke($0, `select_f32`, [
|
||||
bytes("f32", [0x4, 0x3, 0x82, 0x7f]),
|
||||
value("f32", 1),
|
||||
0,
|
||||
]),
|
||||
[value("f32", 1)],
|
||||
);
|
||||
|
||||
// ./test/core/select.wast:194
|
||||
assert_return(
|
||||
() =>
|
||||
invoke($0, `select_f32`, [
|
||||
value("f32", 2),
|
||||
bytes("f32", [0x0, 0x0, 0xc0, 0x7f]),
|
||||
1,
|
||||
]),
|
||||
[value("f32", 2)],
|
||||
);
|
||||
|
||||
// ./test/core/select.wast:195
|
||||
assert_return(
|
||||
() =>
|
||||
invoke($0, `select_f32`, [
|
||||
value("f32", 2),
|
||||
bytes("f32", [0x4, 0x3, 0x82, 0x7f]),
|
||||
1,
|
||||
]),
|
||||
[value("f32", 2)],
|
||||
);
|
||||
|
||||
// ./test/core/select.wast:196
|
||||
assert_return(
|
||||
() =>
|
||||
invoke($0, `select_f32`, [
|
||||
value("f32", 2),
|
||||
bytes("f32", [0x0, 0x0, 0xc0, 0x7f]),
|
||||
0,
|
||||
]),
|
||||
[bytes("f32", [0x0, 0x0, 0xc0, 0x7f])],
|
||||
);
|
||||
|
||||
// ./test/core/select.wast:197
|
||||
assert_return(
|
||||
() =>
|
||||
invoke($0, `select_f32`, [
|
||||
value("f32", 2),
|
||||
bytes("f32", [0x4, 0x3, 0x82, 0x7f]),
|
||||
0,
|
||||
]),
|
||||
[bytes("f32", [0x4, 0x3, 0x82, 0x7f])],
|
||||
);
|
||||
|
||||
// ./test/core/select.wast:199
|
||||
assert_return(
|
||||
() =>
|
||||
invoke($0, `select_f64`, [
|
||||
bytes("f64", [0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xf8, 0x7f]),
|
||||
value("f64", 1),
|
||||
1,
|
||||
]),
|
||||
[bytes("f64", [0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xf8, 0x7f])],
|
||||
);
|
||||
|
||||
// ./test/core/select.wast:200
|
||||
assert_return(
|
||||
() =>
|
||||
invoke($0, `select_f64`, [
|
||||
bytes("f64", [0x4, 0x3, 0x2, 0x0, 0x0, 0x0, 0xf0, 0x7f]),
|
||||
value("f64", 1),
|
||||
1,
|
||||
]),
|
||||
[bytes("f64", [0x4, 0x3, 0x2, 0x0, 0x0, 0x0, 0xf0, 0x7f])],
|
||||
);
|
||||
|
||||
// ./test/core/select.wast:201
|
||||
assert_return(
|
||||
() =>
|
||||
invoke($0, `select_f64`, [
|
||||
bytes("f64", [0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xf8, 0x7f]),
|
||||
value("f64", 1),
|
||||
0,
|
||||
]),
|
||||
[value("f64", 1)],
|
||||
);
|
||||
|
||||
// ./test/core/select.wast:202
|
||||
assert_return(
|
||||
() =>
|
||||
invoke($0, `select_f64`, [
|
||||
bytes("f64", [0x4, 0x3, 0x2, 0x0, 0x0, 0x0, 0xf0, 0x7f]),
|
||||
value("f64", 1),
|
||||
0,
|
||||
]),
|
||||
[value("f64", 1)],
|
||||
);
|
||||
|
||||
// ./test/core/select.wast:203
|
||||
assert_return(
|
||||
() =>
|
||||
invoke($0, `select_f64`, [
|
||||
value("f64", 2),
|
||||
bytes("f64", [0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xf8, 0x7f]),
|
||||
1,
|
||||
]),
|
||||
[value("f64", 2)],
|
||||
);
|
||||
|
||||
// ./test/core/select.wast:204
|
||||
assert_return(
|
||||
() =>
|
||||
invoke($0, `select_f64`, [
|
||||
value("f64", 2),
|
||||
bytes("f64", [0x4, 0x3, 0x2, 0x0, 0x0, 0x0, 0xf0, 0x7f]),
|
||||
1,
|
||||
]),
|
||||
[value("f64", 2)],
|
||||
);
|
||||
|
||||
// ./test/core/select.wast:205
|
||||
assert_return(
|
||||
() =>
|
||||
invoke($0, `select_f64`, [
|
||||
value("f64", 2),
|
||||
bytes("f64", [0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xf8, 0x7f]),
|
||||
0,
|
||||
]),
|
||||
[bytes("f64", [0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xf8, 0x7f])],
|
||||
);
|
||||
|
||||
// ./test/core/select.wast:206
|
||||
assert_return(
|
||||
() =>
|
||||
invoke($0, `select_f64`, [
|
||||
value("f64", 2),
|
||||
bytes("f64", [0x4, 0x3, 0x2, 0x0, 0x0, 0x0, 0xf0, 0x7f]),
|
||||
0,
|
||||
]),
|
||||
[bytes("f64", [0x4, 0x3, 0x2, 0x0, 0x0, 0x0, 0xf0, 0x7f])],
|
||||
);
|
||||
|
||||
// ./test/core/select.wast:208
|
||||
assert_trap(() => invoke($0, `select_trap_l`, [1]), `unreachable`);
|
||||
|
||||
// ./test/core/select.wast:209
|
||||
assert_trap(() => invoke($0, `select_trap_l`, [0]), `unreachable`);
|
||||
|
||||
// ./test/core/select.wast:210
|
||||
assert_trap(() => invoke($0, `select_trap_r`, [1]), `unreachable`);
|
||||
|
||||
// ./test/core/select.wast:211
|
||||
assert_trap(() => invoke($0, `select_trap_r`, [0]), `unreachable`);
|
||||
|
||||
// ./test/core/select.wast:213
|
||||
assert_return(() => invoke($0, `as-select-first`, [0]), [value("i32", 1)]);
|
||||
|
||||
// ./test/core/select.wast:214
|
||||
assert_return(() => invoke($0, `as-select-first`, [1]), [value("i32", 0)]);
|
||||
|
||||
// ./test/core/select.wast:215
|
||||
assert_return(() => invoke($0, `as-select-mid`, [0]), [value("i32", 2)]);
|
||||
|
||||
// ./test/core/select.wast:216
|
||||
assert_return(() => invoke($0, `as-select-mid`, [1]), [value("i32", 2)]);
|
||||
|
||||
// ./test/core/select.wast:217
|
||||
assert_return(() => invoke($0, `as-select-last`, [0]), [value("i32", 2)]);
|
||||
|
||||
// ./test/core/select.wast:218
|
||||
assert_return(() => invoke($0, `as-select-last`, [1]), [value("i32", 3)]);
|
||||
|
||||
// ./test/core/select.wast:220
|
||||
assert_return(() => invoke($0, `as-loop-first`, [0]), [value("i32", 3)]);
|
||||
|
||||
// ./test/core/select.wast:221
|
||||
assert_return(() => invoke($0, `as-loop-first`, [1]), [value("i32", 2)]);
|
||||
|
||||
// ./test/core/select.wast:222
|
||||
assert_return(() => invoke($0, `as-loop-mid`, [0]), [value("i32", 3)]);
|
||||
|
||||
// ./test/core/select.wast:223
|
||||
assert_return(() => invoke($0, `as-loop-mid`, [1]), [value("i32", 2)]);
|
||||
|
||||
// ./test/core/select.wast:224
|
||||
assert_return(() => invoke($0, `as-loop-last`, [0]), [value("i32", 3)]);
|
||||
|
||||
// ./test/core/select.wast:225
|
||||
assert_return(() => invoke($0, `as-loop-last`, [1]), [value("i32", 2)]);
|
||||
|
||||
// ./test/core/select.wast:227
|
||||
assert_return(() => invoke($0, `as-if-condition`, [0]), []);
|
||||
|
||||
// ./test/core/select.wast:228
|
||||
assert_return(() => invoke($0, `as-if-condition`, [1]), []);
|
||||
|
||||
// ./test/core/select.wast:229
|
||||
assert_return(() => invoke($0, `as-if-then`, [0]), [value("i32", 3)]);
|
||||
|
||||
// ./test/core/select.wast:230
|
||||
assert_return(() => invoke($0, `as-if-then`, [1]), [value("i32", 2)]);
|
||||
|
||||
// ./test/core/select.wast:231
|
||||
assert_return(() => invoke($0, `as-if-else`, [0]), [value("i32", 3)]);
|
||||
|
||||
// ./test/core/select.wast:232
|
||||
assert_return(() => invoke($0, `as-if-else`, [1]), [value("i32", 2)]);
|
||||
|
||||
// ./test/core/select.wast:234
|
||||
assert_return(() => invoke($0, `as-br_if-first`, [0]), [value("i32", 3)]);
|
||||
|
||||
// ./test/core/select.wast:235
|
||||
assert_return(() => invoke($0, `as-br_if-first`, [1]), [value("i32", 2)]);
|
||||
|
||||
// ./test/core/select.wast:236
|
||||
assert_return(() => invoke($0, `as-br_if-last`, [0]), [value("i32", 2)]);
|
||||
|
||||
// ./test/core/select.wast:237
|
||||
assert_return(() => invoke($0, `as-br_if-last`, [1]), [value("i32", 2)]);
|
||||
|
||||
// ./test/core/select.wast:239
|
||||
assert_return(() => invoke($0, `as-br_table-first`, [0]), [value("i32", 3)]);
|
||||
|
||||
// ./test/core/select.wast:240
|
||||
assert_return(() => invoke($0, `as-br_table-first`, [1]), [value("i32", 2)]);
|
||||
|
||||
// ./test/core/select.wast:241
|
||||
assert_return(() => invoke($0, `as-br_table-last`, [0]), [value("i32", 2)]);
|
||||
|
||||
// ./test/core/select.wast:242
|
||||
assert_return(() => invoke($0, `as-br_table-last`, [1]), [value("i32", 2)]);
|
||||
|
||||
// ./test/core/select.wast:244
|
||||
assert_return(() => invoke($0, `as-call_indirect-first`, [0]), [
|
||||
value("i32", 3),
|
||||
]);
|
||||
|
||||
// ./test/core/select.wast:245
|
||||
assert_return(() => invoke($0, `as-call_indirect-first`, [1]), [
|
||||
value("i32", 2),
|
||||
]);
|
||||
|
||||
// ./test/core/select.wast:246
|
||||
assert_return(() => invoke($0, `as-call_indirect-mid`, [0]), [value("i32", 1)]);
|
||||
|
||||
// ./test/core/select.wast:247
|
||||
assert_return(() => invoke($0, `as-call_indirect-mid`, [1]), [value("i32", 1)]);
|
||||
|
||||
// ./test/core/select.wast:248
|
||||
assert_trap(
|
||||
() => invoke($0, `as-call_indirect-last`, [0]),
|
||||
`undefined element`,
|
||||
);
|
||||
|
||||
// ./test/core/select.wast:249
|
||||
assert_trap(
|
||||
() => invoke($0, `as-call_indirect-last`, [1]),
|
||||
`undefined element`,
|
||||
);
|
||||
|
||||
// ./test/core/select.wast:251
|
||||
assert_return(() => invoke($0, `as-store-first`, [0]), []);
|
||||
|
||||
// ./test/core/select.wast:252
|
||||
assert_return(() => invoke($0, `as-store-first`, [1]), []);
|
||||
|
||||
// ./test/core/select.wast:253
|
||||
assert_return(() => invoke($0, `as-store-last`, [0]), []);
|
||||
|
||||
// ./test/core/select.wast:254
|
||||
assert_return(() => invoke($0, `as-store-last`, [1]), []);
|
||||
|
||||
// ./test/core/select.wast:256
|
||||
assert_return(() => invoke($0, `as-memory.grow-value`, [0]), [value("i32", 1)]);
|
||||
|
||||
// ./test/core/select.wast:257
|
||||
assert_return(() => invoke($0, `as-memory.grow-value`, [1]), [value("i32", 3)]);
|
||||
|
||||
// ./test/core/select.wast:259
|
||||
assert_return(() => invoke($0, `as-call-value`, [0]), [value("i32", 2)]);
|
||||
|
||||
// ./test/core/select.wast:260
|
||||
assert_return(() => invoke($0, `as-call-value`, [1]), [value("i32", 1)]);
|
||||
|
||||
// ./test/core/select.wast:261
|
||||
assert_return(() => invoke($0, `as-return-value`, [0]), [value("i32", 2)]);
|
||||
|
||||
// ./test/core/select.wast:262
|
||||
assert_return(() => invoke($0, `as-return-value`, [1]), [value("i32", 1)]);
|
||||
|
||||
// ./test/core/select.wast:263
|
||||
assert_return(() => invoke($0, `as-drop-operand`, [0]), []);
|
||||
|
||||
// ./test/core/select.wast:264
|
||||
assert_return(() => invoke($0, `as-drop-operand`, [1]), []);
|
||||
|
||||
// ./test/core/select.wast:265
|
||||
assert_return(() => invoke($0, `as-br-value`, [0]), [value("i32", 2)]);
|
||||
|
||||
// ./test/core/select.wast:266
|
||||
assert_return(() => invoke($0, `as-br-value`, [1]), [value("i32", 1)]);
|
||||
|
||||
// ./test/core/select.wast:267
|
||||
assert_return(() => invoke($0, `as-local.set-value`, [0]), [value("i32", 2)]);
|
||||
|
||||
// ./test/core/select.wast:268
|
||||
assert_return(() => invoke($0, `as-local.set-value`, [1]), [value("i32", 1)]);
|
||||
|
||||
// ./test/core/select.wast:269
|
||||
assert_return(() => invoke($0, `as-local.tee-value`, [0]), [value("i32", 2)]);
|
||||
|
||||
// ./test/core/select.wast:270
|
||||
assert_return(() => invoke($0, `as-local.tee-value`, [1]), [value("i32", 1)]);
|
||||
|
||||
// ./test/core/select.wast:271
|
||||
assert_return(() => invoke($0, `as-global.set-value`, [0]), [value("i32", 2)]);
|
||||
|
||||
// ./test/core/select.wast:272
|
||||
assert_return(() => invoke($0, `as-global.set-value`, [1]), [value("i32", 1)]);
|
||||
|
||||
// ./test/core/select.wast:273
|
||||
assert_return(() => invoke($0, `as-load-operand`, [0]), [value("i32", 1)]);
|
||||
|
||||
// ./test/core/select.wast:274
|
||||
assert_return(() => invoke($0, `as-load-operand`, [1]), [value("i32", 1)]);
|
||||
|
||||
// ./test/core/select.wast:276
|
||||
assert_return(() => invoke($0, `as-unary-operand`, [0]), [value("i32", 0)]);
|
||||
|
||||
// ./test/core/select.wast:277
|
||||
assert_return(() => invoke($0, `as-unary-operand`, [1]), [value("i32", 1)]);
|
||||
|
||||
// ./test/core/select.wast:278
|
||||
assert_return(() => invoke($0, `as-binary-operand`, [0]), [value("i32", 4)]);
|
||||
|
||||
// ./test/core/select.wast:279
|
||||
assert_return(() => invoke($0, `as-binary-operand`, [1]), [value("i32", 1)]);
|
||||
|
||||
// ./test/core/select.wast:280
|
||||
assert_return(() => invoke($0, `as-test-operand`, [0]), [value("i32", 0)]);
|
||||
|
||||
// ./test/core/select.wast:281
|
||||
assert_return(() => invoke($0, `as-test-operand`, [1]), [value("i32", 1)]);
|
||||
|
||||
// ./test/core/select.wast:282
|
||||
assert_return(() => invoke($0, `as-compare-left`, [0]), [value("i32", 0)]);
|
||||
|
||||
// ./test/core/select.wast:283
|
||||
assert_return(() => invoke($0, `as-compare-left`, [1]), [value("i32", 1)]);
|
||||
|
||||
// ./test/core/select.wast:284
|
||||
assert_return(() => invoke($0, `as-compare-right`, [0]), [value("i32", 0)]);
|
||||
|
||||
// ./test/core/select.wast:285
|
||||
assert_return(() => invoke($0, `as-compare-right`, [1]), [value("i32", 1)]);
|
||||
|
||||
// ./test/core/select.wast:286
|
||||
assert_return(() => invoke($0, `as-convert-operand`, [0]), [value("i32", 0)]);
|
||||
|
||||
// ./test/core/select.wast:287
|
||||
assert_return(() => invoke($0, `as-convert-operand`, [1]), [value("i32", 1)]);
|
||||
|
||||
// ./test/core/select.wast:289
|
||||
assert_invalid(
|
||||
() =>
|
||||
instantiate(`(module (func $$arity-0 (select (nop) (nop) (i32.const 1))))`),
|
||||
`type mismatch`,
|
||||
);
|
||||
|
||||
// ./test/core/select.wast:296
|
||||
assert_invalid(
|
||||
() =>
|
||||
instantiate(
|
||||
`(module (func $$type-num-vs-num (select (i32.const 1) (i64.const 1) (i32.const 1))))`,
|
||||
),
|
||||
`type mismatch`,
|
||||
);
|
||||
|
||||
// ./test/core/select.wast:300
|
||||
assert_invalid(
|
||||
() =>
|
||||
instantiate(
|
||||
`(module (func $$type-num-vs-num (select (i32.const 1) (f32.const 1.0) (i32.const 1))))`,
|
||||
),
|
||||
`type mismatch`,
|
||||
);
|
||||
|
||||
// ./test/core/select.wast:304
|
||||
assert_invalid(
|
||||
() =>
|
||||
instantiate(
|
||||
`(module (func $$type-num-vs-num (select (i32.const 1) (f64.const 1.0) (i32.const 1))))`,
|
||||
),
|
||||
`type mismatch`,
|
||||
);
|
||||
|
||||
// ./test/core/select.wast:310
|
||||
assert_invalid(() =>
|
||||
instantiate(`(module
|
||||
(func $$type-1st-operand-empty
|
||||
(select) (drop)
|
||||
)
|
||||
)`), `type mismatch`);
|
||||
|
||||
// ./test/core/select.wast:318
|
||||
assert_invalid(() =>
|
||||
instantiate(`(module
|
||||
(func $$type-2nd-operand-empty
|
||||
(i32.const 0) (select) (drop)
|
||||
)
|
||||
)`), `type mismatch`);
|
||||
|
||||
// ./test/core/select.wast:326
|
||||
assert_invalid(() =>
|
||||
instantiate(`(module
|
||||
(func $$type-3rd-operand-empty
|
||||
(i32.const 0) (i32.const 0) (select) (drop)
|
||||
)
|
||||
)`), `type mismatch`);
|
||||
|
||||
// ./test/core/select.wast:334
|
||||
assert_invalid(() =>
|
||||
instantiate(`(module
|
||||
(func $$type-1st-operand-empty-in-block
|
||||
(i32.const 0) (i32.const 0) (i32.const 0)
|
||||
(block (select) (drop))
|
||||
)
|
||||
)`), `type mismatch`);
|
||||
|
||||
// ./test/core/select.wast:343
|
||||
assert_invalid(() =>
|
||||
instantiate(`(module
|
||||
(func $$type-2nd-operand-empty-in-block
|
||||
(i32.const 0) (i32.const 0)
|
||||
(block (i32.const 0) (select) (drop))
|
||||
)
|
||||
)`), `type mismatch`);
|
||||
|
||||
// ./test/core/select.wast:352
|
||||
assert_invalid(() =>
|
||||
instantiate(`(module
|
||||
(func $$type-3rd-operand-empty-in-block
|
||||
(i32.const 0)
|
||||
(block (i32.const 0) (i32.const 0) (select) (drop))
|
||||
)
|
||||
)`), `type mismatch`);
|
||||
|
||||
// ./test/core/select.wast:361
|
||||
assert_invalid(() =>
|
||||
instantiate(`(module
|
||||
(func $$type-1st-operand-empty-in-loop
|
||||
(i32.const 0) (i32.const 0) (i32.const 0)
|
||||
(loop (select) (drop))
|
||||
)
|
||||
)`), `type mismatch`);
|
||||
|
||||
// ./test/core/select.wast:370
|
||||
assert_invalid(() =>
|
||||
instantiate(`(module
|
||||
(func $$type-2nd-operand-empty-in-loop
|
||||
(i32.const 0) (i32.const 0)
|
||||
(loop (i32.const 0) (select) (drop))
|
||||
)
|
||||
)`), `type mismatch`);
|
||||
|
||||
// ./test/core/select.wast:379
|
||||
assert_invalid(() =>
|
||||
instantiate(`(module
|
||||
(func $$type-3rd-operand-empty-in-loop
|
||||
(i32.const 0)
|
||||
(loop (i32.const 0) (i32.const 0) (select) (drop))
|
||||
)
|
||||
)`), `type mismatch`);
|
||||
|
||||
// ./test/core/select.wast:388
|
||||
assert_invalid(() =>
|
||||
instantiate(`(module
|
||||
(func $$type-1st-operand-empty-in-then
|
||||
(i32.const 0) (i32.const 0) (i32.const 0)
|
||||
(if (then (select) (drop)))
|
||||
)
|
||||
)`), `type mismatch`);
|
||||
|
||||
// ./test/core/select.wast:397
|
||||
assert_invalid(() =>
|
||||
instantiate(`(module
|
||||
(func $$type-2nd-operand-empty-in-then
|
||||
(i32.const 0) (i32.const 0)
|
||||
(if (then (i32.const 0) (select) (drop)))
|
||||
)
|
||||
)`), `type mismatch`);
|
||||
|
||||
// ./test/core/select.wast:406
|
||||
assert_invalid(() =>
|
||||
instantiate(`(module
|
||||
(func $$type-3rd-operand-empty-in-then
|
||||
(i32.const 0)
|
||||
(if (then (i32.const 0) (i32.const 0) (select) (drop)))
|
||||
)
|
||||
)`), `type mismatch`);
|
247
js/src/jit-test/tests/wasm/spec/threads/stack.wast.js
Normal file
247
js/src/jit-test/tests/wasm/spec/threads/stack.wast.js
Normal file
@ -0,0 +1,247 @@
|
||||
/* Copyright 2021 Mozilla Foundation
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
// ./test/core/stack.wast
|
||||
|
||||
// ./test/core/stack.wast:1
|
||||
let $0 = instantiate(`(module
|
||||
(func (export "fac-expr") (param $$n i64) (result i64)
|
||||
(local $$i i64)
|
||||
(local $$res i64)
|
||||
(local.set $$i (local.get $$n))
|
||||
(local.set $$res (i64.const 1))
|
||||
(block $$done
|
||||
(loop $$loop
|
||||
(if
|
||||
(i64.eq (local.get $$i) (i64.const 0))
|
||||
(then (br $$done))
|
||||
(else
|
||||
(local.set $$res (i64.mul (local.get $$i) (local.get $$res)))
|
||||
(local.set $$i (i64.sub (local.get $$i) (i64.const 1)))
|
||||
)
|
||||
)
|
||||
(br $$loop)
|
||||
)
|
||||
)
|
||||
(local.get $$res)
|
||||
)
|
||||
|
||||
(func (export "fac-stack") (param $$n i64) (result i64)
|
||||
(local $$i i64)
|
||||
(local $$res i64)
|
||||
(local.get $$n)
|
||||
(local.set $$i)
|
||||
(i64.const 1)
|
||||
(local.set $$res)
|
||||
(block $$done
|
||||
(loop $$loop
|
||||
(local.get $$i)
|
||||
(i64.const 0)
|
||||
(i64.eq)
|
||||
(if
|
||||
(then (br $$done))
|
||||
(else
|
||||
(local.get $$i)
|
||||
(local.get $$res)
|
||||
(i64.mul)
|
||||
(local.set $$res)
|
||||
(local.get $$i)
|
||||
(i64.const 1)
|
||||
(i64.sub)
|
||||
(local.set $$i)
|
||||
)
|
||||
)
|
||||
(br $$loop)
|
||||
)
|
||||
)
|
||||
(local.get $$res)
|
||||
)
|
||||
|
||||
(func (export "fac-stack-raw") (param $$n i64) (result i64)
|
||||
(local $$i i64)
|
||||
(local $$res i64)
|
||||
local.get $$n
|
||||
local.set $$i
|
||||
i64.const 1
|
||||
local.set $$res
|
||||
block $$done
|
||||
loop $$loop
|
||||
local.get $$i
|
||||
i64.const 0
|
||||
i64.eq
|
||||
if $$body
|
||||
br $$done
|
||||
else $$body
|
||||
local.get $$i
|
||||
local.get $$res
|
||||
i64.mul
|
||||
local.set $$res
|
||||
local.get $$i
|
||||
i64.const 1
|
||||
i64.sub
|
||||
local.set $$i
|
||||
end $$body
|
||||
br $$loop
|
||||
end $$loop
|
||||
end $$done
|
||||
local.get $$res
|
||||
)
|
||||
|
||||
(func (export "fac-mixed") (param $$n i64) (result i64)
|
||||
(local $$i i64)
|
||||
(local $$res i64)
|
||||
(local.set $$i (local.get $$n))
|
||||
(local.set $$res (i64.const 1))
|
||||
(block $$done
|
||||
(loop $$loop
|
||||
(i64.eq (local.get $$i) (i64.const 0))
|
||||
(if
|
||||
(then (br $$done))
|
||||
(else
|
||||
(i64.mul (local.get $$i) (local.get $$res))
|
||||
(local.set $$res)
|
||||
(i64.sub (local.get $$i) (i64.const 1))
|
||||
(local.set $$i)
|
||||
)
|
||||
)
|
||||
(br $$loop)
|
||||
)
|
||||
)
|
||||
(local.get $$res)
|
||||
)
|
||||
|
||||
(func (export "fac-mixed-raw") (param $$n i64) (result i64)
|
||||
(local $$i i64)
|
||||
(local $$res i64)
|
||||
(local.set $$i (local.get $$n))
|
||||
(local.set $$res (i64.const 1))
|
||||
block $$done
|
||||
loop $$loop
|
||||
(i64.eq (local.get $$i) (i64.const 0))
|
||||
if
|
||||
br $$done
|
||||
else
|
||||
(i64.mul (local.get $$i) (local.get $$res))
|
||||
local.set $$res
|
||||
(i64.sub (local.get $$i) (i64.const 1))
|
||||
local.set $$i
|
||||
end
|
||||
br $$loop
|
||||
end
|
||||
end
|
||||
local.get $$res
|
||||
)
|
||||
)`);
|
||||
|
||||
// ./test/core/stack.wast:130
|
||||
assert_return(() => invoke($0, `fac-expr`, [25n]), [
|
||||
value("i64", 7034535277573963776n),
|
||||
]);
|
||||
|
||||
// ./test/core/stack.wast:131
|
||||
assert_return(() => invoke($0, `fac-stack`, [25n]), [
|
||||
value("i64", 7034535277573963776n),
|
||||
]);
|
||||
|
||||
// ./test/core/stack.wast:132
|
||||
assert_return(() => invoke($0, `fac-mixed`, [25n]), [
|
||||
value("i64", 7034535277573963776n),
|
||||
]);
|
||||
|
||||
// ./test/core/stack.wast:137
|
||||
let $1 = instantiate(`(module
|
||||
(type $$proc (func))
|
||||
(table 1 funcref)
|
||||
|
||||
(func
|
||||
(block i32.const 0 call_indirect)
|
||||
(loop i32.const 0 call_indirect)
|
||||
(if (i32.const 0) (then i32.const 0 call_indirect))
|
||||
(if (i32.const 0)
|
||||
(then i32.const 0 call_indirect)
|
||||
(else i32.const 0 call_indirect)
|
||||
)
|
||||
(block i32.const 0 call_indirect (type $$proc))
|
||||
(loop i32.const 0 call_indirect (type $$proc))
|
||||
(if (i32.const 0) (then i32.const 0 call_indirect (type $$proc)))
|
||||
(if (i32.const 0)
|
||||
(then i32.const 0 call_indirect (type $$proc))
|
||||
(else i32.const 0 call_indirect (type $$proc))
|
||||
)
|
||||
(block i32.const 0 i32.const 0 call_indirect (param i32))
|
||||
(loop i32.const 0 i32.const 0 call_indirect (param i32))
|
||||
(if (i32.const 0) (then i32.const 0 i32.const 0 call_indirect (param i32)))
|
||||
(if (i32.const 0)
|
||||
(then i32.const 0 i32.const 0 call_indirect (param i32))
|
||||
(else i32.const 0 i32.const 0 call_indirect (param i32))
|
||||
)
|
||||
(block (result i32) i32.const 0 call_indirect (result i32)) (drop)
|
||||
(loop (result i32) i32.const 0 call_indirect (result i32)) (drop)
|
||||
(if (result i32) (i32.const 0)
|
||||
(then i32.const 0 call_indirect (result i32))
|
||||
(else i32.const 0 call_indirect (result i32))
|
||||
) (drop)
|
||||
(block i32.const 0 call_indirect (type $$proc) (param) (result))
|
||||
(loop i32.const 0 call_indirect (type $$proc) (param) (result))
|
||||
(if (i32.const 0)
|
||||
(then i32.const 0 call_indirect (type $$proc) (param) (result))
|
||||
)
|
||||
(if (i32.const 0)
|
||||
(then i32.const 0 call_indirect (type $$proc) (param) (param) (result))
|
||||
(else i32.const 0 call_indirect (type $$proc) (param) (result) (result))
|
||||
)
|
||||
|
||||
block i32.const 0 call_indirect end
|
||||
loop i32.const 0 call_indirect end
|
||||
i32.const 0 if i32.const 0 call_indirect end
|
||||
i32.const 0 if i32.const 0 call_indirect else i32.const 0 call_indirect end
|
||||
block i32.const 0 call_indirect (type $$proc) end
|
||||
loop i32.const 0 call_indirect (type $$proc) end
|
||||
i32.const 0 if i32.const 0 call_indirect (type $$proc) end
|
||||
i32.const 0
|
||||
if
|
||||
i32.const 0 call_indirect (type $$proc)
|
||||
else
|
||||
i32.const 0 call_indirect (type $$proc)
|
||||
end
|
||||
block i32.const 0 i32.const 0 call_indirect (param i32) end
|
||||
loop i32.const 0 i32.const 0 call_indirect (param i32) end
|
||||
i32.const 0 if i32.const 0 i32.const 0 call_indirect (param i32) end
|
||||
i32.const 0
|
||||
if
|
||||
i32.const 0 i32.const 0 call_indirect (param i32)
|
||||
else
|
||||
i32.const 0 i32.const 0 call_indirect (param i32)
|
||||
end
|
||||
block (result i32) i32.const 0 call_indirect (result i32) end drop
|
||||
loop (result i32) i32.const 0 call_indirect (result i32) end drop
|
||||
i32.const 0
|
||||
if (result i32)
|
||||
i32.const 0 call_indirect (result i32)
|
||||
else
|
||||
i32.const 0 call_indirect (result i32)
|
||||
end drop
|
||||
block i32.const 0 call_indirect (type $$proc) (param) (result) end
|
||||
loop i32.const 0 call_indirect (type $$proc) (param) (result) end
|
||||
i32.const 0 if i32.const 0 call_indirect (type $$proc) (param) (result) end
|
||||
i32.const 0
|
||||
if
|
||||
i32.const 0 call_indirect (type $$proc) (param) (result)
|
||||
else
|
||||
i32.const 0 call_indirect (type $$proc) (param) (param) (result) (result)
|
||||
end
|
||||
i32.const 0 call_indirect
|
||||
)
|
||||
)`);
|
2304
js/src/jit-test/tests/wasm/spec/threads/utf8-import-field.wast.js
Normal file
2304
js/src/jit-test/tests/wasm/spec/threads/utf8-import-field.wast.js
Normal file
File diff suppressed because it is too large
Load Diff
2304
js/src/jit-test/tests/wasm/spec/threads/utf8-import-module.wast.js
Normal file
2304
js/src/jit-test/tests/wasm/spec/threads/utf8-import-module.wast.js
Normal file
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue
Block a user