diff options
Diffstat (limited to 'deps/v8/test/mjsunit/wasm/origin-trial-flags.js')
-rw-r--r-- | deps/v8/test/mjsunit/wasm/origin-trial-flags.js | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/deps/v8/test/mjsunit/wasm/origin-trial-flags.js b/deps/v8/test/mjsunit/wasm/origin-trial-flags.js new file mode 100644 index 00000000000..d41f581e134 --- /dev/null +++ b/deps/v8/test/mjsunit/wasm/origin-trial-flags.js @@ -0,0 +1,35 @@ +// Copyright 2017 the V8 project authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +// Flags: --noexperimental-wasm-threads --allow-natives-syntax + +load("test/mjsunit/wasm/wasm-constants.js"); +load("test/mjsunit/wasm/wasm-module-builder.js"); + +function instantiateModuleWithThreads() { + // Build a WebAssembly module which uses threads-features. + const builder = new WasmModuleBuilder(); + const shared = true; + builder.addMemory(2, 10, false, shared); + builder.addFunction('main', kSig_i_ii) + .addBody([ + kExprGetLocal, 0, kExprGetLocal, 1, kAtomicPrefix, kExprI32AtomicAdd, 2, + 0 + ]) + .exportFunc(); + + return builder.instantiate(); +} + +// Disable WebAssembly threads initially. +%SetWasmThreadsEnabled(false); +assertThrows(instantiateModuleWithThreads, WebAssembly.CompileError); + +// Enable WebAssembly threads. +%SetWasmThreadsEnabled(true); +assertInstanceof(instantiateModuleWithThreads(), WebAssembly.Instance); + +// Disable WebAssembly threads. +%SetWasmThreadsEnabled(false); +assertThrows(instantiateModuleWithThreads, WebAssembly.CompileError); |