1 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- 2 * vim: set ts=8 sts=2 et sw=2 tw=80: 3 * This Source Code Form is subject to the terms of the Mozilla Public 4 * License, v. 2.0. If a copy of the MPL was not distributed with this 5 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 6 7 #ifndef jit_JitOptions_h 8 #define jit_JitOptions_h 9 10 #include "mozilla/Maybe.h" 11 12 #include "jit/IonTypes.h" 13 #include "js/TypeDecls.h" 14 15 namespace js { 16 namespace jit { 17 18 // Possible register allocators which may be used. 19 enum IonRegisterAllocator { 20 RegisterAllocator_Backtracking, 21 RegisterAllocator_Testbed, 22 }; 23 LookupRegisterAllocator(const char * name)24static inline mozilla::Maybe<IonRegisterAllocator> LookupRegisterAllocator( 25 const char* name) { 26 if (!strcmp(name, "backtracking")) { 27 return mozilla::Some(RegisterAllocator_Backtracking); 28 } 29 if (!strcmp(name, "testbed")) { 30 return mozilla::Some(RegisterAllocator_Testbed); 31 } 32 return mozilla::Nothing(); 33 } 34 35 struct DefaultJitOptions { 36 bool checkGraphConsistency; 37 #ifdef CHECK_OSIPOINT_REGISTERS 38 bool checkOsiPointRegisters; 39 #endif 40 bool checkRangeAnalysis; 41 bool runExtraChecks; 42 bool disableInlineBacktracking; 43 bool disableAma; 44 bool disableEaa; 45 bool disableEdgeCaseAnalysis; 46 bool disableGvn; 47 bool disableInlining; 48 bool disableLicm; 49 bool disablePgo; 50 bool disableInstructionReordering; 51 bool disableRangeAnalysis; 52 bool disableRecoverIns; 53 bool disableScalarReplacement; 54 bool disableCacheIR; 55 bool disableSink; 56 bool disableOptimizationLevels; 57 bool baselineInterpreter; 58 bool baselineJit; 59 bool ion; 60 #ifdef NIGHTLY_BUILD 61 bool typeInference; 62 #endif 63 bool warpBuilder; 64 bool jitForTrustedPrincipals; 65 bool nativeRegExp; 66 bool forceInlineCaches; 67 bool fullDebugChecks; 68 bool limitScriptSize; 69 bool osr; 70 bool wasmFoldOffsets; 71 bool wasmDelayTier2; 72 #ifdef JS_TRACE_LOGGING 73 bool enableTraceLogger; 74 #endif 75 #ifdef ENABLE_NEW_REGEXP 76 bool traceRegExpParser; 77 bool traceRegExpAssembler; 78 bool traceRegExpInterpreter; 79 bool traceRegExpPeephole; 80 #endif 81 bool enableWasmJitExit; 82 bool enableWasmJitEntry; 83 bool enableWasmIonFastCalls; 84 #ifdef WASM_CODEGEN_DEBUG 85 bool enableWasmImportCallSpew; 86 bool enableWasmFuncCallSpew; 87 #endif 88 uint32_t baselineInterpreterWarmUpThreshold; 89 uint32_t baselineJitWarmUpThreshold; 90 uint32_t normalIonWarmUpThreshold; 91 uint32_t fullIonWarmUpThreshold; 92 #ifdef ENABLE_NEW_REGEXP 93 uint32_t regexpWarmUpThreshold; 94 #endif 95 uint32_t exceptionBailoutThreshold; 96 uint32_t frequentBailoutThreshold; 97 uint32_t maxStackArgs; 98 uint32_t osrPcMismatchesBeforeRecompile; 99 uint32_t smallFunctionMaxBytecodeLength_; 100 uint32_t jumpThreshold; 101 uint32_t branchPruningHitCountFactor; 102 uint32_t branchPruningInstFactor; 103 uint32_t branchPruningBlockSpanFactor; 104 uint32_t branchPruningEffectfulInstFactor; 105 uint32_t branchPruningThreshold; 106 uint32_t ionMaxScriptSize; 107 uint32_t ionMaxScriptSizeMainThread; 108 uint32_t ionMaxLocalsAndArgs; 109 uint32_t ionMaxLocalsAndArgsMainThread; 110 uint32_t wasmBatchBaselineThreshold; 111 uint32_t wasmBatchIonThreshold; 112 uint32_t wasmBatchCraneliftThreshold; 113 mozilla::Maybe<IonRegisterAllocator> forcedRegisterAllocator; 114 115 // Spectre mitigation flags. Each mitigation has its own flag in order to 116 // measure the effectiveness of each mitigation with various proof of 117 // concept. 118 bool spectreIndexMasking; 119 bool spectreObjectMitigationsBarriers; 120 bool spectreObjectMitigationsMisc; 121 bool spectreStringMitigations; 122 bool spectreValueMasking; 123 bool spectreJitToCxxCalls; 124 125 bool supportsFloatingPoint; 126 bool supportsUnalignedAccesses; 127 128 DefaultJitOptions(); 129 bool isSmallFunction(JSScript* script) const; 130 void setEagerBaselineCompilation(); 131 void setEagerIonCompilation(); 132 void setNormalIonWarmUpThreshold(uint32_t warmUpThreshold); 133 void setFullIonWarmUpThreshold(uint32_t warmUpThreshold); 134 void resetNormalIonWarmUpThreshold(); 135 void resetFullIonWarmUpThreshold(); 136 void enableGvn(bool val); 137 eagerIonCompilationDefaultJitOptions138 bool eagerIonCompilation() const { return normalIonWarmUpThreshold == 0; } 139 }; 140 141 extern DefaultJitOptions JitOptions; 142 IsBaselineInterpreterEnabled()143inline bool IsBaselineInterpreterEnabled() { 144 #ifdef JS_CODEGEN_NONE 145 return false; 146 #else 147 return JitOptions.baselineInterpreter && JitOptions.supportsFloatingPoint; 148 #endif 149 } 150 151 } // namespace jit 152 IsTypeInferenceEnabled()153inline bool IsTypeInferenceEnabled() { 154 #ifdef NIGHTLY_BUILD 155 return jit::JitOptions.typeInference; 156 #else 157 // Always enable TI on non-Nightly for now to avoid performance overhead. 158 return true; 159 #endif 160 } 161 162 } // namespace js 163 164 #endif /* jit_JitOptions_h */ 165