summaryrefslogtreecommitdiff
path: root/deps/v8/test/mjsunit/wasm/atomics.js
diff options
context:
space:
mode:
Diffstat (limited to 'deps/v8/test/mjsunit/wasm/atomics.js')
-rw-r--r--deps/v8/test/mjsunit/wasm/atomics.js30
1 files changed, 30 insertions, 0 deletions
diff --git a/deps/v8/test/mjsunit/wasm/atomics.js b/deps/v8/test/mjsunit/wasm/atomics.js
index 58d3d950d5..371839ae24 100644
--- a/deps/v8/test/mjsunit/wasm/atomics.js
+++ b/deps/v8/test/mjsunit/wasm/atomics.js
@@ -432,3 +432,33 @@ function TestStore(func, buffer, value, size) {
assertThrows(() => GetAtomicBinOpFunction(kExprI32AtomicSub16U, 3, 0),
WebAssembly.CompileError);
})();
+
+function CmpExchgLoop(opcode, alignment) {
+ print("TestI64AtomicCompareExchangeLoop" + alignment);
+ let builder = new WasmModuleBuilder();
+ builder.addImportedMemory("m", "imported_mem", 0, 2, "shared");
+ builder.addFunction("main", makeSig([kWasmI32], []))
+ .addLocals({i64_count: 2})
+ .addBody([
+ kExprLoop, kWasmStmt,
+ kExprGetLocal, 0,
+ kExprGetLocal, 1,
+ kExprGetLocal, 2,
+ kAtomicPrefix, opcode, alignment, 0,
+ kExprGetLocal, 1,
+ kExprI64Ne,
+ kExprBrIf, 0,
+ kExprEnd
+ ])
+ .exportFunc();
+ let mem = new WebAssembly.Memory({initial: 2, maximum: 2, shared: true});
+ let module = new WebAssembly.Module(builder.toBuffer());
+ let instance = new WebAssembly.Instance(module, {m: {imported_mem: mem}});
+}
+
+(function TestAtomicCompareExchgLoop() {
+ CmpExchgLoop(kExprI64AtomicCompareExchange, 3);
+ CmpExchgLoop(kExprI64AtomicCompareExchange32U, 2);
+ CmpExchgLoop(kExprI64AtomicCompareExchange16U, 1);
+ CmpExchgLoop(kExprI64AtomicCompareExchange8U, 0);
+})();