Bug 700822: Add javascript.options.jit_hardening pref, default enabled. (r=dmandelin)

This commit is contained in:
Chris Leary 2011-11-08 13:28:49 -08:00
parent 595d492eed
commit a4908dc54a
5 changed files with 13 additions and 1 deletions

View File

@ -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);

View File

@ -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<nsIXULRuntime> 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

View File

@ -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)

View File

@ -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();

View File

@ -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,