Bug 1382650 part 8 - Add a JitOption to disable use of Ion optimization levels. r=nbp a=pascalc
☠☠ backed out by a330a9835751 ☠ ☠
authorJan de Mooij <jdemooij@mozilla.com>
Sun, 07 Apr 2019 16:43:19 +0300
changeset 526001 353c9e1559f09f75eafcb6f7897b21a75777e64a
parent 526000 dfde2a76520d0f0539a4ee1b377c34f5d410d9a3
child 526002 ee00e620926a5bf8af78b41d91fd8b670af57634
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 8 - Add a JitOption to disable use of Ion optimization levels. r=nbp a=pascalc Summary: We might uplift these patches to beta. Having a JitOption makes it easier to turn this off if needed. Reviewers: nbp Reviewed By: nbp Bug #: 1382650 Differential Revision: https://phabricator.services.mozilla.com/D25754
js/src/jit/IonBuilder.cpp
js/src/jit/IonOptimizationLevels.h
js/src/jit/JitOptions.cpp
js/src/jit/JitOptions.h
js/src/shell/fuzz-flags.txt
js/src/shell/js.cpp
--- a/js/src/jit/IonBuilder.cpp
+++ b/js/src/jit/IonBuilder.cpp
@@ -7651,22 +7651,25 @@ static bool ObjectHasExtraOwnProperty(Co
   // Resolve hooks can install new properties on objects on demand.
   JSObject* singleton = object->isSingleton() ? object->singleton() : nullptr;
   return ClassMayResolveId(realm->runtime()->names(), clasp, id, singleton);
 }
 
 void IonBuilder::insertRecompileCheck() {
   MOZ_ASSERT(pc == script()->code() || *pc == JSOP_LOOPENTRY);
 
-  // No need for recompile checks if this is the highest optimization level.
+  // No need for recompile checks if this is the highest optimization level or
+  // if we're performing an analysis instead of compilation.
   OptimizationLevel curLevel = optimizationLevel();
-  if (IonOptimizations.isLastLevel(curLevel)) {
+  if (IonOptimizations.isLastLevel(curLevel) || info().isAnalysis()) {
     return;
   }
 
+  MOZ_ASSERT(!JitOptions.disableOptimizationLevels);
+
   // Add recompile check. See MRecompileCheck::RecompileCheckType for how this
   // works.
 
   MRecompileCheck::RecompileCheckType type;
   if (*pc == JSOP_LOOPENTRY) {
     type = MRecompileCheck::RecompileCheckType::OptimizationLevelOSR;
   } else if (this != outermostBuilder()) {
     type = MRecompileCheck::RecompileCheckType::OptimizationLevelInlined;
--- a/js/src/jit/IonOptimizationLevels.h
+++ b/js/src/jit/IonOptimizationLevels.h
@@ -146,17 +146,22 @@ class OptimizationInfo {
   // as a multiplication of inliningWarmUpThreshold.
   uint32_t inliningRecompileThresholdFactor_;
 
   uint32_t baseCompilerWarmUpThreshold() const {
     switch (level_) {
       case OptimizationLevel::Normal:
         return JitOptions.normalIonWarmUpThreshold;
       case OptimizationLevel::Full:
-        return JitOptions.fullIonWarmUpThreshold;
+        if (!JitOptions.disableOptimizationLevels) {
+          return JitOptions.fullIonWarmUpThreshold;
+        }
+        // Use the 'normal' threshold so Ion uses a single optimization level,
+        // OptimizationLevel::Full.
+        return JitOptions.normalIonWarmUpThreshold;
       case OptimizationLevel::DontCompile:
       case OptimizationLevel::Wasm:
       case OptimizationLevel::Count:
         break;
     }
     MOZ_CRASH("Unexpected optimization level");
   }
 
--- a/js/src/jit/JitOptions.cpp
+++ b/js/src/jit/JitOptions.cpp
@@ -131,16 +131,20 @@ DefaultJitOptions::DefaultJitOptions() {
   SET_DEFAULT(disableSincos, false);
 #else
   SET_DEFAULT(disableSincos, true);
 #endif
 
   // Toggles whether sink code motion is globally disabled.
   SET_DEFAULT(disableSink, true);
 
+  // Toggles whether the use of multiple Ion optimization levels is globally
+  // disabled.
+  SET_DEFAULT(disableOptimizationLevels, false);
+
   // Whether IonBuilder should prefer IC generation above specialized MIR.
   SET_DEFAULT(forceInlineCaches, false);
 
   // Toggles whether large scripts are rejected.
   SET_DEFAULT(limitScriptSize, true);
 
   // Toggles whether functions may be entered at loop headers.
   SET_DEFAULT(osr, true);
--- a/js/src/jit/JitOptions.h
+++ b/js/src/jit/JitOptions.h
@@ -60,16 +60,17 @@ struct DefaultJitOptions {
   bool disableInstructionReordering;
   bool disableRangeAnalysis;
   bool disableRecoverIns;
   bool disableScalarReplacement;
   bool disableCacheIR;
   bool disableCacheIRBinaryArith;
   bool disableSincos;
   bool disableSink;
+  bool disableOptimizationLevels;
   bool forceInlineCaches;
   bool fullDebugChecks;
   bool limitScriptSize;
   bool osr;
   bool wasmFoldOffsets;
   bool wasmDelayTier2;
 #ifdef JS_TRACE_LOGGING
   bool enableTraceLogger;
--- a/js/src/shell/fuzz-flags.txt
+++ b/js/src/shell/fuzz-flags.txt
@@ -37,16 +37,18 @@
 --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
+--ion-optimization-levels=off
+--ion-optimization-levels=on
 --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
@@ -10324,16 +10324,26 @@ static bool SetContextOptions(JSContext*
       jit::JitOptions.disableSink = false;
     } else if (strcmp(str, "off") == 0) {
       jit::JitOptions.disableSink = true;
     } else {
       return OptionFailure("ion-sink", str);
     }
   }
 
+  if (const char* str = op.getStringOption("ion-optimization-levels")) {
+    if (strcmp(str, "on") == 0) {
+      jit::JitOptions.disableOptimizationLevels = false;
+    } else if (strcmp(str, "off") == 0) {
+      jit::JitOptions.disableOptimizationLevels = true;
+    } else {
+      return OptionFailure("ion-optimization-levels", str);
+    }
+  }
+
   if (const char* str = op.getStringOption("ion-instruction-reordering")) {
     if (strcmp(str, "on") == 0) {
       jit::JitOptions.disableInstructionReordering = false;
     } else if (strcmp(str, "off") == 0) {
       jit::JitOptions.disableInstructionReordering = true;
     } else {
       return OptionFailure("ion-instruction-reordering", str);
     }
@@ -10949,16 +10959,19 @@ int main(int argc, char** argv, char** e
              "Replace sin(x)/cos(x) to sincos(x) (default: on, off to disable)")
 #else
       || !op.addStringOption(
              '\0', "ion-sincos", "on/off",
              "Replace sin(x)/cos(x) to sincos(x) (default: off, on to enable)")
 #endif
       || !op.addStringOption('\0', "ion-sink", "on/off",
                              "Sink code motion (default: off, on to enable)") ||
+      !op.addStringOption('\0', "ion-optimization-levels", "on/off",
+                          "Use multiple Ion optimization levels (default: on, "
+                          "off to disable)") ||
       !op.addStringOption('\0', "ion-loop-unrolling", "on/off",
                           "(NOP for fuzzers)") ||
       !op.addStringOption(
           '\0', "ion-instruction-reordering", "on/off",
           "Instruction reordering (default: off, on to enable)") ||
       !op.addBoolOption('\0', "ion-check-range-analysis",
                         "Range analysis checking") ||
       !op.addBoolOption('\0', "ion-extra-checks",