diff --git a/build/automation.py.in b/build/automation.py.in index ce30cd9a644e..ad35c6892c6a 100644 --- a/build/automation.py.in +++ b/build/automation.py.in @@ -418,6 +418,7 @@ user_pref("javascript.options.showInConsole", true); user_pref("devtools.errorconsole.enabled", true); user_pref("layout.debug.enable_data_xbl", true); user_pref("browser.EULA.override", true); +user_pref("javascript.options.jit_hardening", true); user_pref("gfx.color_management.force_srgb", true); user_pref("network.manage-offline-status", false); user_pref("test.mousescroll", true); diff --git a/dom/base/nsJSEnvironment.cpp b/dom/base/nsJSEnvironment.cpp index f60ff12eb10f..409393fe6c24 100644 --- a/dom/base/nsJSEnvironment.cpp +++ b/dom/base/nsJSEnvironment.cpp @@ -937,6 +937,7 @@ static const char js_methodjit_always_str[] = JS_OPTIONS_DOT_STR "methodjit_al static const char js_typeinfer_str[] = JS_OPTIONS_DOT_STR "typeinference"; static const char js_pccounts_content_str[] = JS_OPTIONS_DOT_STR "pccounts.content"; static const char js_pccounts_chrome_str[] = JS_OPTIONS_DOT_STR "pccounts.chrome"; +static const char js_jit_hardening_str[] = JS_OPTIONS_DOT_STR "jit_hardening"; static const char js_memlog_option_str[] = JS_OPTIONS_DOT_STR "mem.log"; int @@ -973,6 +974,7 @@ nsJSContext::JSOptionChangedCallback(const char *pref, void *data) js_pccounts_content_str); bool useMethodJITAlways = Preferences::GetBool(js_methodjit_always_str); bool useTypeInference = !chromeWindow && Preferences::GetBool(js_typeinfer_str); + bool useHardening = Preferences::GetBool(js_jit_hardening_str); nsCOMPtr xr = do_GetService(XULRUNTIME_SERVICE_CONTRACTID); if (xr) { bool safeMode = false; @@ -984,6 +986,7 @@ nsJSContext::JSOptionChangedCallback(const char *pref, void *data) usePCCounts = false; useTypeInference = false; useMethodJITAlways = true; + useHardening = false; } } @@ -1012,6 +1015,11 @@ nsJSContext::JSOptionChangedCallback(const char *pref, void *data) else newDefaultJSOptions &= ~JSOPTION_METHODJIT_ALWAYS; + if (useHardening) + newDefaultJSOptions &= ~JSOPTION_SOFTEN; + else + newDefaultJSOptions |= JSOPTION_SOFTEN; + if (useTypeInference) newDefaultJSOptions |= JSOPTION_TYPE_INFERENCE; else diff --git a/js/src/jsapi.h b/js/src/jsapi.h index fd03c0f683e8..35a98febd641 100644 --- a/js/src/jsapi.h +++ b/js/src/jsapi.h @@ -2177,11 +2177,12 @@ JS_StringToVersion(const char *string); #define JSOPTION_PCCOUNT JS_BIT(17) /* Collect per-op execution counts */ #define JSOPTION_TYPE_INFERENCE JS_BIT(18) /* Perform type inference. */ +#define JSOPTION_SOFTEN JS_BIT(19) /* Disable JIT hardening. */ /* Options which reflect compile-time properties of scripts. */ #define JSCOMPILEOPTION_MASK (JSOPTION_XML) -#define JSRUNOPTION_MASK (JS_BITMASK(19) & ~JSCOMPILEOPTION_MASK) +#define JSRUNOPTION_MASK (JS_BITMASK(20) & ~JSCOMPILEOPTION_MASK) #define JSALLOPTION_MASK (JSCOMPILEOPTION_MASK | JSRUNOPTION_MASK) extern JS_PUBLIC_API(uint32) diff --git a/js/src/jscntxt.h b/js/src/jscntxt.h index 6570c0d19556..b0c4878b6bbf 100644 --- a/js/src/jscntxt.h +++ b/js/src/jscntxt.h @@ -1127,6 +1127,7 @@ struct JSContext bool hasStrictOption() const { return hasRunOption(JSOPTION_STRICT); } bool hasWErrorOption() const { return hasRunOption(JSOPTION_WERROR); } bool hasAtLineOption() const { return hasRunOption(JSOPTION_ATLINE); } + bool hasJITHardeningOption() const { return !hasRunOption(JSOPTION_SOFTEN); } js::LifoAlloc &tempLifoAlloc() { return JS_THREAD_DATA(this)->tempLifoAlloc; } inline js::LifoAlloc &typeLifoAlloc(); diff --git a/modules/libpref/src/init/all.js b/modules/libpref/src/init/all.js index 40b65b03717d..22d65a43ad80 100644 --- a/modules/libpref/src/init/all.js +++ b/modules/libpref/src/init/all.js @@ -635,6 +635,7 @@ pref("javascript.options.jitprofiling.chrome", true); pref("javascript.options.pccounts.content", false); pref("javascript.options.pccounts.chrome", false); pref("javascript.options.methodjit_always", false); +pref("javascript.options.jit_hardening", true); pref("javascript.options.typeinference", true); // This preference limits the memory usage of javascript. // If you want to change these values for your device,