Bug 829841 - Add an option to enable eager compilation in the browser. r=dvander

This commit is contained in:
Nicolas B. Pierron 2013-06-24 05:10:55 -07:00
parent 00d1add813
commit 9d5fdcde72
3 changed files with 49 additions and 1 deletions

View File

@ -968,10 +968,12 @@ static const char js_memlog_option_str[] = JS_OPTIONS_DOT_STR "mem.log";
static const char js_memnotify_option_str[] = JS_OPTIONS_DOT_STR "mem.notify";
static const char js_disable_explicit_compartment_gc[] =
JS_OPTIONS_DOT_STR "mem.disable_explicit_compartment_gc";
static const char js_asmjs_content_str[] = JS_OPTIONS_DOT_STR "asmjs";
static const char js_baselinejit_content_str[] = JS_OPTIONS_DOT_STR "baselinejit.content";
static const char js_baselinejit_chrome_str[] = JS_OPTIONS_DOT_STR "baselinejit.chrome";
static const char js_baselinejit_eager_str[] = JS_OPTIONS_DOT_STR "baselinejit.unsafe_eager_compilation";
static const char js_ion_content_str[] = JS_OPTIONS_DOT_STR "ion.content";
static const char js_asmjs_content_str[] = JS_OPTIONS_DOT_STR "asmjs";
static const char js_ion_eager_str[] = JS_OPTIONS_DOT_STR "ion.unsafe_eager_compilation";
static const char js_ion_parallel_compilation_str[] = JS_OPTIONS_DOT_STR "ion.parallel_compilation";
int
@ -1010,7 +1012,9 @@ nsJSContext::JSOptionChangedCallback(const char *pref, void *data)
bool useBaselineJIT = Preferences::GetBool(chromeWindow || !contentWindow ?
js_baselinejit_chrome_str :
js_baselinejit_content_str);
bool useBaselineJITEager = Preferences::GetBool(js_baselinejit_eager_str);
bool useIon = Preferences::GetBool(js_ion_content_str);
bool useIonEager = Preferences::GetBool(js_ion_eager_str);
bool useAsmJS = Preferences::GetBool(js_asmjs_content_str);
bool parallelIonCompilation = Preferences::GetBool(js_ion_parallel_compilation_str);
nsCOMPtr<nsIXULRuntime> xr = do_GetService(XULRUNTIME_SERVICE_CONTRACTID);
@ -1022,7 +1026,9 @@ nsJSContext::JSOptionChangedCallback(const char *pref, void *data)
useTypeInference = false;
useHardening = false;
useBaselineJIT = false;
useBaselineJITEager = false;
useIon = false;
useIonEager = false;
useAsmJS = false;
}
}
@ -1072,6 +1078,12 @@ nsJSContext::JSOptionChangedCallback(const char *pref, void *data)
::JS_SetParallelCompilationEnabled(context->mContext, parallelIonCompilation);
::JS_SetGlobalCompilerOption(context->mContext, JSCOMPILER_BASELINE_USECOUNT_TRIGGER,
(useBaselineJITEager ? 0 : -1));
::JS_SetGlobalCompilerOption(context->mContext, JSCOMPILER_ION_USECOUNT_TRIGGER,
(useIonEager ? 0 : -1));
// Save the new defaults for the next page load (InitContext).
context->mDefaultJSOptions = newDefaultJSOptions;

View File

@ -6993,6 +6993,33 @@ JS_SetParallelCompilationEnabled(JSContext *cx, bool enabled)
#endif
}
JS_PUBLIC_API(void)
JS_SetGlobalCompilerOption(JSContext *cx, JSCompilerOption opt, uint32_t value)
{
#ifdef JS_ION
ion::IonOptions defaultValues;
switch (opt) {
case JSCOMPILER_BASELINE_USECOUNT_TRIGGER:
if (value == uint32_t(-1))
value = defaultValues.baselineUsesBeforeCompile;
ion::js_IonOptions.baselineUsesBeforeCompile = value;
break;
case JSCOMPILER_ION_USECOUNT_TRIGGER:
if (value == uint32_t(-1))
value = defaultValues.usesBeforeCompile;
ion::js_IonOptions.usesBeforeCompile = value;
ion::js_IonOptions.eagerCompilation = (value == 0);
break;
case JSCOMPILER_PJS_ENABLE:
if (value == uint32_t(-1))
value = uint32_t(defaultValues.parallelCompilation);
ion::js_IonOptions.parallelCompilation = bool(value);
break;
}
#endif
}
/************************************************************************/
#if !defined(STATIC_EXPORTABLE_JS_API) && !defined(STATIC_JS_API) && defined(XP_WIN)

View File

@ -4999,6 +4999,15 @@ JS_ScheduleGC(JSContext *cx, uint32_t count);
extern JS_PUBLIC_API(void)
JS_SetParallelCompilationEnabled(JSContext *cx, bool enabled);
typedef enum JSCompilerOption {
JSCOMPILER_BASELINE_USECOUNT_TRIGGER,
JSCOMPILER_ION_USECOUNT_TRIGGER,
JSCOMPILER_PJS_ENABLE
} JSCompilerOption;
extern JS_PUBLIC_API(void)
JS_SetGlobalCompilerOption(JSContext *cx, JSCompilerOption opt, uint32_t value);
/*
* Convert a uint32_t index into a jsid.
*/