Bug 1495431 Expose baseline and ion JIT warm up threshold options to preferences, about:config r=nbp
authorAndrew Creskey <acreskey@mozilla.com>
Wed, 03 Oct 2018 19:23:54 +0000
changeset 495296 01634947caab094ec094beda6d039bf189c59ffa
parent 495295 a22ea1fdf4cb5eea00a73306d2b0d005e26d4a6c
child 495358 f66e525e6978c2fbc7351501936711876261b546
child 495360 1737f12f6ff15a46473abbd937f8b0f911946f4a
push id9984
push userffxbld-merge
push dateMon, 15 Oct 2018 21:07:35 +0000
treeherdermozilla-beta@183d27ea8570 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersnbp
bugs1495431
milestone64.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1495431 Expose baseline and ion JIT warm up threshold options to preferences, about:config r=nbp JIT warmup options were exposed to preferences to facilitate experimentation/optimization. The baseline and ion warm up thresholds had already been exposed through JSAPI, just needed to read from Preferences. The ion JitOption, frequentBailoutThreshold, was also exposed to JSAPI and Preferences. Differential Revision: https://phabricator.services.mozilla.com/D7321
js/src/jit/IonOptimizationLevels.cpp
js/src/jit/JitOptions.cpp
js/src/jsapi.cpp
js/src/jsapi.h
js/xpconnect/src/XPCJSContext.cpp
modules/libpref/init/all.js
--- a/js/src/jit/IonOptimizationLevels.cpp
+++ b/js/src/jit/IonOptimizationLevels.cpp
@@ -12,16 +12,17 @@
 using namespace js;
 using namespace js::jit;
 
 namespace js {
 namespace jit {
 
 const OptimizationLevelInfo IonOptimizations;
 
+// Duplicated in all.js - ensure both match.
 const uint32_t OptimizationInfo::CompilerWarmupThreshold = 1000;
 const uint32_t OptimizationInfo::CompilerSmallFunctionWarmupThreshold = CompilerWarmupThreshold;
 
 void
 OptimizationInfo::initNormalOptimizationInfo()
 {
     level_ = OptimizationLevel::Normal;
 
--- a/js/src/jit/JitOptions.cpp
+++ b/js/src/jit/JitOptions.cpp
@@ -153,24 +153,26 @@ DefaultJitOptions::DefaultJitOptions()
     // Toggles whether functions may be entered at loop headers.
     SET_DEFAULT(osr, true);
 
     // Whether to enable extra code to perform dynamic validations.
     SET_DEFAULT(runExtraChecks, false);
 
     // How many invocations or loop iterations are needed before functions
     // are compiled with the baseline compiler.
+    // Duplicated in all.js - ensure both match.
     SET_DEFAULT(baselineWarmUpThreshold, 10);
 
     // Number of exception bailouts (resuming into catch/finally block) before
     // we invalidate and forbid Ion compilation.
     SET_DEFAULT(exceptionBailoutThreshold, 10);
 
     // Number of bailouts without invalidation before we set
     // JSScript::hadFrequentBailouts and invalidate.
+    // Duplicated in all.js - ensure both match.
     SET_DEFAULT(frequentBailoutThreshold, 10);
 
     // Whether to run all debug checks in debug builds.
     // Disabling might make it more enjoyable to run JS in debug builds.
     SET_DEFAULT(fullDebugChecks, true);
 
     // How many actual arguments are accepted on the C stack.
     SET_DEFAULT(maxStackArgs, 4096);
--- a/js/src/jsapi.cpp
+++ b/js/src/jsapi.cpp
@@ -6525,16 +6525,23 @@ JS_SetGlobalJitCompilerOption(JSContext*
         if (value == 1) {
             JS::ContextOptionsRef(cx).setIon(true);
             JitSpew(js::jit::JitSpew_IonScripts, "Enable ion");
         } else if (value == 0) {
             JS::ContextOptionsRef(cx).setIon(false);
             JitSpew(js::jit::JitSpew_IonScripts, "Disable ion");
         }
         break;
+        case JSJITCOMPILER_ION_FREQUENT_BAILOUT_THRESHOLD:
+            if (value == uint32_t(-1)) {
+                jit::DefaultJitOptions defaultValues;
+                value = defaultValues.frequentBailoutThreshold;
+            }
+            jit::JitOptions.frequentBailoutThreshold = value;
+        break;
       case JSJITCOMPILER_BASELINE_ENABLE:
         if (value == 1) {
             JS::ContextOptionsRef(cx).setBaseline(true);
             ReleaseAllJITCode(rt->defaultFreeOp());
             JitSpew(js::jit::JitSpew_BaselineScripts, "Enable baseline");
         } else if (value == 0) {
             JS::ContextOptionsRef(cx).setBaseline(false);
             ReleaseAllJITCode(rt->defaultFreeOp());
@@ -6617,16 +6624,19 @@ JS_GetGlobalJitCompilerOption(JSContext*
         *valueOut = jit::JitOptions.forceInlineCaches;
         break;
       case JSJITCOMPILER_ION_CHECK_RANGE_ANALYSIS:
         *valueOut = jit::JitOptions.checkRangeAnalysis;
         break;
       case JSJITCOMPILER_ION_ENABLE:
         *valueOut = JS::ContextOptionsRef(cx).ion();
         break;
+      case JSJITCOMPILER_ION_FREQUENT_BAILOUT_THRESHOLD:
+        *valueOut = jit::JitOptions.frequentBailoutThreshold;
+        break;
       case JSJITCOMPILER_BASELINE_ENABLE:
         *valueOut = JS::ContextOptionsRef(cx).baseline();
         break;
       case JSJITCOMPILER_OFFTHREAD_COMPILATION_ENABLE:
         *valueOut = rt->canUseOffthreadIonCompilation();
         break;
       case JSJITCOMPILER_WASM_FOLD_OFFSETS:
         *valueOut = jit::JitOptions.wasmFoldOffsets ? 1 : 0;
--- a/js/src/jsapi.h
+++ b/js/src/jsapi.h
@@ -4457,16 +4457,17 @@ JS_SetOffthreadIonCompilationEnabled(JSC
 
 #define JIT_COMPILER_OPTIONS(Register)                                      \
     Register(BASELINE_WARMUP_TRIGGER, "baseline.warmup.trigger")            \
     Register(ION_WARMUP_TRIGGER, "ion.warmup.trigger")                      \
     Register(ION_GVN_ENABLE, "ion.gvn.enable")                              \
     Register(ION_FORCE_IC, "ion.forceinlineCaches")                         \
     Register(ION_ENABLE, "ion.enable")                                      \
     Register(ION_CHECK_RANGE_ANALYSIS, "ion.check-range-analysis")          \
+    Register(ION_FREQUENT_BAILOUT_THRESHOLD, "ion.frequent-bailout-threshold") \
     Register(BASELINE_ENABLE, "baseline.enable")                            \
     Register(OFFTHREAD_COMPILATION_ENABLE, "offthread-compilation.enable")  \
     Register(FULL_DEBUG_CHECKS, "jit.full-debug-checks")                    \
     Register(JUMP_THRESHOLD, "jump-threshold")                              \
     Register(TRACK_OPTIMIZATIONS, "jit.track-optimizations")                \
     Register(ENABLE_TRACELOGGER, "jit.enable-tracelogger")                  \
     Register(SIMULATOR_ALWAYS_INTERRUPT, "simulator.always-interrupt")      \
     Register(SPECTRE_INDEX_MASKING, "spectre.index-masking")                \
--- a/js/xpconnect/src/XPCJSContext.cpp
+++ b/js/xpconnect/src/XPCJSContext.cpp
@@ -817,16 +817,17 @@ ReloadPrefsCallback(const char* pref, XP
                                                  "baselinejit.unsafe_eager_compilation");
     bool useIonEager = Preferences::GetBool(JS_OPTIONS_DOT_STR "ion.unsafe_eager_compilation");
 #ifdef DEBUG
     bool fullJitDebugChecks = Preferences::GetBool(JS_OPTIONS_DOT_STR "jit.full_debug_checks");
 #endif
 
     int32_t baselineThreshold = Preferences::GetInt(JS_OPTIONS_DOT_STR "baselinejit.threshold", -1);
     int32_t ionThreshold = Preferences::GetInt(JS_OPTIONS_DOT_STR "ion.threshold", -1);
+    int32_t ionFrequentBailoutThreshold = Preferences::GetInt(JS_OPTIONS_DOT_STR "ion.frequent_bailout_threshold", -1);
 
     sDiscardSystemSource = Preferences::GetBool(JS_OPTIONS_DOT_STR "discardSystemSource");
 
     bool useAsyncStack = Preferences::GetBool(JS_OPTIONS_DOT_STR "asyncstack");
 
     bool throwOnDebuggeeWouldRun = Preferences::GetBool(JS_OPTIONS_DOT_STR
                                                         "throw_on_debuggee_would_run");
 
@@ -901,16 +902,19 @@ ReloadPrefsCallback(const char* pref, XP
     }
 
     JS_SetParallelParsingEnabled(cx, parallelParsing);
     JS_SetOffthreadIonCompilationEnabled(cx, offthreadIonCompilation);
     JS_SetGlobalJitCompilerOption(cx, JSJITCOMPILER_BASELINE_WARMUP_TRIGGER,
                                   useBaselineEager ? 0 : baselineThreshold);
     JS_SetGlobalJitCompilerOption(cx, JSJITCOMPILER_ION_WARMUP_TRIGGER,
                                   useIonEager ? 0 : ionThreshold);
+    JS_SetGlobalJitCompilerOption(cx, JSJITCOMPILER_ION_FREQUENT_BAILOUT_THRESHOLD,
+                                  ionFrequentBailoutThreshold);
+
 #ifdef DEBUG
     JS_SetGlobalJitCompilerOption(cx, JSJITCOMPILER_FULL_DEBUG_CHECKS, fullJitDebugChecks);
 #endif
 
     JS_SetGlobalJitCompilerOption(cx, JSJITCOMPILER_SPECTRE_INDEX_MASKING, spectreIndexMasking);
     JS_SetGlobalJitCompilerOption(cx, JSJITCOMPILER_SPECTRE_OBJECT_MITIGATIONS_BARRIERS,
                                   spectreObjectMitigationsBarriers);
     JS_SetGlobalJitCompilerOption(cx, JSJITCOMPILER_SPECTRE_OBJECT_MITIGATIONS_MISC,
--- a/modules/libpref/init/all.js
+++ b/modules/libpref/init/all.js
@@ -1405,17 +1405,23 @@ pref("dom.webcomponents.shadowdom.enable
 pref("dom.webcomponents.customelements.enabled", true);
 
 pref("javascript.enabled",                  true);
 pref("javascript.options.strict",           false);
 #ifdef DEBUG
 pref("javascript.options.strict.debug",     false);
 #endif
 pref("javascript.options.baselinejit",      true);
+//Duplicated in JitOptions - ensure both match.
+pref("javascript.options.baselinejit.threshold", 10);
 pref("javascript.options.ion",              true);
+//Duplicated in JitOptions - ensure both match.
+pref("javascript.options.ion.threshold",    1000);
+//Duplicated in JitOptions - ensure both match.
+pref("javascript.options.ion.frequent_bailout_threshold", 10);
 pref("javascript.options.asmjs",            true);
 pref("javascript.options.wasm",             true);
 pref("javascript.options.wasm_ionjit",      true);
 pref("javascript.options.wasm_baselinejit", true);
 #ifdef ENABLE_WASM_CRANELIFT
 pref("javascript.options.wasm_cranelift",   false);
 #endif
 #ifdef ENABLE_WASM_GC