Bug 1382650 part 4 - Split Ion warmup threshold JitOption in 'normal' and 'full' options. r=nbp a=pascalc
☠☠ backed out by a330a9835751 ☠ ☠
authorNarcis Beleuzu <nbeleuzu@mozilla.com>
Sun, 07 Apr 2019 16:39:22 +0300
changeset 525997 9d3bcd768496b23e1423f41a15e78e6d35ff1ff6
parent 525996 a0419e61efcd9bc2b2a8f1a7d8f40ad2cc55fe94
child 525998 0e0e954b3cdc98870700da9e8d76b2f5b142fdb0
push id2032
push userffxbld-merge
push dateMon, 13 May 2019 09:36:57 +0000
treeherdermozilla-release@455c1065dcbe [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersnbp, pascalc
bugs1382650
milestone67.0
Bug 1382650 part 4 - Split Ion warmup threshold JitOption in 'normal' and 'full' options. r=nbp a=pascalc Summary: Also adds a javascript.options.ion.full.threshold browser pref and similar shell flags. This doesn't rename the existing prefs yet. Reviewers: nbp Reviewed By: nbp Bug #: 1382650 Differential Revision: https://phabricator.services.mozilla.com/D24156
js/src/jit/JitOptions.cpp
js/src/jit/JitOptions.h
js/src/jsapi.cpp
js/src/jsapi.h
js/src/shell/fuzz-flags.txt
js/src/shell/js.cpp
js/xpconnect/src/XPCJSContext.cpp
modules/libpref/init/all.js
--- a/js/src/jit/JitOptions.cpp
+++ b/js/src/jit/JitOptions.cpp
@@ -153,16 +153,21 @@ DefaultJitOptions::DefaultJitOptions() {
   // Duplicated in all.js - ensure both match.
   SET_DEFAULT(baselineWarmUpThreshold, 10);
 
   // How many invocations or loop iterations are needed before functions
   // are compiled with the Ion compiler at OptimizationLevel::Normal.
   // Duplicated in all.js - ensure both match.
   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
   // 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);
@@ -262,21 +267,39 @@ bool DefaultJitOptions::isSmallFunction(
   return script->length() <= smallFunctionMaxBytecodeLength_;
 }
 
 void DefaultJitOptions::enableGvn(bool enable) { disableGvn = !enable; }
 
 void DefaultJitOptions::setEagerIonCompilation() {
   baselineWarmUpThreshold = 0;
   normalIonWarmUpThreshold = 0;
+  fullIonWarmUpThreshold = 0;
+}
+
+void DefaultJitOptions::setNormalIonWarmUpThreshold(uint32_t warmUpThreshold) {
+  normalIonWarmUpThreshold = warmUpThreshold;
+
+  if (fullIonWarmUpThreshold < normalIonWarmUpThreshold) {
+    fullIonWarmUpThreshold = normalIonWarmUpThreshold;
+  }
 }
 
-void DefaultJitOptions::setCompilerWarmUpThreshold(uint32_t warmUpThreshold) {
-  normalIonWarmUpThreshold = warmUpThreshold;
+void DefaultJitOptions::setFullIonWarmUpThreshold(uint32_t warmUpThreshold) {
+  fullIonWarmUpThreshold = warmUpThreshold;
+
+  if (normalIonWarmUpThreshold > fullIonWarmUpThreshold) {
+    setNormalIonWarmUpThreshold(fullIonWarmUpThreshold);
+  }
 }
 
-void DefaultJitOptions::resetCompilerWarmUpThreshold() {
+void DefaultJitOptions::resetNormalIonWarmUpThreshold() {
   jit::DefaultJitOptions defaultValues;
-  normalIonWarmUpThreshold = defaultValues.normalIonWarmUpThreshold;
+  setNormalIonWarmUpThreshold(defaultValues.normalIonWarmUpThreshold);
+}
+
+void DefaultJitOptions::resetFullIonWarmUpThreshold() {
+  jit::DefaultJitOptions defaultValues;
+  setFullIonWarmUpThreshold(defaultValues.fullIonWarmUpThreshold);
 }
 
 }  // namespace jit
 }  // namespace js
--- a/js/src/jit/JitOptions.h
+++ b/js/src/jit/JitOptions.h
@@ -78,16 +78,17 @@ struct DefaultJitOptions {
   bool enableWasmJitExit;
   bool enableWasmJitEntry;
   bool enableWasmIonFastCalls;
   bool enableWasmImportCallSpew;
   bool enableWasmFuncCallSpew;
 #endif
   uint32_t baselineWarmUpThreshold;
   uint32_t normalIonWarmUpThreshold;
+  uint32_t fullIonWarmUpThreshold;
   uint32_t exceptionBailoutThreshold;
   uint32_t frequentBailoutThreshold;
   uint32_t maxStackArgs;
   uint32_t osrPcMismatchesBeforeRecompile;
   uint32_t smallFunctionMaxBytecodeLength_;
   uint32_t jumpThreshold;
   uint32_t branchPruningHitCountFactor;
   uint32_t branchPruningInstFactor;
@@ -109,18 +110,20 @@ struct DefaultJitOptions {
   bool spectreJitToCxxCalls;
 
   // The options below affect the rest of the VM, and not just the JIT.
   bool disableUnboxedObjects;
 
   DefaultJitOptions();
   bool isSmallFunction(JSScript* script) const;
   void setEagerIonCompilation();
-  void setCompilerWarmUpThreshold(uint32_t warmUpThreshold);
-  void resetCompilerWarmUpThreshold();
+  void setNormalIonWarmUpThreshold(uint32_t warmUpThreshold);
+  void setFullIonWarmUpThreshold(uint32_t warmUpThreshold);
+  void resetNormalIonWarmUpThreshold();
+  void resetFullIonWarmUpThreshold();
   void enableGvn(bool val);
 
   bool eagerIonCompilation() const {
     return normalIonWarmUpThreshold == 0;
   }
 };
 
 extern DefaultJitOptions JitOptions;
--- a/js/src/jsapi.cpp
+++ b/js/src/jsapi.cpp
@@ -5470,22 +5470,29 @@ JS_PUBLIC_API void JS_SetGlobalJitCompil
   switch (opt) {
     case JSJITCOMPILER_BASELINE_WARMUP_TRIGGER:
       if (value == uint32_t(-1)) {
         jit::DefaultJitOptions defaultValues;
         value = defaultValues.baselineWarmUpThreshold;
       }
       jit::JitOptions.baselineWarmUpThreshold = value;
       break;
-    case JSJITCOMPILER_ION_WARMUP_TRIGGER:
+    case JSJITCOMPILER_ION_NORMAL_WARMUP_TRIGGER:
       if (value == uint32_t(-1)) {
-        jit::JitOptions.resetCompilerWarmUpThreshold();
+        jit::JitOptions.resetNormalIonWarmUpThreshold();
         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;
     case JSJITCOMPILER_ION_GVN_ENABLE:
       if (value == 0) {
         jit::JitOptions.enableGvn(false);
         JitSpew(js::jit::JitSpew_IonScripts, "Disable ion's GVN");
       } else {
         jit::JitOptions.enableGvn(true);
         JitSpew(js::jit::JitSpew_IonScripts, "Enable ion's GVN");
@@ -5601,19 +5608,22 @@ JS_PUBLIC_API bool JS_GetGlobalJitCompil
                                                  uint32_t* valueOut) {
   MOZ_ASSERT(valueOut);
 #ifndef JS_CODEGEN_NONE
   JSRuntime* rt = cx->runtime();
   switch (opt) {
     case JSJITCOMPILER_BASELINE_WARMUP_TRIGGER:
       *valueOut = jit::JitOptions.baselineWarmUpThreshold;
       break;
-    case JSJITCOMPILER_ION_WARMUP_TRIGGER:
+    case JSJITCOMPILER_ION_NORMAL_WARMUP_TRIGGER:
       *valueOut = jit::JitOptions.normalIonWarmUpThreshold;
       break;
+    case JSJITCOMPILER_ION_FULL_WARMUP_TRIGGER:
+      *valueOut = jit::JitOptions.fullIonWarmUpThreshold;
+      break;
     case JSJITCOMPILER_ION_FORCE_IC:
       *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();
--- a/js/src/jsapi.h
+++ b/js/src/jsapi.h
@@ -3289,17 +3289,18 @@ extern JS_PUBLIC_API void JS_SetParallel
                                                        bool enabled);
 
 extern JS_PUBLIC_API void JS_SetOffthreadIonCompilationEnabled(JSContext* cx,
                                                                bool enabled);
 
 // clang-format off
 #define JIT_COMPILER_OPTIONS(Register) \
   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_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") \
--- a/js/src/shell/fuzz-flags.txt
+++ b/js/src/shell/fuzz-flags.txt
@@ -31,16 +31,22 @@
 --ion-regalloc=testbed
 --ion-scalar-replacement=off
 --ion-scalar-replacement=on
 --ion-sincos=off
 --ion-sincos=on
 --ion-warmup-threshold=0
 --ion-warmup-threshold=10
 --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
 --nursery-strings=off
 --nursery-strings=on
 --spectre-mitigations=off
 --spectre-mitigations=on
 --more-compartments
 
 # Experimental JS language features
--- a/js/src/shell/js.cpp
+++ b/js/src/shell/js.cpp
@@ -10374,17 +10374,22 @@ static bool SetContextOptions(JSContext*
       jit::JitOptions.limitScriptSize = false;
     } else {
       return OptionFailure("ion-limit-script-size", str);
     }
   }
 
   int32_t warmUpThreshold = op.getIntOption("ion-warmup-threshold");
   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");
   if (warmUpThreshold >= 0) {
     jit::JitOptions.baselineWarmUpThreshold = warmUpThreshold;
   }
 
   if (op.getBoolOption("baseline-eager")) {
@@ -10964,17 +10969,21 @@ int main(int argc, char** argv, char** e
       !op.addStringOption(
           '\0', "ion-osr", "on/off",
           "On-Stack Replacement (default: on, off to disable)") ||
       !op.addStringOption(
           '\0', "ion-limit-script-size", "on/off",
           "Don't compile very large scripts (default: on, off to disable)") ||
       !op.addIntOption('\0', "ion-warmup-threshold", "COUNT",
                        "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) ||
       !op.addStringOption(
           '\0', "ion-regalloc", "[mode]",
           "Specify Ion register allocation:\n"
           "  backtracking: Priority based backtracking register allocation "
           "(default)\n"
           "  testbed: Backtracking allocator with experimental features\n"
           "  stupid: Simple block local register allocation") ||
--- a/js/xpconnect/src/XPCJSContext.cpp
+++ b/js/xpconnect/src/XPCJSContext.cpp
@@ -805,18 +805,20 @@ static void ReloadPrefsCallback(const ch
       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 =
+  int32_t normalIonThreshold =
       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(
       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");
 
@@ -905,18 +907,20 @@ static void ReloadPrefsCallback(const ch
       JS::ContextOptionsRef(cx).disableOptionsForSafeMode();
     }
   }
 
   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_NORMAL_WARMUP_TRIGGER,
+                                useIonEager ? 0 : normalIonThreshold);
+  JS_SetGlobalJitCompilerOption(cx, JSJITCOMPILER_ION_FULL_WARMUP_TRIGGER,
+                                useIonEager ? 0 : fullIonThreshold);
   JS_SetGlobalJitCompilerOption(cx,
                                 JSJITCOMPILER_ION_FREQUENT_BAILOUT_THRESHOLD,
                                 ionFrequentBailoutThreshold);
 
 #ifdef DEBUG
   JS_SetGlobalJitCompilerOption(cx, JSJITCOMPILER_FULL_DEBUG_CHECKS,
                                 fullJitDebugChecks);
 #endif
--- a/modules/libpref/init/all.js
+++ b/modules/libpref/init/all.js
@@ -1469,16 +1469,17 @@ pref("javascript.options.baselinejit",  
 pref("javascript.options.baselinejit.threshold", 10);
 #ifdef NO_ION
 pref("javascript.options.ion",              false);
 #else
 pref("javascript.options.ion",              true);
 #endif
 //Duplicated in JitOptions - ensure both match.
 pref("javascript.options.ion.threshold",    1000);
+pref("javascript.options.ion.full.threshold", 100000);
 //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_verbose",     false);
 pref("javascript.options.wasm_ionjit",      true);
 pref("javascript.options.wasm_baselinejit", true);
 #ifdef ENABLE_WASM_CRANELIFT