Bug 1577757 - Add a compile-time option for wasm multi-value r=luke
☠☠ backed out by e3a5836b677a ☠ ☠
authorAndy Wingo <wingo@igalia.com>
Fri, 20 Sep 2019 07:53:50 +0000
changeset 494256 9a94f14b419211d487168aea11ffc0fc3bcef149
parent 494255 f63bec9d338547074c12913e5bcf8b2c50ceff9f
child 494257 fe49a3616f91ec154b6db215a7ff0240d4872a15
push id114114
push userdluca@mozilla.com
push dateFri, 20 Sep 2019 22:00:08 +0000
treeherdermozilla-inbound@56e11fddf939 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersluke
bugs1577757
milestone71.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1577757 - Add a compile-time option for wasm multi-value r=luke Differential Revision: https://phabricator.services.mozilla.com/D44142
js/moz.configure
js/src/builtin/TestingFunctions.cpp
js/src/jit-test/tests/wasm/binary.js
js/src/wasm/WasmJS.cpp
js/src/wasm/WasmJS.h
--- a/js/moz.configure
+++ b/js/moz.configure
@@ -544,8 +544,24 @@ def default_wasm_private_reftypes(is_nig
         return True
 
 js_option('--enable-wasm-private-reftypes',
           default=default_wasm_private_reftypes,
           help='{Enable|Disable} WebAssembly private reference types')
 
 set_config('WASM_PRIVATE_REFTYPES', depends_if('--enable-wasm-private-reftypes')(lambda x: True))
 set_define('WASM_PRIVATE_REFTYPES', depends_if('--enable-wasm-private-reftypes')(lambda x: True))
+
+
+# Support for the WebAssembly multi-value proposal.
+# =====================================================
+
+@depends(milestone.is_nightly)
+def default_wasm_multi_value(is_nightly):
+    return False
+
+js_option('--enable-wasm-multi-value',
+          default=default_wasm_multi_value,
+          help='{Enable|Disable} support for the experimental WebAssembly '
+               'multi-value proposal')
+
+set_config('ENABLE_WASM_MULTI_VALUE', depends_if('--enable-wasm-multi-value')(lambda x: True))
+set_define('ENABLE_WASM_MULTI_VALUE', depends_if('--enable-wasm-multi-value')(lambda x: True))
--- a/js/src/builtin/TestingFunctions.cpp
+++ b/js/src/builtin/TestingFunctions.cpp
@@ -772,16 +772,22 @@ static bool WasmReftypesEnabled(JSContex
 }
 
 static bool WasmGcEnabled(JSContext* cx, unsigned argc, Value* vp) {
   CallArgs args = CallArgsFromVp(argc, vp);
   args.rval().setBoolean(wasm::HasGcSupport(cx));
   return true;
 }
 
+static bool WasmMultiValueEnabled(JSContext* cx, unsigned argc, Value* vp) {
+  CallArgs args = CallArgsFromVp(argc, vp);
+  args.rval().setBoolean(wasm::HasMultiValueSupport(cx));
+  return true;
+}
+
 static bool WasmDebugSupport(JSContext* cx, unsigned argc, Value* vp) {
   CallArgs args = CallArgsFromVp(argc, vp);
   args.rval().setBoolean(cx->options().wasmBaseline() &&
                          wasm::BaselineCanCompile());
   return true;
 }
 
 static bool WasmCompileMode(JSContext* cx, unsigned argc, Value* vp) {
@@ -6564,16 +6570,20 @@ gc::ZealModeHelpText),
     JS_FN_HELP("wasmReftypesEnabled", WasmReftypesEnabled, 1, 0,
 "wasmReftypesEnabled()",
 "  Returns a boolean indicating whether the WebAssembly reftypes proposal is enabled."),
 
     JS_FN_HELP("wasmGcEnabled", WasmGcEnabled, 1, 0,
 "wasmGcEnabled()",
 "  Returns a boolean indicating whether the WebAssembly GC types proposal is enabled."),
 
+    JS_FN_HELP("wasmMultiValueEnabled", WasmMultiValueEnabled, 1, 0,
+"wasmMultiValueEnabled()",
+"  Returns a boolean indicating whether the WebAssembly multi-value proposal is enabled."),
+
     JS_FN_HELP("wasmDebugSupport", WasmDebugSupport, 1, 0,
 "wasmDebugSupport()",
 "  Returns a boolean indicating whether the WebAssembly compilers support debugging."),
 
     JS_FN_HELP("isLazyFunction", IsLazyFunction, 1, 0,
 "isLazyFunction(fun)",
 "  True if fun is a lazy JSFunction."),
 
--- a/js/src/jit-test/tests/wasm/binary.js
+++ b/js/src/jit-test/tests/wasm/binary.js
@@ -227,17 +227,17 @@ assertErrorMessage(() => wasmEval(module
     declSection([0]),
     exportSection([{funcIndex: 0, name: "f"}]),
     bodySection([funcBody({locals:[], body:[UnreachableCode]})]),
     nameSection([moduleNameSubsection('hi')])])
 ).f(), RuntimeError, /unreachable/);
 
 // Diagnose nonstandard block signature types.
 for (var bad of [0xff, 0, 1, 0x3f])
