summaryrefslogtreecommitdiff
path: root/deps/v8/test/mjsunit/wasm/origin-trial-flags.js
diff options
context:
space:
mode:
Diffstat (limited to 'deps/v8/test/mjsunit/wasm/origin-trial-flags.js')
-rw-r--r--deps/v8/test/mjsunit/wasm/origin-trial-flags.js46
1 files changed, 46 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 0000000000..46363e1747
--- /dev/null
+++ b/deps/v8/test/mjsunit/wasm/origin-trial-flags.js
@@ -0,0 +1,46 @@
+// Copyright 2023 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-gc --no-experimental-wasm-stringref
+// Flags: --allow-natives-syntax
+
+load("test/mjsunit/wasm/wasm-module-builder.js");
+
+function instantiateModuleWithGC() {
+ // Build a WebAssembly module which uses Wasm GC features.
+ const builder = new WasmModuleBuilder();
+ builder.addFunction('main', makeSig([], [kWasmAnyRef]))
+ .addBody([
+ kExprI32Const, 42,
+ kGCPrefix, kExprI31New,
+ ])
+ .exportFunc();
+
+ return builder.instantiate();
+}
+
+function instantiateModuleWithStringRef() {
+ // Build a WebAssembly module which uses stringref features.
+ const builder = new WasmModuleBuilder();
+ builder.addFunction("main",
+ makeSig([kWasmStringRef], [kWasmStringRef]))
+ .addBody([kExprLocalGet, 0])
+ .exportFunc();
+ return builder.instantiate();
+}
+
+// Due to --noexperimental-wasm-gc GC is disabled.
+assertThrows(instantiateModuleWithGC, WebAssembly.CompileError);
+// Due to --noexperimental-wasm-stringref stringrefs are not supported.
+assertThrows(instantiateModuleWithStringRef, WebAssembly.CompileError);
+// Disable WebAssembly GC explicitly.
+%SetWasmGCEnabled(false);
+assertThrows(instantiateModuleWithGC, WebAssembly.CompileError);
+assertThrows(instantiateModuleWithStringRef, WebAssembly.CompileError);
+// Enable WebAssembly GC explicitly.
+%SetWasmGCEnabled(true);
+assertEquals(42, instantiateModuleWithGC().exports.main());
+// Enabling Wasm GC via callback will also enable wasm stringref.
+let str = "Hello World!";
+assertSame(str, instantiateModuleWithStringRef().exports.main(str));