Bug 1620986 - Introduce run-time switch for multi-value. r=bbouvier,wingo

This adds a JS shell command line argument to disable multi-value (if
it is enabled at compile time) and an about:config option to do the
same in the browser.

At this time, multi-values are not enabled in the browser, so the
about:config option is not visible.

Differential Revision: https://phabricator.services.mozilla.com/D67465

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Lars T Hansen 2020-03-20 10:58:07 +00:00
parent d69ed85444
commit 93f9148960
7 changed files with 47 additions and 1 deletions

View File

@ -26,6 +26,7 @@ class JS_PUBLIC_API ContextOptions {
wasmIon_(true),
wasmCranelift_(false),
wasmGc_(false),
wasmMultiValue_(false),
testWasmAwaitTier2_(false),
#ifdef ENABLE_WASM_BIGINT
enableWasmBigInt_(true),
@ -110,6 +111,10 @@ class JS_PUBLIC_API ContextOptions {
// Defined out-of-line because it depends on a compile-time option
ContextOptions& setWasmGc(bool flag);
bool wasmMultiValue() const { return wasmMultiValue_; }
// Defined out-of-line because it depends on a compile-time option
ContextOptions& setWasmMultiValue(bool flag);
bool throwOnAsmJSValidationFailure() const {
return throwOnAsmJSValidationFailure_;
}
@ -197,6 +202,7 @@ class JS_PUBLIC_API ContextOptions {
setWasmBaseline(false);
setWasmIon(false);
setWasmGc(false);
setWasmMultiValue(false);
}
private:
@ -208,6 +214,7 @@ class JS_PUBLIC_API ContextOptions {
bool wasmIon_ : 1;
bool wasmCranelift_ : 1;
bool wasmGc_ : 1;
bool wasmMultiValue_ : 1;
bool testWasmAwaitTier2_ : 1;
#ifdef ENABLE_WASM_BIGINT
bool enableWasmBigInt_ : 1;

View File

@ -428,6 +428,13 @@ JS::ContextOptions& JS::ContextOptions::setWasmGc(bool flag) {
return *this;
}
JS::ContextOptions& JS::ContextOptions::setWasmMultiValue(bool flag) {
#ifdef ENABLE_WASM_MULTI_VALUE
wasmMultiValue_ = flag;
#endif
return *this;
}
JS::ContextOptions& JS::ContextOptions::setFuzzing(bool flag) {
#ifdef FUZZING
fuzzing_ = flag;

View File

@ -493,6 +493,9 @@ bool shell::enableWasmCranelift = false;
#ifdef ENABLE_WASM_GC
bool shell::enableWasmGc = false;
#endif
#ifdef ENABLE_WASM_MULTI_VALUE
bool shell::enableWasmMultiValue = true;
#endif
bool shell::enableWasmVerbose = false;
bool shell::enableTestWasmAwaitTier2 = false;
#ifdef ENABLE_WASM_BIGINT
@ -10347,6 +10350,9 @@ static bool SetContextOptions(JSContext* cx, const OptionParser& op) {
#ifdef ENABLE_WASM_GC
enableWasmGc = op.getBoolOption("wasm-gc");
#endif
#ifdef ENABLE_WASM_MULTI_VALUE
enableWasmMultiValue = !op.getBoolOption("no-wasm-multi-value");
#endif
enableWasmVerbose = op.getBoolOption("wasm-verbose");
enableTestWasmAwaitTier2 = op.getBoolOption("test-wasm-await-tier2");
@ -10375,6 +10381,9 @@ static bool SetContextOptions(JSContext* cx, const OptionParser& op) {
#endif
#ifdef ENABLE_WASM_GC
.setWasmGc(enableWasmGc)
#endif
#ifdef ENABLE_WASM_MULTI_VALUE
.setWasmMultiValue(enableWasmMultiValue)
#endif
.setWasmVerbose(enableWasmVerbose)
.setTestWasmAwaitTier2(enableTestWasmAwaitTier2)
@ -10721,6 +10730,9 @@ static void SetWorkerContextOptions(JSContext* cx) {
#ifdef ENABLE_WASM_GC
.setWasmGc(enableWasmGc)
#endif
#ifdef ENABLE_WASM_MULTI_VALUE
.setWasmMultiValue(enableWasmMultiValue)
#endif
#ifdef ENABLE_WASM_BIGINT
.setWasmBigIntEnabled(enableWasmBigInt)
#endif
@ -11152,6 +11164,13 @@ int main(int argc, char** argv, char** envp) {
#else
!op.addBoolOption('\0', "wasm-gc", "No-op") ||
#endif
#ifdef ENABLE_WASM_MULTI_VALUE
!op.addBoolOption('\0', "no-wasm-multi-value",
"Disable wasm multi-value features") ||
#else
!op.addBoolOption('\0', "no-wasm-multi-value", "No-op") ||
#endif
!op.addBoolOption('\0', "no-native-regexp",
"Disable native regexp compilation") ||
!op.addBoolOption('\0', "no-unboxed-objects",

View File

@ -110,6 +110,9 @@ extern bool enableWasmCranelift;
#ifdef ENABLE_WASM_GC
extern bool enableWasmGc;
#endif
#ifdef ENABLE_WASM_MULTI_VALUE
extern bool enableWasmMultiValue;
#endif
extern bool enableWasmVerbose;
extern bool enableTestWasmAwaitTier2;
#ifdef ENABLE_WASM_BIGINT

View File

@ -67,7 +67,7 @@ extern mozilla::Atomic<bool> fuzzingSafe;
static inline bool WasmMultiValueFlag(JSContext* cx) {
#ifdef ENABLE_WASM_MULTI_VALUE
return true;
return cx->options().wasmMultiValue();
#else
return false;
#endif

View File

@ -910,6 +910,10 @@ static void ReloadPrefsCallback(const char* pref, void* aXpccx) {
#endif
#ifdef ENABLE_WASM_GC
bool useWasmGc = Preferences::GetBool(JS_OPTIONS_DOT_STR "wasm_gc");
#endif
#ifdef ENABLE_WASM_MULTI_VALUE
bool useWasmMultiValue =
Preferences::GetBool(JS_OPTIONS_DOT_STR "wasm_multi_value");
#endif
bool useWasmVerbose = Preferences::GetBool(JS_OPTIONS_DOT_STR "wasm_verbose");
bool throwOnAsmJSValidationFailure = Preferences::GetBool(
@ -966,6 +970,9 @@ static void ReloadPrefsCallback(const char* pref, void* aXpccx) {
#endif
#ifdef ENABLE_WASM_GC
.setWasmGc(useWasmGc)
#endif
#ifdef ENABLE_WASM_MULTI_VALUE
.setWasmMultiValue(useWasmMultiValue)
#endif
.setWasmVerbose(useWasmVerbose)
.setThrowOnAsmJSValidationFailure(throwOnAsmJSValidationFailure)

View File

@ -1121,6 +1121,9 @@ pref("javascript.options.wasm_baselinejit", true);
#ifdef ENABLE_WASM_REFTYPES
pref("javascript.options.wasm_gc", false);
#endif
#ifdef ENABLE_WASM_MULTI_VALUE
pref("javascript.options.wasm_multi_value", true);
#endif
pref("javascript.options.native_regexp", true);
pref("javascript.options.parallel_parsing", true);
// Async stacks instrumentation adds overhead that is only