-    assertErrorMessage(() => wasmEval(moduleWithSections([sigSection([v2vSig]), declSection([0]), bodySection([funcBody({locals:[], body:[BlockCode, bad, EndCode]})])])), CompileError, /invalid inline block type/);
+    assertErrorMessage(() => wasmEval(moduleWithSections([sigSection([v2vSig]), declSection([0]), bodySection([funcBody({locals:[], body:[BlockCode, bad, EndCode]})])])), CompileError, /invalid .*block type/);
 
 // Ensure all invalid opcodes rejected
 for (let op of undefinedOpcodes) {
     let binary = moduleWithSections([v2vSigSection, declSection([0]), bodySection([funcBody({locals:[], body:[op]})])]);
     assertErrorMessage(() => wasmEval(binary), CompileError, /unrecognized opcode/);
     assertEq(WebAssembly.validate(binary), false);
 }
 
--- a/js/src/wasm/WasmJS.cpp
+++ b/js/src/wasm/WasmJS.cpp
@@ -81,16 +81,29 @@ bool wasm::HasGcSupport(JSContext* cx) {
 #endif
 #ifdef ENABLE_WASM_GC
   return cx->options().wasmGc() && cx->options().wasmBaseline();
 #else
   return false;
 #endif
 }
 
+bool wasm::HasMultiValueSupport(JSContext* cx) {
+#ifdef ENABLE_WASM_CRANELIFT
+  if (cx->options().wasmCranelift()) {
+    return false;
+  }
+#endif
+#ifdef ENABLE_WASM_MULTI_VALUE
+  return true;
+#else
+  return false;
+#endif
+}
+
 bool wasm::HasCompilerSupport(JSContext* cx) {
 #if !MOZ_LITTLE_ENDIAN || defined(JS_CODEGEN_NONE)
   return false;
 #endif
 
   if (gc::SystemPageSize() > wasm::PageSize) {
     return false;
   }
--- a/js/src/wasm/WasmJS.h
+++ b/js/src/wasm/WasmJS.h
@@ -64,16 +64,21 @@ bool HasCachingSupport(JSContext* cx);
 
 bool HasReftypesSupport(JSContext* cx);
 
 // Returns true if WebAssembly as configured by compile-time flags and run-time
 // options can support (ref T) types and structure types, etc (evolving).
 
 bool HasGcSupport(JSContext* cx);
 
+// Returns true if WebAssembly as configured by compile-time flags and run-time
+// options can support multi-value block and function returns (evolving).
+
+bool HasMultiValueSupport(JSContext* cx);
+
 // Compiles the given binary wasm module given the ArrayBufferObject
 // and links the module's imports with the given import object.
 
 MOZ_MUST_USE bool Eval(JSContext* cx, Handle<TypedArrayObject*> code,
                        HandleObject importObj,
                        MutableHandleWasmInstanceObject instanceObj);
 
 // Extracts the various imports from the given import object into the given