Bug 1382650 part 4 - Split Ion warmup threshold JitOption in 'normal' and 'full' options. r=nbp

Also adds a javascript.options.ion.full.threshold browser pref and similar shell
flags.

This doesn't rename the existing prefs yet.

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

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Jan de Mooij 2019-03-27 18:57:58 +00:00
Родитель 094a569b9d
Коммит 3ad6efea42
8 изменённых файлов: 72 добавлений и 15 удалений

Просмотреть файл

@ -158,6 +158,11 @@ DefaultJitOptions::DefaultJitOptions() {
// Duplicated in all.js - ensure both match. // Duplicated in all.js - ensure both match.
SET_DEFAULT(normalIonWarmUpThreshold, 1000); SET_DEFAULT(normalIonWarmUpThreshold, 1000);
// How many invocations or loop iterations are needed before functions
// are compiled with the Ion compiler at OptimizationLevel::Full.
// Duplicated in all.js - ensure both match.
SET_DEFAULT(fullIonWarmUpThreshold, 100'000);
// Number of exception bailouts (resuming into catch/finally block) before // Number of exception bailouts (resuming into catch/finally block) before
// we invalidate and forbid Ion compilation. // we invalidate and forbid Ion compilation.
SET_DEFAULT(exceptionBailoutThreshold, 10); SET_DEFAULT(exceptionBailoutThreshold, 10);
@ -264,15 +269,33 @@ void DefaultJitOptions::enableGvn(bool enable) { disableGvn = !enable; }
void DefaultJitOptions::setEagerIonCompilation() { void DefaultJitOptions::setEagerIonCompilation() {
baselineWarmUpThreshold = 0; baselineWarmUpThreshold = 0;
normalIonWarmUpThreshold = 0; normalIonWarmUpThreshold = 0;
fullIonWarmUpThreshold = 0;
} }
void DefaultJitOptions::setCompilerWarmUpThreshold(uint32_t warmUpThreshold) { void DefaultJitOptions::setNormalIonWarmUpThreshold(uint32_t warmUpThreshold) {
normalIonWarmUpThreshold = warmUpThreshold; normalIonWarmUpThreshold = warmUpThreshold;
if (fullIonWarmUpThreshold < normalIonWarmUpThreshold) {
fullIonWarmUpThreshold = normalIonWarmUpThreshold;
}
} }
void DefaultJitOptions::resetCompilerWarmUpThreshold() { void DefaultJitOptions::setFullIonWarmUpThreshold(uint32_t warmUpThreshold) {
fullIonWarmUpThreshold = warmUpThreshold;
if (normalIonWarmUpThreshold > fullIonWarmUpThreshold) {
setNormalIonWarmUpThreshold(fullIonWarmUpThreshold);
}
}
void DefaultJitOptions::resetNormalIonWarmUpThreshold() {
jit::DefaultJitOptions defaultValues; jit::DefaultJitOptions defaultValues;
normalIonWarmUpThreshold = defaultValues.normalIonWarmUpThreshold; setNormalIonWarmUpThreshold(defaultValues.normalIonWarmUpThreshold);
}
void DefaultJitOptions::resetFullIonWarmUpThreshold() {
jit::DefaultJitOptions defaultValues;
setFullIonWarmUpThreshold(defaultValues.fullIonWarmUpThreshold);
} }
} // namespace jit } // namespace jit

Просмотреть файл

@ -83,6 +83,7 @@ struct DefaultJitOptions {
#endif #endif
uint32_t baselineWarmUpThreshold; uint32_t baselineWarmUpThreshold;
uint32_t normalIonWarmUpThreshold; uint32_t normalIonWarmUpThreshold;
uint32_t fullIonWarmUpThreshold;
uint32_t exceptionBailoutThreshold; uint32_t exceptionBailoutThreshold;
uint32_t frequentBailoutThreshold; uint32_t frequentBailoutThreshold;
uint32_t maxStackArgs; uint32_t maxStackArgs;
@ -111,8 +112,10 @@ struct DefaultJitOptions {
DefaultJitOptions(); DefaultJitOptions();
bool isSmallFunction(JSScript* script) const; bool isSmallFunction(JSScript* script) const;
void setEagerIonCompilation(); void setEagerIonCompilation();
void setCompilerWarmUpThreshold(uint32_t warmUpThreshold); void setNormalIonWarmUpThreshold(uint32_t warmUpThreshold);
void resetCompilerWarmUpThreshold(); void setFullIonWarmUpThreshold(uint32_t warmUpThreshold);
void resetNormalIonWarmUpThreshold();
void resetFullIonWarmUpThreshold();
void enableGvn(bool val); void enableGvn(bool val);
bool eagerIonCompilation() const { bool eagerIonCompilation() const {

Просмотреть файл

@ -5340,12 +5340,19 @@ JS_PUBLIC_API void JS_SetGlobalJitCompilerOption(JSContext* cx,
} }
jit::JitOptions.baselineWarmUpThreshold = value; jit::JitOptions.baselineWarmUpThreshold = value;
break; break;
case JSJITCOMPILER_ION_WARMUP_TRIGGER: case JSJITCOMPILER_ION_NORMAL_WARMUP_TRIGGER:
if (value == uint32_t(-1)) { if (value == uint32_t(-1)) {
jit::JitOptions.resetCompilerWarmUpThreshold(); jit::JitOptions.resetNormalIonWarmUpThreshold();
break; break;
} }
jit::JitOptions.setCompilerWarmUpThreshold(value); jit::JitOptions.setNormalIonWarmUpThreshold(value);
break;
case JSJITCOMPILER_ION_FULL_WARMUP_TRIGGER:
if (value == uint32_t(-1)) {
jit::JitOptions.resetFullIonWarmUpThreshold();
break;
}
jit::JitOptions.setFullIonWarmUpThreshold(value);
break; break;
case JSJITCOMPILER_ION_GVN_ENABLE: case JSJITCOMPILER_ION_GVN_ENABLE:
if (value == 0) { if (value == 0) {
@ -5468,9 +5475,12 @@ JS_PUBLIC_API bool JS_GetGlobalJitCompilerOption(JSContext* cx,
case JSJITCOMPILER_BASELINE_WARMUP_TRIGGER: case JSJITCOMPILER_BASELINE_WARMUP_TRIGGER:
*valueOut = jit::JitOptions.baselineWarmUpThreshold; *valueOut = jit::JitOptions.baselineWarmUpThreshold;
break; break;
case JSJITCOMPILER_ION_WARMUP_TRIGGER: case JSJITCOMPILER_ION_NORMAL_WARMUP_TRIGGER:
*valueOut = jit::JitOptions.normalIonWarmUpThreshold; *valueOut = jit::JitOptions.normalIonWarmUpThreshold;
break; break;
case JSJITCOMPILER_ION_FULL_WARMUP_TRIGGER:
*valueOut = jit::JitOptions.fullIonWarmUpThreshold;
break;
case JSJITCOMPILER_ION_FORCE_IC: case JSJITCOMPILER_ION_FORCE_IC:
*valueOut = jit::JitOptions.forceInlineCaches; *valueOut = jit::JitOptions.forceInlineCaches;
break; break;

Просмотреть файл

@ -2973,7 +2973,8 @@ extern JS_PUBLIC_API void JS_SetOffthreadIonCompilationEnabled(JSContext* cx,
// clang-format off // clang-format off
#define JIT_COMPILER_OPTIONS(Register) \ #define JIT_COMPILER_OPTIONS(Register) \
Register(BASELINE_WARMUP_TRIGGER, "baseline.warmup.trigger") \ Register(BASELINE_WARMUP_TRIGGER, "baseline.warmup.trigger") \
Register(ION_WARMUP_TRIGGER, "ion.warmup.trigger") \ Register(ION_NORMAL_WARMUP_TRIGGER, "ion.warmup.trigger") \
Register(ION_FULL_WARMUP_TRIGGER, "ion.full.warmup.trigger") \
Register(ION_GVN_ENABLE, "ion.gvn.enable") \ Register(ION_GVN_ENABLE, "ion.gvn.enable") \
Register(ION_FORCE_IC, "ion.forceinlineCaches") \ Register(ION_FORCE_IC, "ion.forceinlineCaches") \
Register(ION_ENABLE, "ion.enable") \ Register(ION_ENABLE, "ion.enable") \

Просмотреть файл

@ -36,6 +36,12 @@
--ion-warmup-threshold=0 --ion-warmup-threshold=0
--ion-warmup-threshold=10 --ion-warmup-threshold=10
--ion-warmup-threshold=100 --ion-warmup-threshold=100
--ion-full-warmup-threshold=0
--ion-full-warmup-threshold=10
--ion-full-warmup-threshold=100
--ion-full-warmup-threshold=1000
--ion-full-warmup-threshold=1500
--ion-full-warmup-threshold=5000
--no-native-regexp --no-native-regexp
--nursery-strings=off --nursery-strings=off
--nursery-strings=on --nursery-strings=on

Просмотреть файл

@ -10354,7 +10354,12 @@ static bool SetContextOptions(JSContext* cx, const OptionParser& op) {
int32_t warmUpThreshold = op.getIntOption("ion-warmup-threshold"); int32_t warmUpThreshold = op.getIntOption("ion-warmup-threshold");
if (warmUpThreshold >= 0) { if (warmUpThreshold >= 0) {
jit::JitOptions.setCompilerWarmUpThreshold(warmUpThreshold); jit::JitOptions.setNormalIonWarmUpThreshold(warmUpThreshold);
}
warmUpThreshold = op.getIntOption("ion-full-warmup-threshold");
if (warmUpThreshold >= 0) {
jit::JitOptions.setFullIonWarmUpThreshold(warmUpThreshold);
} }
warmUpThreshold = op.getIntOption("baseline-warmup-threshold"); warmUpThreshold = op.getIntOption("baseline-warmup-threshold");
@ -10946,7 +10951,11 @@ int main(int argc, char** argv, char** envp) {
"Don't compile very large scripts (default: on, off to disable)") || "Don't compile very large scripts (default: on, off to disable)") ||
!op.addIntOption('\0', "ion-warmup-threshold", "COUNT", !op.addIntOption('\0', "ion-warmup-threshold", "COUNT",
"Wait for COUNT calls or iterations before compiling " "Wait for COUNT calls or iterations before compiling "
"(default: 1000)", "at the normal optimization level (default: 1000)",
-1) ||
!op.addIntOption('\0', "ion-full-warmup-threshold", "COUNT",
"Wait for COUNT calls or iterations before compiling "
"at the 'full' optimization level (default: 100,000)",
-1) || -1) ||
!op.addStringOption( !op.addStringOption(
'\0', "ion-regalloc", "[mode]", '\0', "ion-regalloc", "[mode]",

Просмотреть файл

@ -812,8 +812,10 @@ static void ReloadPrefsCallback(const char* pref, XPCJSContext* xpccx) {
int32_t baselineThreshold = int32_t baselineThreshold =
Preferences::GetInt(JS_OPTIONS_DOT_STR "baselinejit.threshold", -1); Preferences::GetInt(JS_OPTIONS_DOT_STR "baselinejit.threshold", -1);
int32_t ionThreshold = int32_t normalIonThreshold =
Preferences::GetInt(JS_OPTIONS_DOT_STR "ion.threshold", -1); Preferences::GetInt(JS_OPTIONS_DOT_STR "ion.threshold", -1);
int32_t fullIonThreshold =
Preferences::GetInt(JS_OPTIONS_DOT_STR "ion.full.threshold", -1);
int32_t ionFrequentBailoutThreshold = Preferences::GetInt( int32_t ionFrequentBailoutThreshold = Preferences::GetInt(
JS_OPTIONS_DOT_STR "ion.frequent_bailout_threshold", -1); JS_OPTIONS_DOT_STR "ion.frequent_bailout_threshold", -1);
@ -911,8 +913,10 @@ static void ReloadPrefsCallback(const char* pref, XPCJSContext* xpccx) {
JS_SetOffthreadIonCompilationEnabled(cx, offthreadIonCompilation); JS_SetOffthreadIonCompilationEnabled(cx, offthreadIonCompilation);
JS_SetGlobalJitCompilerOption(cx, JSJITCOMPILER_BASELINE_WARMUP_TRIGGER, JS_SetGlobalJitCompilerOption(cx, JSJITCOMPILER_BASELINE_WARMUP_TRIGGER,
useBaselineEager ? 0 : baselineThreshold); useBaselineEager ? 0 : baselineThreshold);
JS_SetGlobalJitCompilerOption(cx, JSJITCOMPILER_ION_WARMUP_TRIGGER, JS_SetGlobalJitCompilerOption(cx, JSJITCOMPILER_ION_NORMAL_WARMUP_TRIGGER,
useIonEager ? 0 : ionThreshold); useIonEager ? 0 : normalIonThreshold);
JS_SetGlobalJitCompilerOption(cx, JSJITCOMPILER_ION_FULL_WARMUP_TRIGGER,
useIonEager ? 0 : fullIonThreshold);
JS_SetGlobalJitCompilerOption(cx, JS_SetGlobalJitCompilerOption(cx,
JSJITCOMPILER_ION_FREQUENT_BAILOUT_THRESHOLD, JSJITCOMPILER_ION_FREQUENT_BAILOUT_THRESHOLD,
ionFrequentBailoutThreshold); ionFrequentBailoutThreshold);

Просмотреть файл

@ -1456,6 +1456,7 @@ pref("javascript.options.baselinejit.threshold", 10);
pref("javascript.options.ion", true); pref("javascript.options.ion", true);
//Duplicated in JitOptions - ensure both match. //Duplicated in JitOptions - ensure both match.
pref("javascript.options.ion.threshold", 1000); pref("javascript.options.ion.threshold", 1000);
pref("javascript.options.ion.full.threshold", 100000);
//Duplicated in JitOptions - ensure both match. //Duplicated in JitOptions - ensure both match.
pref("javascript.options.ion.frequent_bailout_threshold", 10); pref("javascript.options.ion.frequent_bailout_threshold", 10);
pref("javascript.options.asmjs", true); pref("javascript.options.asmjs", true);