diff --git a/js/src/jit/IonOptimizationLevels.cpp b/js/src/jit/IonOptimizationLevels.cpp index e8a11a9452a0..f972e0191f75 100644 --- a/js/src/jit/IonOptimizationLevels.cpp +++ b/js/src/jit/IonOptimizationLevels.cpp @@ -49,6 +49,7 @@ OptimizationInfo::initNormalOptimizationInfo() scalarReplacement_ = true; smallFunctionMaxInlineDepth_ = 10; compilerWarmUpThreshold_ = CompilerWarmupThreshold; + compilerSmallFunctionWarmUpThreshold_ = CompilerSmallFunctionWarmupThreshold; inliningWarmUpThresholdFactor_ = 0.125; inliningRecompileThresholdFactor_ = 4; } @@ -86,6 +87,12 @@ OptimizationInfo::compilerWarmUpThreshold(JSScript* script, jsbytecode* pc) cons if (JitOptions.forcedDefaultIonWarmUpThreshold.isSome()) warmUpThreshold = JitOptions.forcedDefaultIonWarmUpThreshold.ref(); + if (JitOptions.isSmallFunction(script)) { + warmUpThreshold = compilerSmallFunctionWarmUpThreshold_; + if (JitOptions.forcedDefaultIonSmallFunctionWarmUpThreshold.isSome()) + warmUpThreshold = JitOptions.forcedDefaultIonSmallFunctionWarmUpThreshold.ref(); + } + // If the script is too large to compile on the main thread, we can still // compile it off thread. In these cases, increase the warm-up counter // threshold to improve the compilation's type information and hopefully diff --git a/js/src/jit/IonOptimizationLevels.h b/js/src/jit/IonOptimizationLevels.h index df6d3211e7b6..43187641116f 100644 --- a/js/src/jit/IonOptimizationLevels.h +++ b/js/src/jit/IonOptimizationLevels.h @@ -134,6 +134,13 @@ class OptimizationInfo // Default compiler warmup threshold, unless it is overridden. static const uint32_t CompilerWarmupThreshold = 1000; + // How many invocations or loop iterations are needed before small functions + // are compiled. + uint32_t compilerSmallFunctionWarmUpThreshold_; + + // Default small function compiler warmup threshold, unless it is overridden. + static const uint32_t CompilerSmallFunctionWarmupThreshold = 100; + // How many invocations or loop iterations are needed before calls // are inlined, as a fraction of compilerWarmUpThreshold. double inliningWarmUpThresholdFactor_; diff --git a/js/src/jit/JitOptions.cpp b/js/src/jit/JitOptions.cpp index e04d13908caf..208ab8e4c8b1 100644 --- a/js/src/jit/JitOptions.cpp +++ b/js/src/jit/JitOptions.cpp @@ -178,6 +178,17 @@ DefaultJitOptions::DefaultJitOptions() Warn(forcedDefaultIonWarmUpThresholdEnv, env); } + // Same but for compiling small functions. + const char* forcedDefaultIonSmallFunctionWarmUpThresholdEnv = + "JIT_OPTION_forcedDefaultIonSmallFunctionWarmUpThreshold"; + if (const char* env = getenv(forcedDefaultIonSmallFunctionWarmUpThresholdEnv)) { + Maybe value = ParseInt(env); + if (value.isSome()) + forcedDefaultIonSmallFunctionWarmUpThreshold.emplace(value.ref()); + else + Warn(forcedDefaultIonSmallFunctionWarmUpThresholdEnv, env); + } + // Force the used register allocator instead of letting the optimization // pass decide. const char* forcedRegisterAllocatorEnv = "JIT_OPTION_forcedRegisterAllocator"; @@ -213,6 +224,8 @@ DefaultJitOptions::setEagerCompilation() baselineWarmUpThreshold = 0; forcedDefaultIonWarmUpThreshold.reset(); forcedDefaultIonWarmUpThreshold.emplace(0); + forcedDefaultIonSmallFunctionWarmUpThreshold.reset(); + forcedDefaultIonSmallFunctionWarmUpThreshold.emplace(0); } void @@ -220,6 +233,8 @@ DefaultJitOptions::setCompilerWarmUpThreshold(uint32_t warmUpThreshold) { forcedDefaultIonWarmUpThreshold.reset(); forcedDefaultIonWarmUpThreshold.emplace(warmUpThreshold); + forcedDefaultIonSmallFunctionWarmUpThreshold.reset(); + forcedDefaultIonSmallFunctionWarmUpThreshold.emplace(warmUpThreshold); // Undo eager compilation if (eagerCompilation && warmUpThreshold != 0) { diff --git a/js/src/jit/JitOptions.h b/js/src/jit/JitOptions.h index 6b3d8cbc48f6..021612773825 100644 --- a/js/src/jit/JitOptions.h +++ b/js/src/jit/JitOptions.h @@ -75,6 +75,7 @@ struct DefaultJitOptions uint32_t smallFunctionMaxBytecodeLength_; uint32_t jumpThreshold; mozilla::Maybe forcedDefaultIonWarmUpThreshold; + mozilla::Maybe forcedDefaultIonSmallFunctionWarmUpThreshold; mozilla::Maybe forcedRegisterAllocator; // The options below affect the rest of the VM, and not just the JIT.