-
Notifications
You must be signed in to change notification settings - Fork 54
Expand file tree
/
Copy pathwait-notify-unshared.any.js
More file actions
34 lines (32 loc) · 1.24 KB
/
wait-notify-unshared.any.js
File metadata and controls
34 lines (32 loc) · 1.24 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
// META: global=window,dedicatedworker,jsshell
// META: script=/wasm/jsapi/wasm-module-builder.js
test(() => {
const builder = new WasmModuleBuilder();
builder.addMemory(1, 1, false, false);
builder.addFunction('notify', kSig_i_ii)
.addBody([
kExprLocalGet, 0, kExprLocalGet, 1, kAtomicPrefix, kExprAtomicNotify, 2,
0
])
.exportFunc();
const instance = builder.instantiate();
const result = instance.exports.notify(0, 1);
assert_equals(result, 0, 'Notify on unshared memory should return 0');
}, 'Notify on unshared memory');
test(() => {
const builder = new WasmModuleBuilder();
builder.addMemory(1, 1, false, false);
const kSig_i_iil = makeSig([kWasmI32, kWasmI32, kWasmI64], [kWasmI32]);
builder.addFunction('wait', kSig_i_iil)
.addBody([
kExprLocalGet, 0, kExprLocalGet, 1, kExprLocalGet, 2, kAtomicPrefix,
kExprI32AtomicWait, 2, 0
])
.exportFunc();
const instance = builder.instantiate();
// This should trap. We use a non-infinite timeout to avoid hanging if the
// trap is not implemented.
assert_throws_js(
WebAssembly.RuntimeError, () => instance.exports.wait(0, 0, 1000n),
'Wait on unshared memory should trap');
}, 'Wait on unshared memory traps');