Bug 1824772: part 1 - Add jit option and static pref to toggle eager baseline hints. r=iain

Add a pref, javascript.options.jitHints, to toggle eager baseline hints.

Differential Revision: https://phabricator.services.mozilla.com/D175521
This commit is contained in:
Denis Palmeiro 2023-04-21 15:27:15 +00:00
parent 913bc955ca
commit d19bd78ea6
7 changed files with 28 additions and 0 deletions

View File

@ -179,6 +179,9 @@ DefaultJitOptions::DefaultJitOptions() {
// Duplicated in all.js - ensure both match.
SET_DEFAULT(baselineJitWarmUpThreshold, 100);
// Disable eager baseline jit hints
SET_DEFAULT(disableJitHints, false);
// How many invocations or loop iterations are needed before functions
// are considered for trial inlining.
SET_DEFAULT(trialInliningWarmUpThreshold, 500);

View File

@ -45,6 +45,7 @@ struct DefaultJitOptions {
bool checkRangeAnalysis;
bool runExtraChecks;
bool disableJitBackend;
bool disableJitHints;
bool disableAma;
bool disableEaa;
bool disableEdgeCaseAnalysis;

View File

@ -4183,6 +4183,9 @@ JS_PUBLIC_API void JS_SetGlobalJitCompilerOption(JSContext* cx,
case JSJITCOMPILER_NATIVE_REGEXP_ENABLE:
jit::JitOptions.nativeRegExp = !!value;
break;
case JSJITCOMPILER_JIT_HINTS_ENABLE:
jit::JitOptions.disableJitHints = !value;
break;
case JSJITCOMPILER_OFFTHREAD_COMPILATION_ENABLE:
if (value == 1) {
rt->setOffthreadIonCompilationEnabled(true);

View File

@ -829,6 +829,7 @@ extern JS_PUBLIC_API void JS_SetOffthreadIonCompilationEnabled(JSContext* cx,
Register(FULL_DEBUG_CHECKS, "jit.full-debug-checks") \
Register(JUMP_THRESHOLD, "jump-threshold") \
Register(NATIVE_REGEXP_ENABLE, "native_regexp.enable") \
Register(JIT_HINTS_ENABLE, "jitHints.enable") \
Register(SIMULATOR_ALWAYS_INTERRUPT, "simulator.always-interrupt") \
Register(SPECTRE_INDEX_MASKING, "spectre.index-masking") \
Register(SPECTRE_OBJECT_MITIGATIONS, "spectre.object-mitigations") \

View File

@ -11555,6 +11555,8 @@ bool InitOptionParser(OptionParser& op) {
!op.addBoolOption('\0', "blinterp",
"Enable Baseline Interpreter (default)") ||
!op.addBoolOption('\0', "no-blinterp", "Disable Baseline Interpreter") ||
!op.addBoolOption('\0', "disable-jithints",
"Disable caching eager baseline compilation hints.") ||
!op.addBoolOption(
'\0', "emit-interpreter-entry",
"Emit Interpreter entry trampolines (default under --enable-perf)") ||
@ -12349,6 +12351,10 @@ bool SetContextJITOptions(JSContext* cx, const OptionParser& op) {
jit::JitOptions.baselineInterpreter = false;
}
if (op.getBoolOption("disable-jithints")) {
jit::JitOptions.disableJitHints = true;
}
if (op.getBoolOption("emit-interpreter-entry")) {
jit::JitOptions.emitInterpreterEntryTrampoline = true;
}

View File

@ -895,6 +895,7 @@ static void LoadStartupJSPrefs(XPCJSContext* xpccx) {
cx, JSJITCOMPILER_JIT_TRUSTEDPRINCIPALS_ENABLE, false);
JS_SetGlobalJitCompilerOption(cx, JSJITCOMPILER_NATIVE_REGEXP_ENABLE,
false);
JS_SetGlobalJitCompilerOption(cx, JSJITCOMPILER_JIT_HINTS_ENABLE, false);
sSelfHostedUseSharedMemory = false;
} else {
JS_SetGlobalJitCompilerOption(
@ -909,6 +910,11 @@ static void LoadStartupJSPrefs(XPCJSContext* xpccx) {
JS_SetGlobalJitCompilerOption(
cx, JSJITCOMPILER_NATIVE_REGEXP_ENABLE,
StaticPrefs::javascript_options_native_regexp_DoNotUseDirectly());
JS_SetGlobalJitCompilerOption(
cx, JSJITCOMPILER_JIT_HINTS_ENABLE,
XRE_IsContentProcess()
? StaticPrefs::javascript_options_jitHints_DoNotUseDirectly()
: false);
sSelfHostedUseSharedMemory = StaticPrefs::
javascript_options_self_hosted_use_shared_memory_DoNotUseDirectly();
}

View File

@ -7470,6 +7470,14 @@
mirror: always # LoadStartupJSPrefs
do_not_use_directly: true
# Jit Hints Cache - An in-process cache to
# accelerate repeated baseline compilations
- name: javascript.options.jitHints
type: bool
value: true
mirror: always # LoadStartupJSPrefs
do_not_use_directly: true
# "Warm-up" thresholds at which we attempt to compile a script/function with
# the next JIT tier.
#