| 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_Simple, |
| 22 |
}; |
| 23 |
|
| 24 |
// Which register to use as base register to access stack slots: frame pointer, |
| 25 |
// stack pointer, or whichever is the default for this platform. See comment |
| 26 |
// for baseRegForLocals in JitOptions.cpp for more information. |
| 27 |
enum class BaseRegForAddress { Default, FP, SP }; |
| 28 |
|
| 29 |
enum class UseMonomorphicInlining : uint8_t { |
| 30 |
Default, |
| 31 |
Always, |
| 32 |
Never, |
| 33 |
}; |
| 34 |
|
| 35 |
static inline mozilla::Maybe<IonRegisterAllocator> LookupRegisterAllocator( |
| 36 |
const char* name) { |
| 37 |
if (!strcmp(name, "backtracking")) { |
| 38 |
return mozilla::Some(RegisterAllocator_Backtracking); |
| 39 |
} |
| 40 |
if (!strcmp(name, "simple")) { |
| 41 |
return mozilla::Some(RegisterAllocator_Simple); |
| 42 |
} |
| 43 |
return mozilla::Nothing(); |
| 44 |
} |
| 45 |
|
| 46 |
struct DefaultJitOptions { |
| 47 |
bool checkGraphConsistency; |
| 48 |
#ifdef CHECK_OSIPOINT_REGISTERS |
| 49 |
bool checkOsiPointRegisters; |
| 50 |
#endif |
| 51 |
bool checkRangeAnalysis; |
| 52 |
bool runExtraChecks; |
| 53 |
bool disableJitBackend; |
| 54 |
bool disableJitHints; |
| 55 |
bool disableAma; |
| 56 |
bool disableEaa; |
| 57 |
bool disableEdgeCaseAnalysis; |
| 58 |
bool disableGvn; |
| 59 |
bool disableInlining; |
| 60 |
bool disableLicm; |
| 61 |
bool disablePruning; |
| 62 |
bool disableInstructionReordering; |
| 63 |
bool disableIteratorIndices; |
| 64 |
bool disableMarkLoadsUsedAsPropertyKeys; |
| 65 |
bool disableRangeAnalysis; |
| 66 |
bool disableRecoverIns; |
| 67 |
bool disableScalarReplacement; |
| 68 |
bool disableCacheIR; |
| 69 |
bool disableSink; |
| 70 |
bool disableRedundantShapeGuards; |
| 71 |
bool disableRedundantGCBarriers; |
| 72 |
bool disableBailoutLoopCheck; |
| 73 |
#ifdef ENABLE_PORTABLE_BASELINE_INTERP |
| 74 |
bool portableBaselineInterpreter; |
| 75 |
#endif |
| 76 |
bool baselineInterpreter; |
| 77 |
bool baselineJit; |
| 78 |
bool baselineBatching; |
| 79 |
bool ion; |
| 80 |
bool jitForTrustedPrincipals; |
| 81 |
bool nativeRegExp; |
| 82 |
bool forceInlineCaches; |
| 83 |
bool forceMegamorphicICs; |
| 84 |
bool fullDebugChecks; |
| 85 |
bool limitScriptSize; |
| 86 |
bool osr; |
| 87 |
bool wasmFoldOffsets; |
| 88 |
bool wasmDelayTier2; |
| 89 |
bool lessDebugCode; |
| 90 |
bool onlyInlineSelfHosted; |
| 91 |
bool enableICFramePointers; |
| 92 |
bool enableWasmJitExit; |
| 93 |
bool enableWasmJitEntry; |
| 94 |
bool enableWasmIonFastCalls; |
| 95 |
#ifdef WASM_CODEGEN_DEBUG |
| 96 |
bool enableWasmImportCallSpew; |
| 97 |
bool enableWasmFuncCallSpew; |
| 98 |
#endif |
| 99 |
bool emitInterpreterEntryTrampoline; |
| 100 |
uint32_t baselineInterpreterWarmUpThreshold; |
| 101 |
uint32_t baselineJitWarmUpThreshold; |
| 102 |
uint32_t baselineQueueCapacity; |
| 103 |
uint32_t trialInliningWarmUpThreshold; |
| 104 |
uint32_t trialInliningInitialWarmUpCount; |
| 105 |
UseMonomorphicInlining monomorphicInlining = UseMonomorphicInlining::Default; |
| 106 |
uint32_t normalIonWarmUpThreshold; |
| 107 |
uint32_t regexpWarmUpThreshold; |
| 108 |
#ifdef ENABLE_PORTABLE_BASELINE_INTERP |
| 109 |
uint32_t portableBaselineInterpreterWarmUpThreshold; |
| 110 |
#endif |
| 111 |
uint32_t exceptionBailoutThreshold; |
| 112 |
uint32_t frequentBailoutThreshold; |
| 113 |
uint32_t maxStackArgs; |
| 114 |
uint32_t osrPcMismatchesBeforeRecompile; |
| 115 |
uint32_t smallFunctionMaxBytecodeLength; |
| 116 |
uint32_t inliningEntryThreshold; |
| 117 |
uint32_t jumpThreshold; |
| 118 |
uint32_t branchPruningHitCountFactor; |
| 119 |
uint32_t branchPruningInstFactor; |
| 120 |
uint32_t branchPruningBlockSpanFactor; |
| 121 |
uint32_t branchPruningEffectfulInstFactor; |
| 122 |
uint32_t branchPruningThreshold; |
| 123 |
uint32_t ionMaxScriptSize; |
| 124 |
uint32_t ionMaxScriptSizeMainThread; |
| 125 |
uint32_t ionMaxLocalsAndArgs; |
| 126 |
uint32_t ionMaxLocalsAndArgsMainThread; |
| 127 |
uint32_t wasmBatchBaselineThreshold; |
| 128 |
uint32_t wasmBatchIonThreshold; |
| 129 |
#ifdef ENABLE_JS_AOT_ICS |
| 130 |
bool enableAOTICs; |
| 131 |
bool enableAOTICEnforce; |
| 132 |
#endif |
| 133 |
|
| 134 |
// Spectre mitigation flags. Each mitigation has its own flag in order to |
| 135 |
// measure the effectiveness of each mitigation with various proof of |
| 136 |
// concept. |
| 137 |
bool spectreIndexMasking; |
| 138 |
bool spectreObjectMitigations; |
| 139 |
bool spectreStringMitigations; |
| 140 |
bool spectreValueMasking; |
| 141 |
bool spectreJitToCxxCalls; |
| 142 |
|
| 143 |
bool writeProtectCode; |
| 144 |
|
| 145 |
bool supportsUnalignedAccesses; |
| 146 |
BaseRegForAddress baseRegForLocals; |
| 147 |
|
| 148 |
// Irregexp shim flags |
| 149 |
bool correctness_fuzzer_suppressions; |
| 150 |
bool enable_regexp_unaligned_accesses; |
| 151 |
bool js_regexp_modifiers; |
| 152 |
bool js_regexp_duplicate_named_groups; |
| 153 |
bool regexp_possessive_quantifier; |
| 154 |
bool regexp_optimization; |
| 155 |
bool regexp_peephole_optimization; |
| 156 |
bool regexp_tier_up; |
| 157 |
bool trace_regexp_assembler; |
| 158 |
bool trace_regexp_bytecodes; |
| 159 |
bool trace_regexp_parser; |
| 160 |
bool trace_regexp_peephole_optimization; |
| 161 |
|
| 162 |
DefaultJitOptions(); |
| 163 |
bool isSmallFunction(JSScript* script) const; |
| 164 |
#ifdef ENABLE_PORTABLE_BASELINE_INTERP |
| 165 |
void setEagerPortableBaselineInterpreter(); |
| 166 |
#endif |
| 167 |
void setEagerBaselineCompilation(); |
| 168 |
void setEagerIonCompilation(); |
| 169 |
void setNormalIonWarmUpThreshold(uint32_t warmUpThreshold); |
| 170 |
void resetNormalIonWarmUpThreshold(); |
| 171 |
void enableGvn(bool val); |
| 172 |
void setFastWarmUp(); |
| 173 |
|
| 174 |
void maybeSetWriteProtectCode(bool val); |
| 175 |
|
| 176 |
bool eagerIonCompilation() const { return normalIonWarmUpThreshold == 0; } |
| 177 |
}; |
| 178 |
|
| 179 |
extern DefaultJitOptions JitOptions; |
| 180 |
|
| 181 |
inline bool HasJitBackend() { |
| 182 |
#if defined(JS_CODEGEN_NONE) |
| 183 |
return false; |
| 184 |
#else |
| 185 |
return !JitOptions.disableJitBackend; |
| 186 |
#endif |
| 187 |
} |
| 188 |
|
| 189 |
inline bool IsBaselineInterpreterEnabled() { |
| 190 |
return HasJitBackend() && JitOptions.baselineInterpreter; |
| 191 |
} |
| 192 |
|
| 193 |
#ifdef ENABLE_PORTABLE_BASELINE_INTERP |
| 194 |
inline bool IsPortableBaselineInterpreterEnabled() { |
| 195 |
return JitOptions.portableBaselineInterpreter; |
| 196 |
} |
| 197 |
#else |
| 198 |
inline bool IsPortableBaselineInterpreterEnabled() { return false; } |
| 199 |
#endif |
| 200 |
|
| 201 |
inline bool TooManyActualArguments(size_t nargs) { |
| 202 |
return nargs > JitOptions.maxStackArgs; |
| 203 |
} |
| 204 |
|
| 205 |
} // namespace jit |
| 206 |
|
| 207 |
extern mozilla::Atomic<bool> fuzzingSafe; |
| 208 |
|
| 209 |
static inline bool IsFuzzing() { |
| 210 |
#ifdef FUZZING |
| 211 |
return true; |
| 212 |
#else |
| 213 |
return fuzzingSafe; |
| 214 |
#endif |
| 215 |
} |
| 216 |
|
| 217 |
} // namespace js |
| 218 |
|
| 219 |
#endif /* jit_JitOptions_h */ |