| 1 | /* |
| 2 | * Copyright (C) 2011-2019 Apple Inc. All rights reserved. |
| 3 | * |
| 4 | * Redistribution and use in source and binary forms, with or without |
| 5 | * modification, are permitted provided that the following conditions |
| 6 | * are met: |
| 7 | * 1. Redistributions of source code must retain the above copyright |
| 8 | * notice, this list of conditions and the following disclaimer. |
| 9 | * 2. Redistributions in binary form must reproduce the above copyright |
| 10 | * notice, this list of conditions and the following disclaimer in the |
| 11 | * documentation and/or other materials provided with the distribution. |
| 12 | * |
| 13 | * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY |
| 14 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
| 15 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR |
| 16 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR |
| 17 | * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, |
| 18 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, |
| 19 | * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR |
| 20 | * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY |
| 21 | * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| 22 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
| 23 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 24 | */ |
| 25 | |
| 26 | #pragma once |
| 27 | |
| 28 | #include "GCLogging.h" |
| 29 | #include "JSExportMacros.h" |
| 30 | #include <stdint.h> |
| 31 | #include <stdio.h> |
| 32 | #include <wtf/PrintStream.h> |
| 33 | #include <wtf/StdLibExtras.h> |
| 34 | |
| 35 | namespace WTF { |
| 36 | class StringBuilder; |
| 37 | } |
| 38 | using WTF::StringBuilder; |
| 39 | |
| 40 | namespace JSC { |
| 41 | |
| 42 | // How do JSC VM options work? |
| 43 | // =========================== |
| 44 | // The JSC_OPTIONS() macro below defines a list of all JSC options in use, |
| 45 | // along with their types and default values. The options values are actually |
| 46 | // realized as an array of Options::Entry elements. |
| 47 | // |
| 48 | // Options::initialize() will initialize the array of options values with |
| 49 | // the defaults specified in JSC_OPTIONS() below. After that, the values can |
| 50 | // be programmatically read and written to using an accessor method with the |
| 51 | // same name as the option. For example, the option "useJIT" can be read and |
| 52 | // set like so: |
| 53 | // |
| 54 | // bool jitIsOn = Options::useJIT(); // Get the option value. |
| 55 | // Options::useJIT() = false; // Sets the option value. |
| 56 | // |
| 57 | // If you want to tweak any of these values programmatically for testing |
| 58 | // purposes, you can do so in Options::initialize() after the default values |
| 59 | // are set. |
| 60 | // |
| 61 | // Alternatively, you can override the default values by specifying |
| 62 | // environment variables of the form: JSC_<name of JSC option>. |
| 63 | // |
| 64 | // Note: Options::initialize() tries to ensure some sanity on the option values |
| 65 | // which are set by doing some range checks, and value corrections. These |
| 66 | // checks are done after the option values are set. If you alter the option |
| 67 | // values after the sanity checks (for your own testing), then you're liable to |
| 68 | // ensure that the new values set are sane and reasonable for your own run. |
| 69 | |
| 70 | class OptionRange { |
| 71 | private: |
| 72 | enum RangeState { Uninitialized, InitError, Normal, Inverted }; |
| 73 | public: |
| 74 | OptionRange& operator= (const int& rhs) |
| 75 | { // Only needed for initialization |
| 76 | if (!rhs) { |
| 77 | m_state = Uninitialized; |
| 78 | m_rangeString = 0; |
| 79 | m_lowLimit = 0; |
| 80 | m_highLimit = 0; |
| 81 | } |
| 82 | return *this; |
| 83 | } |
| 84 | |
| 85 | bool init(const char*); |
| 86 | bool isInRange(unsigned); |
| 87 | const char* rangeString() const { return (m_state > InitError) ? m_rangeString : s_nullRangeStr; } |
| 88 | |
| 89 | void dump(PrintStream& out) const; |
| 90 | |
| 91 | private: |
| 92 | static const char* const s_nullRangeStr; |
| 93 | |
| 94 | RangeState m_state; |
| 95 | const char* m_rangeString; |
| 96 | unsigned m_lowLimit; |
| 97 | unsigned m_highLimit; |
| 98 | }; |
| 99 | |
| 100 | typedef OptionRange optionRange; |
| 101 | typedef const char* optionString; |
| 102 | |
| 103 | #if PLATFORM(IOS_FAMILY) |
| 104 | #define MAXIMUM_NUMBER_OF_FTL_COMPILER_THREADS 2 |
| 105 | #else |
| 106 | #define MAXIMUM_NUMBER_OF_FTL_COMPILER_THREADS 8 |
| 107 | #endif |
| 108 | |
| 109 | #if ENABLE(EXPERIMENTAL_FEATURES) |
| 110 | constexpr bool enableIntlNumberFormatToParts = true; |
| 111 | #else |
| 112 | constexpr bool enableIntlNumberFormatToParts = false; |
| 113 | #endif |
| 114 | |
| 115 | #if ENABLE(EXPERIMENTAL_FEATURES) |
| 116 | constexpr bool enableIntlPluralRules = true; |
| 117 | #else |
| 118 | constexpr bool enableIntlPluralRules = false; |
| 119 | #endif |
| 120 | |
| 121 | #if ENABLE(WEBASSEMBLY_STREAMING_API) |
| 122 | constexpr bool enableWebAssemblyStreamingApi = true; |
| 123 | #else |
| 124 | constexpr bool enableWebAssemblyStreamingApi = false; |
| 125 | #endif |
| 126 | |
| 127 | #define JSC_OPTIONS(v) \ |
| 128 | v(bool, validateOptions, false, Normal, "crashes if mis-typed JSC options were passed to the VM") \ |
| 129 | v(unsigned, dumpOptions, 0, Normal, "dumps JSC options (0 = None, 1 = Overridden only, 2 = All, 3 = Verbose)") \ |
| 130 | v(optionString, configFile, nullptr, Normal, "file to configure JSC options and logging location") \ |
| 131 | \ |
| 132 | v(bool, useLLInt, true, Normal, "allows the LLINT to be used if true") \ |
| 133 | v(bool, useJIT, jitEnabledByDefault(), Normal, "allows the executable pages to be allocated for JIT and thunks if true") \ |
| 134 | v(bool, useBaselineJIT, true, Normal, "allows the baseline JIT to be used if true") \ |
| 135 | v(bool, useDFGJIT, true, Normal, "allows the DFG JIT to be used if true") \ |
| 136 | v(bool, useRegExpJIT, jitEnabledByDefault(), Normal, "allows the RegExp JIT to be used if true") \ |
| 137 | v(bool, useDOMJIT, is64Bit(), Normal, "allows the DOMJIT to be used if true") \ |
| 138 | \ |
| 139 | v(bool, reportMustSucceedExecutableAllocations, false, Normal, nullptr) \ |
| 140 | \ |
| 141 | v(unsigned, maxPerThreadStackUsage, 4 * MB, Normal, "Max allowed stack usage by the VM") \ |
| 142 | v(unsigned, softReservedZoneSize, 128 * KB, Normal, "A buffer greater than reservedZoneSize that reserves space for stringifying exceptions.") \ |
| 143 | v(unsigned, reservedZoneSize, 64 * KB, Normal, "The amount of stack space we guarantee to our clients (and to interal VM code that does not call out to clients).") \ |
| 144 | \ |
| 145 | v(bool, crashIfCantAllocateJITMemory, false, Normal, nullptr) \ |
| 146 | v(unsigned, jitMemoryReservationSize, 0, Normal, "Set this number to change the executable allocation size in ExecutableAllocatorFixedVMPool. (In bytes.)") \ |
| 147 | v(bool, useSeparatedWXHeap, false, Normal, nullptr) \ |
| 148 | \ |
| 149 | v(bool, forceCodeBlockLiveness, false, Normal, nullptr) \ |
| 150 | v(bool, forceICFailure, false, Normal, nullptr) \ |
| 151 | \ |
| 152 | v(unsigned, repatchCountForCoolDown, 8, Normal, nullptr) \ |
| 153 | v(unsigned, initialCoolDownCount, 20, Normal, nullptr) \ |
| 154 | v(unsigned, repatchBufferingCountdown, 8, Normal, nullptr) \ |
| 155 | \ |
| 156 | v(bool, dumpGeneratedBytecodes, false, Normal, nullptr) \ |
| 157 | v(bool, dumpBytecodeLivenessResults, false, Normal, nullptr) \ |
| 158 | v(bool, validateBytecode, false, Normal, nullptr) \ |
| 159 | v(bool, forceDebuggerBytecodeGeneration, false, Normal, nullptr) \ |
| 160 | v(bool, dumpBytecodesBeforeGeneratorification, false, Normal, nullptr) \ |
| 161 | \ |
| 162 | v(bool, useFunctionDotArguments, true, Normal, nullptr) \ |
| 163 | v(bool, useTailCalls, true, Normal, nullptr) \ |
| 164 | v(bool, optimizeRecursiveTailCalls, true, Normal, nullptr) \ |
| 165 | v(bool, alwaysUseShadowChicken, false, Normal, nullptr) \ |
| 166 | v(unsigned, shadowChickenLogSize, 1000, Normal, nullptr) \ |
| 167 | v(unsigned, shadowChickenMaxTailDeletedFramesSize, 128, Normal, nullptr) \ |
| 168 | \ |
| 169 | /* dumpDisassembly implies dumpDFGDisassembly. */ \ |
| 170 | v(bool, dumpDisassembly, false, Normal, "dumps disassembly of all JIT compiled code upon compilation") \ |
| 171 | v(bool, asyncDisassembly, false, Normal, nullptr) \ |
| 172 | v(bool, dumpDFGDisassembly, false, Normal, "dumps disassembly of DFG function upon compilation") \ |
| 173 | v(bool, dumpFTLDisassembly, false, Normal, "dumps disassembly of FTL function upon compilation") \ |
| 174 | v(bool, dumpRegExpDisassembly, false, Normal, "dumps disassembly of RegExp upon compilation") \ |
| 175 | v(bool, dumpAllDFGNodes, false, Normal, nullptr) \ |
| 176 | v(bool, logJITCodeForPerf, false, Configurable, nullptr) \ |
| 177 | v(optionRange, bytecodeRangeToJITCompile, 0, Normal, "bytecode size range to allow compilation on, e.g. 1:100") \ |
| 178 | v(optionRange, bytecodeRangeToDFGCompile, 0, Normal, "bytecode size range to allow DFG compilation on, e.g. 1:100") \ |
| 179 | v(optionRange, bytecodeRangeToFTLCompile, 0, Normal, "bytecode size range to allow FTL compilation on, e.g. 1:100") \ |
| 180 | v(optionString, jitWhitelist, nullptr, Normal, "file with list of function signatures to allow compilation on") \ |
| 181 | v(optionString, dfgWhitelist, nullptr, Normal, "file with list of function signatures to allow DFG compilation on") \ |
| 182 | v(optionString, ftlWhitelist, nullptr, Normal, "file with list of function signatures to allow FTL compilation on") \ |
| 183 | v(bool, dumpSourceAtDFGTime, false, Normal, "dumps source code of JS function being DFG compiled") \ |
| 184 | v(bool, dumpBytecodeAtDFGTime, false, Normal, "dumps bytecode of JS function being DFG compiled") \ |
| 185 | v(bool, dumpGraphAfterParsing, false, Normal, nullptr) \ |
| 186 | v(bool, dumpGraphAtEachPhase, false, Normal, nullptr) \ |
| 187 | v(bool, dumpDFGGraphAtEachPhase, false, Normal, "dumps the DFG graph at each phase of DFG compilation (note this excludes DFG graphs during FTL compilation)") \ |
| 188 | v(bool, dumpDFGFTLGraphAtEachPhase, false, Normal, "dumps the DFG graph at each phase of DFG compilation when compiling FTL code") \ |
| 189 | v(bool, dumpB3GraphAtEachPhase, false, Normal, "dumps the B3 graph at each phase of compilation") \ |
| 190 | v(bool, dumpAirGraphAtEachPhase, false, Normal, "dumps the Air graph at each phase of compilation") \ |
| 191 | v(bool, verboseDFGBytecodeParsing, false, Normal, nullptr) \ |
| 192 | v(bool, safepointBeforeEachPhase, true, Normal, nullptr) \ |
| 193 | v(bool, verboseCompilation, false, Normal, nullptr) \ |
| 194 | v(bool, verboseFTLCompilation, false, Normal, nullptr) \ |
| 195 | v(bool, logCompilationChanges, false, Normal, nullptr) \ |
| 196 | v(bool, useProbeOSRExit, false, Normal, nullptr) \ |
| 197 | v(bool, printEachOSRExit, false, Normal, nullptr) \ |
| 198 | v(bool, validateGraph, false, Normal, nullptr) \ |
| 199 | v(bool, validateGraphAtEachPhase, false, Normal, nullptr) \ |
| 200 | v(bool, verboseValidationFailure, false, Normal, nullptr) \ |
| 201 | v(bool, verboseOSR, false, Normal, nullptr) \ |
| 202 | v(bool, verboseDFGOSRExit, false, Normal, nullptr) \ |
| 203 | v(bool, verboseFTLOSRExit, false, Normal, nullptr) \ |
| 204 | v(bool, verboseCallLink, false, Normal, nullptr) \ |
| 205 | v(bool, verboseCompilationQueue, false, Normal, nullptr) \ |
| 206 | v(bool, reportCompileTimes, false, Normal, "dumps JS function signature and the time it took to compile in all tiers") \ |
| 207 | v(bool, reportBaselineCompileTimes, false, Normal, "dumps JS function signature and the time it took to BaselineJIT compile") \ |
| 208 | v(bool, reportDFGCompileTimes, false, Normal, "dumps JS function signature and the time it took to DFG and FTL compile") \ |
| 209 | v(bool, reportFTLCompileTimes, false, Normal, "dumps JS function signature and the time it took to FTL compile") \ |
| 210 | v(bool, reportTotalCompileTimes, false, Normal, nullptr) \ |
| 211 | v(bool, reportParseTimes, false, Normal, "dumps JS function signature and the time it took to parse") \ |
| 212 | v(bool, reportBytecodeCompileTimes, false, Normal, "dumps JS function signature and the time it took to bytecode compile") \ |
| 213 | v(bool, verboseExitProfile, false, Normal, nullptr) \ |
| 214 | v(bool, verboseCFA, false, Normal, nullptr) \ |
| 215 | v(bool, verboseDFGFailure, false, Normal, nullptr) \ |
| 216 | v(bool, verboseFTLToJSThunk, false, Normal, nullptr) \ |
| 217 | v(bool, verboseFTLFailure, false, Normal, nullptr) \ |
| 218 | v(bool, alwaysComputeHash, false, Normal, nullptr) \ |
| 219 | v(bool, testTheFTL, false, Normal, nullptr) \ |
| 220 | v(bool, verboseSanitizeStack, false, Normal, nullptr) \ |
| 221 | v(bool, useGenerationalGC, true, Normal, nullptr) \ |
| 222 | v(bool, useConcurrentGC, true, Normal, nullptr) \ |
| 223 | v(bool, collectContinuously, false, Normal, nullptr) \ |
| 224 | v(double, collectContinuouslyPeriodMS, 1, Normal, nullptr) \ |
| 225 | v(bool, forceFencedBarrier, false, Normal, nullptr) \ |
| 226 | v(bool, verboseVisitRace, false, Normal, nullptr) \ |
| 227 | v(bool, optimizeParallelSlotVisitorsForStoppedMutator, false, Normal, nullptr) \ |
| 228 | v(unsigned, largeHeapSize, 32 * 1024 * 1024, Normal, nullptr) \ |
| 229 | v(unsigned, smallHeapSize, 1 * 1024 * 1024, Normal, nullptr) \ |
| 230 | v(double, smallHeapRAMFraction, 0.25, Normal, nullptr) \ |
| 231 | v(double, smallHeapGrowthFactor, 2, Normal, nullptr) \ |
| 232 | v(double, mediumHeapRAMFraction, 0.5, Normal, nullptr) \ |
| 233 | v(double, mediumHeapGrowthFactor, 1.5, Normal, nullptr) \ |
| 234 | v(double, largeHeapGrowthFactor, 1.24, Normal, nullptr) \ |
| 235 | v(double, miniVMHeapGrowthFactor, 1.27, Normal, nullptr) \ |
| 236 | v(double, criticalGCMemoryThreshold, 0.80, Normal, "percent memory in use the GC considers critical. The collector is much more aggressive above this threshold") \ |
| 237 | v(double, minimumMutatorUtilization, 0, Normal, nullptr) \ |
| 238 | v(double, maximumMutatorUtilization, 0.7, Normal, nullptr) \ |
| 239 | v(double, epsilonMutatorUtilization, 0.01, Normal, nullptr) \ |
| 240 | v(double, concurrentGCMaxHeadroom, 1.5, Normal, nullptr) \ |
| 241 | v(double, concurrentGCPeriodMS, 2, Normal, nullptr) \ |
| 242 | v(bool, useStochasticMutatorScheduler, true, Normal, nullptr) \ |
| 243 | v(double, minimumGCPauseMS, 0.3, Normal, nullptr) \ |
| 244 | v(double, gcPauseScale, 0.3, Normal, nullptr) \ |
| 245 | v(double, gcIncrementBytes, 10000, Normal, nullptr) \ |
| 246 | v(double, gcIncrementMaxBytes, 100000, Normal, nullptr) \ |
| 247 | v(double, gcIncrementScale, 0, Normal, nullptr) \ |
| 248 | v(bool, scribbleFreeCells, false, Normal, nullptr) \ |
| 249 | v(double, sizeClassProgression, 1.4, Normal, nullptr) \ |
| 250 | v(unsigned, largeAllocationCutoff, 100000, Normal, nullptr) \ |
| 251 | v(bool, dumpSizeClasses, false, Normal, nullptr) \ |
| 252 | v(bool, useBumpAllocator, true, Normal, nullptr) \ |
| 253 | v(bool, stealEmptyBlocksFromOtherAllocators, true, Normal, nullptr) \ |
| 254 | v(bool, eagerlyUpdateTopCallFrame, false, Normal, nullptr) \ |
| 255 | \ |
| 256 | v(bool, useOSREntryToDFG, true, Normal, nullptr) \ |
| 257 | v(bool, useOSREntryToFTL, true, Normal, nullptr) \ |
| 258 | \ |
| 259 | v(bool, useFTLJIT, true, Normal, "allows the FTL JIT to be used if true") \ |
| 260 | v(bool, useFTLTBAA, true, Normal, nullptr) \ |
| 261 | v(bool, validateFTLOSRExitLiveness, false, Normal, nullptr) \ |
| 262 | v(unsigned, defaultB3OptLevel, 2, Normal, nullptr) \ |
| 263 | v(bool, b3AlwaysFailsBeforeCompile, false, Normal, nullptr) \ |
| 264 | v(bool, b3AlwaysFailsBeforeLink, false, Normal, nullptr) \ |
| 265 | v(bool, ftlCrashes, false, Normal, nullptr) /* fool-proof way of checking that you ended up in the FTL. ;-) */\ |
| 266 | v(bool, clobberAllRegsInFTLICSlowPath, !ASSERT_DISABLED, Normal, nullptr) \ |
| 267 | v(bool, enableJITDebugAssertions, !ASSERT_DISABLED, Normal, nullptr) \ |
| 268 | v(bool, useAccessInlining, true, Normal, nullptr) \ |
| 269 | v(unsigned, maxAccessVariantListSize, 8, Normal, nullptr) \ |
| 270 | v(bool, usePolyvariantDevirtualization, true, Normal, nullptr) \ |
| 271 | v(bool, usePolymorphicAccessInlining, true, Normal, nullptr) \ |
| 272 | v(unsigned, maxPolymorphicAccessInliningListSize, 8, Normal, nullptr) \ |
| 273 | v(bool, usePolymorphicCallInlining, true, Normal, nullptr) \ |
| 274 | v(bool, usePolymorphicCallInliningForNonStubStatus, false, Normal, nullptr) \ |
| 275 | v(unsigned, maxPolymorphicCallVariantListSize, 15, Normal, nullptr) \ |
| 276 | v(unsigned, maxPolymorphicCallVariantListSizeForTopTier, 5, Normal, nullptr) \ |
| 277 | v(unsigned, maxPolymorphicCallVariantListSizeForWebAssemblyToJS, 5, Normal, nullptr) \ |
| 278 | v(unsigned, maxPolymorphicCallVariantsForInlining, 5, Normal, nullptr) \ |
| 279 | v(unsigned, frequentCallThreshold, 2, Normal, nullptr) \ |
| 280 | v(double, minimumCallToKnownRate, 0.51, Normal, nullptr) \ |
| 281 | v(bool, , true, Normal, nullptr) \ |
| 282 | v(bool, useMovHintRemoval, true, Normal, nullptr) \ |
| 283 | v(bool, usePutStackSinking, true, Normal, nullptr) \ |
| 284 | v(bool, useObjectAllocationSinking, true, Normal, nullptr) \ |
| 285 | v(bool, useValueRepElimination, true, Normal, nullptr) \ |
| 286 | v(bool, useArityFixupInlining, true, Normal, nullptr) \ |
| 287 | v(bool, logExecutableAllocation, false, Normal, nullptr) \ |
| 288 | \ |
| 289 | v(bool, useConcurrentJIT, true, Normal, "allows the DFG / FTL compilation in threads other than the executing JS thread") \ |
| 290 | v(unsigned, numberOfDFGCompilerThreads, computeNumberOfWorkerThreads(3, 2) - 1, Normal, nullptr) \ |
| 291 | v(unsigned, numberOfFTLCompilerThreads, computeNumberOfWorkerThreads(MAXIMUM_NUMBER_OF_FTL_COMPILER_THREADS, 2) - 1, Normal, nullptr) \ |
| 292 | v(int32, priorityDeltaOfDFGCompilerThreads, computePriorityDeltaOfWorkerThreads(-1, 0), Normal, nullptr) \ |
| 293 | v(int32, priorityDeltaOfFTLCompilerThreads, computePriorityDeltaOfWorkerThreads(-2, 0), Normal, nullptr) \ |
| 294 | v(int32, priorityDeltaOfWasmCompilerThreads, computePriorityDeltaOfWorkerThreads(-1, 0), Normal, nullptr) \ |
| 295 | \ |
| 296 | v(bool, useProfiler, false, Normal, nullptr) \ |
| 297 | v(bool, disassembleBaselineForProfiler, true, Normal, nullptr) \ |
| 298 | \ |
| 299 | v(bool, useArchitectureSpecificOptimizations, true, Normal, nullptr) \ |
| 300 | \ |
| 301 | v(bool, breakOnThrow, false, Normal, nullptr) \ |
| 302 | \ |
| 303 | v(unsigned, maximumOptimizationCandidateBytecodeCost, 100000, Normal, nullptr) \ |
| 304 | \ |
| 305 | v(unsigned, maximumFunctionForCallInlineCandidateBytecodeCost, 120, Normal, nullptr) \ |
| 306 | v(unsigned, maximumFunctionForClosureCallInlineCandidateBytecodeCost, 100, Normal, nullptr) \ |
| 307 | v(unsigned, maximumFunctionForConstructInlineCandidateBytecoodeCost, 100, Normal, nullptr) \ |
| 308 | \ |
| 309 | v(unsigned, maximumFTLCandidateBytecodeCost, 20000, Normal, nullptr) \ |
| 310 | \ |
| 311 | /* Depth of inline stack, so 1 = no inlining, 2 = one level, etc. */ \ |
| 312 | v(unsigned, maximumInliningDepth, 5, Normal, "maximum allowed inlining depth. Depth of 1 means no inlining") \ |
| 313 | v(unsigned, maximumInliningRecursion, 2, Normal, nullptr) \ |
| 314 | \ |
| 315 | /* Maximum size of a caller for enabling inlining. This is purely to protect us */\ |
| 316 | /* from super long compiles that take a lot of memory. */\ |
| 317 | v(unsigned, maximumInliningCallerBytecodeCost, 10000, Normal, nullptr) \ |
| 318 | \ |
| 319 | v(unsigned, maximumVarargsForInlining, 100, Normal, nullptr) \ |
| 320 | \ |
| 321 | v(bool, useMaximalFlushInsertionPhase, false, Normal, "Setting to true allows the DFG's MaximalFlushInsertionPhase to run.") \ |
| 322 | \ |
| 323 | v(unsigned, maximumBinaryStringSwitchCaseLength, 50, Normal, nullptr) \ |
| 324 | v(unsigned, maximumBinaryStringSwitchTotalLength, 2000, Normal, nullptr) \ |
| 325 | \ |
| 326 | v(double, jitPolicyScale, 1.0, Normal, "scale JIT thresholds to this specified ratio between 0.0 (compile ASAP) and 1.0 (compile like normal).") \ |
| 327 | v(bool, forceEagerCompilation, false, Normal, nullptr) \ |
| 328 | v(int32, thresholdForJITAfterWarmUp, 500, Normal, nullptr) \ |
| 329 | v(int32, thresholdForJITSoon, 100, Normal, nullptr) \ |
| 330 | \ |
| 331 | v(int32, thresholdForOptimizeAfterWarmUp, 1000, Normal, nullptr) \ |
| 332 | v(int32, thresholdForOptimizeAfterLongWarmUp, 1000, Normal, nullptr) \ |
| 333 | v(int32, thresholdForOptimizeSoon, 1000, Normal, nullptr) \ |
| 334 | v(int32, executionCounterIncrementForLoop, 1, Normal, nullptr) \ |
| 335 | v(int32, executionCounterIncrementForEntry, 15, Normal, nullptr) \ |
| 336 | \ |
| 337 | v(int32, thresholdForFTLOptimizeAfterWarmUp, 100000, Normal, nullptr) \ |
| 338 | v(int32, thresholdForFTLOptimizeSoon, 1000, Normal, nullptr) \ |
| 339 | v(int32, ftlTierUpCounterIncrementForLoop, 1, Normal, nullptr) \ |
| 340 | v(int32, ftlTierUpCounterIncrementForReturn, 15, Normal, nullptr) \ |
| 341 | v(unsigned, ftlOSREntryFailureCountForReoptimization, 15, Normal, nullptr) \ |
| 342 | v(unsigned, ftlOSREntryRetryThreshold, 100, Normal, nullptr) \ |
| 343 | \ |
| 344 | v(int32, evalThresholdMultiplier, 10, Normal, nullptr) \ |
| 345 | v(unsigned, maximumEvalCacheableSourceLength, 256, Normal, nullptr) \ |
| 346 | \ |
| 347 | v(bool, randomizeExecutionCountsBetweenCheckpoints, false, Normal, nullptr) \ |
| 348 | v(int32, maximumExecutionCountsBetweenCheckpointsForBaseline, 1000, Normal, nullptr) \ |
| 349 | v(int32, maximumExecutionCountsBetweenCheckpointsForUpperTiers, 50000, Normal, nullptr) \ |
| 350 | \ |
| 351 | v(unsigned, likelyToTakeSlowCaseMinimumCount, 20, Normal, nullptr) \ |
| 352 | v(unsigned, couldTakeSlowCaseMinimumCount, 10, Normal, nullptr) \ |
| 353 | \ |
| 354 | v(unsigned, osrExitCountForReoptimization, 100, Normal, nullptr) \ |
| 355 | v(unsigned, osrExitCountForReoptimizationFromLoop, 5, Normal, nullptr) \ |
| 356 | \ |
| 357 | v(unsigned, reoptimizationRetryCounterMax, 0, Normal, nullptr) \ |
| 358 | \ |
| 359 | v(unsigned, minimumOptimizationDelay, 1, Normal, nullptr) \ |
| 360 | v(unsigned, maximumOptimizationDelay, 5, Normal, nullptr) \ |
| 361 | v(double, desiredProfileLivenessRate, 0.75, Normal, nullptr) \ |
| 362 | v(double, desiredProfileFullnessRate, 0.35, Normal, nullptr) \ |
| 363 | \ |
| 364 | v(double, doubleVoteRatioForDoubleFormat, 2, Normal, nullptr) \ |
| 365 | v(double, structureCheckVoteRatioForHoisting, 1, Normal, nullptr) \ |
| 366 | v(double, checkArrayVoteRatioForHoisting, 1, Normal, nullptr) \ |
| 367 | \ |
| 368 | v(unsigned, maximumDirectCallStackSize, 200, Normal, nullptr) \ |
| 369 | \ |
| 370 | v(unsigned, minimumNumberOfScansBetweenRebalance, 100, Normal, nullptr) \ |
| 371 | v(unsigned, numberOfGCMarkers, computeNumberOfGCMarkers(8), Normal, nullptr) \ |
| 372 | v(bool, useParallelMarkingConstraintSolver, true, Normal, nullptr) \ |
| 373 | v(unsigned, opaqueRootMergeThreshold, 1000, Normal, nullptr) \ |
| 374 | v(double, minHeapUtilization, 0.8, Normal, nullptr) \ |
| 375 | v(double, minMarkedBlockUtilization, 0.9, Normal, nullptr) \ |
| 376 | v(unsigned, slowPathAllocsBetweenGCs, 0, Normal, "force a GC on every Nth slow path alloc, where N is specified by this option") \ |
| 377 | \ |
| 378 | v(double, percentCPUPerMBForFullTimer, 0.0003125, Normal, nullptr) \ |
| 379 | v(double, percentCPUPerMBForEdenTimer, 0.0025, Normal, nullptr) \ |
| 380 | v(double, collectionTimerMaxPercentCPU, 0.05, Normal, nullptr) \ |
| 381 | \ |
| 382 | v(bool, forceWeakRandomSeed, false, Normal, nullptr) \ |
| 383 | v(unsigned, forcedWeakRandomSeed, 0, Normal, nullptr) \ |
| 384 | \ |
| 385 | v(bool, useZombieMode, false, Normal, "debugging option to scribble over dead objects with 0xbadbeef0") \ |
| 386 | v(bool, useImmortalObjects, false, Normal, "debugging option to keep all objects alive forever") \ |
| 387 | v(bool, sweepSynchronously, false, Normal, "debugging option to sweep all dead objects synchronously at GC end before resuming mutator") \ |
| 388 | v(unsigned, maxSingleAllocationSize, 0, Configurable, "debugging option to limit individual allocations to a max size (0 = limit not set, N = limit size in bytes)") \ |
| 389 | \ |
| 390 | v(gcLogLevel, logGC, GCLogging::None, Normal, "debugging option to log GC activity (0 = None, 1 = Basic, 2 = Verbose)") \ |
| 391 | v(bool, useGC, true, Normal, nullptr) \ |
| 392 | v(bool, gcAtEnd, false, Normal, "If true, the jsc CLI will do a GC before exiting") \ |
| 393 | v(bool, forceGCSlowPaths, false, Normal, "If true, we will force all JIT fast allocations down their slow paths.") \ |
| 394 | v(unsigned, gcMaxHeapSize, 0, Normal, nullptr) \ |
| 395 | v(unsigned, forceRAMSize, 0, Normal, nullptr) \ |
| 396 | v(bool, recordGCPauseTimes, false, Normal, nullptr) \ |
| 397 | v(bool, dumpHeapStatisticsAtVMDestruction, false, Normal, nullptr) \ |
| 398 | v(bool, forceCodeBlockToJettisonDueToOldAge, false, Normal, "If true, this means that anytime we can jettison a CodeBlock due to old age, we do.") \ |
| 399 | v(bool, useEagerCodeBlockJettisonTiming, false, Normal, "If true, the time slices for jettisoning a CodeBlock due to old age are shrunk significantly.") \ |
| 400 | \ |
| 401 | v(bool, useTypeProfiler, false, Normal, nullptr) \ |
| 402 | v(bool, useControlFlowProfiler, false, Normal, nullptr) \ |
| 403 | \ |
| 404 | v(bool, useSamplingProfiler, false, Normal, nullptr) \ |
| 405 | v(unsigned, sampleInterval, 1000, Normal, "Time between stack traces in microseconds.") \ |
| 406 | v(bool, collectSamplingProfilerDataForJSCShell, false, Normal, "This corresponds to the JSC shell's --sample option.") \ |
| 407 | v(unsigned, samplingProfilerTopFunctionsCount, 12, Normal, "Number of top functions to report when using the command line interface.") \ |
| 408 | v(unsigned, samplingProfilerTopBytecodesCount, 40, Normal, "Number of top bytecodes to report when using the command line interface.") \ |
| 409 | v(optionString, samplingProfilerPath, nullptr, Normal, "The path to the directory to write sampiling profiler output to. This probably will not work with WK2 unless the path is in the whitelist.") \ |
| 410 | v(bool, sampleCCode, false, Normal, "Causes the sampling profiler to record profiling data for C frames.") \ |
| 411 | \ |
| 412 | v(bool, alwaysGeneratePCToCodeOriginMap, false, Normal, "This will make sure we always generate a PCToCodeOriginMap for JITed code.") \ |
| 413 | \ |
| 414 | v(bool, verifyHeap, false, Normal, nullptr) \ |
| 415 | v(unsigned, numberOfGCCyclesToRecordForVerification, 3, Normal, nullptr) \ |
| 416 | \ |
| 417 | v(unsigned, exceptionStackTraceLimit, 100, Normal, "Stack trace limit for internal Exception object") \ |
| 418 | v(unsigned, defaultErrorStackTraceLimit, 100, Normal, "The default value for Error.stackTraceLimit") \ |
| 419 | v(bool, useExceptionFuzz, false, Normal, nullptr) \ |
| 420 | v(unsigned, fireExceptionFuzzAt, 0, Normal, nullptr) \ |
| 421 | v(bool, validateDFGExceptionHandling, false, Normal, "Causes the DFG to emit code validating exception handling for each node that can exit") /* This is true by default on Debug builds */\ |
| 422 | v(bool, dumpSimulatedThrows, false, Normal, "Dumps the call stack of the last simulated throw if exception scope verification fails") \ |
| 423 | v(bool, validateExceptionChecks, false, Normal, "Verifies that needed exception checks are performed.") \ |
| 424 | v(unsigned, unexpectedExceptionStackTraceLimit, 100, Normal, "Stack trace limit for debugging unexpected exceptions observed in the VM") \ |
| 425 | \ |
| 426 | v(bool, useExecutableAllocationFuzz, false, Normal, nullptr) \ |
| 427 | v(unsigned, fireExecutableAllocationFuzzAt, 0, Normal, nullptr) \ |
| 428 | v(unsigned, fireExecutableAllocationFuzzAtOrAfter, 0, Normal, nullptr) \ |
| 429 | v(bool, verboseExecutableAllocationFuzz, false, Normal, nullptr) \ |
| 430 | \ |
| 431 | v(bool, useOSRExitFuzz, false, Normal, nullptr) \ |
| 432 | v(unsigned, fireOSRExitFuzzAtStatic, 0, Normal, nullptr) \ |
| 433 | v(unsigned, fireOSRExitFuzzAt, 0, Normal, nullptr) \ |
| 434 | v(unsigned, fireOSRExitFuzzAtOrAfter, 0, Normal, nullptr) \ |
| 435 | \ |
| 436 | v(bool, useRandomizingFuzzerAgent, false, Normal, nullptr) \ |
| 437 | v(unsigned, seedOfRandomizingFuzzerAgent, 1, Normal, nullptr) \ |
| 438 | v(bool, dumpRandomizingFuzzerAgentPredictions, false, Normal, nullptr) \ |
| 439 | v(bool, useDoublePredictionFuzzerAgent, false, Normal, nullptr) \ |
| 440 | \ |
| 441 | v(bool, logPhaseTimes, false, Normal, nullptr) \ |
| 442 | v(double, rareBlockPenalty, 0.001, Normal, nullptr) \ |
| 443 | v(bool, airLinearScanVerbose, false, Normal, nullptr) \ |
| 444 | v(bool, airLinearScanSpillsEverything, false, Normal, nullptr) \ |
| 445 | v(bool, airForceBriggsAllocator, false, Normal, nullptr) \ |
| 446 | v(bool, airForceIRCAllocator, false, Normal, nullptr) \ |
| 447 | v(bool, airRandomizeRegs, false, Normal, nullptr) \ |
| 448 | v(unsigned, airRandomizeRegsSeed, 0, Normal, nullptr) \ |
| 449 | v(bool, coalesceSpillSlots, true, Normal, nullptr) \ |
| 450 | v(bool, logAirRegisterPressure, false, Normal, nullptr) \ |
| 451 | v(bool, useB3TailDup, true, Normal, nullptr) \ |
| 452 | v(unsigned, maxB3TailDupBlockSize, 3, Normal, nullptr) \ |
| 453 | v(unsigned, maxB3TailDupBlockSuccessors, 3, Normal, nullptr) \ |
| 454 | \ |
| 455 | v(bool, useDollarVM, false, Restricted, "installs the $vm debugging tool in global objects") \ |
| 456 | v(optionString, functionOverrides, nullptr, Restricted, "file with debugging overrides for function bodies") \ |
| 457 | v(bool, useSigillCrashAnalyzer, false, Configurable, "logs data about SIGILL crashes") \ |
| 458 | \ |
| 459 | v(unsigned, watchdog, 0, Normal, "watchdog timeout (0 = Disabled, N = a timeout period of N milliseconds)") \ |
| 460 | v(bool, usePollingTraps, false, Normal, "use polling (instead of signalling) VM traps") \ |
| 461 | \ |
| 462 | v(bool, useMachForExceptions, true, Normal, "Use mach exceptions rather than signals to handle faults and pass thread messages. (This does nothing on platforms without mach)") \ |
| 463 | \ |
| 464 | v(bool, useICStats, false, Normal, nullptr) \ |
| 465 | \ |
| 466 | v(unsigned, prototypeHitCountForLLIntCaching, 2, Normal, "Number of prototype property hits before caching a prototype in the LLInt. A count of 0 means never cache.") \ |
| 467 | \ |
| 468 | v(bool, dumpCompiledRegExpPatterns, false, Normal, nullptr) \ |
| 469 | \ |
| 470 | v(bool, dumpModuleRecord, false, Normal, nullptr) \ |
| 471 | v(bool, dumpModuleLoadingState, false, Normal, nullptr) \ |
| 472 | v(bool, exposeInternalModuleLoader, false, Normal, "expose the internal module loader object to the global space for debugging") \ |
| 473 | \ |
| 474 | v(bool, useSuperSampler, false, Normal, nullptr) \ |
| 475 | \ |
| 476 | v(bool, useSourceProviderCache, true, Normal, "If false, the parser will not use the source provider cache. It's good to verify everything works when this is false. Because the cache is so successful, it can mask bugs.") \ |
| 477 | v(bool, useCodeCache, true, Normal, "If false, the unlinked byte code cache will not be used.") \ |
| 478 | \ |
| 479 | v(bool, useWebAssembly, true, Normal, "Expose the WebAssembly global object.") \ |
| 480 | \ |
| 481 | v(bool, enableSpectreMitigations, true, Restricted, "Enable Spectre mitigations.") \ |
| 482 | v(bool, enableSpectreGadgets, false, Restricted, "enable gadgets to test Spectre mitigations.") \ |
| 483 | v(bool, zeroStackFrame, false, Normal, "Zero stack frame on entry to a function.") \ |
| 484 | \ |
| 485 | v(bool, failToCompileWebAssemblyCode, false, Normal, "If true, no Wasm::Plan will sucessfully compile a function.") \ |
| 486 | v(size, webAssemblyPartialCompileLimit, 5000, Normal, "Limit on the number of bytes a Wasm::Plan::compile should attempt before checking for other work.") \ |
| 487 | v(unsigned, webAssemblyBBQOptimizationLevel, 0, Normal, "B3 Optimization level for BBQ Web Assembly module compilations.") \ |
| 488 | v(unsigned, webAssemblyOMGOptimizationLevel, Options::defaultB3OptLevel(), Normal, "B3 Optimization level for OMG Web Assembly module compilations.") \ |
| 489 | \ |
| 490 | v(bool, useBBQTierUpChecks, true, Normal, "Enables tier up checks for our BBQ code.") \ |
| 491 | v(unsigned, webAssemblyOMGTierUpCount, 5000, Normal, "The countdown before we tier up a function to OMG.") \ |
| 492 | v(unsigned, webAssemblyLoopDecrement, 15, Normal, "The amount the tier up countdown is decremented on each loop backedge.") \ |
| 493 | v(unsigned, webAssemblyFunctionEntryDecrement, 1, Normal, "The amount the tier up countdown is decremented on each function entry.") \ |
| 494 | \ |
| 495 | v(bool, useWebAssemblyFastMemory, true, Normal, "If true, we will try to use a 32-bit address space with a signal handler to bounds check wasm memory.") \ |
| 496 | v(bool, logWebAssemblyMemory, false, Normal, nullptr) \ |
| 497 | v(unsigned, webAssemblyFastMemoryRedzonePages, 128, Normal, "WebAssembly fast memories use 4GiB virtual allocations, plus a redzone (counted as multiple of 64KiB WebAssembly pages) at the end to catch reg+imm accesses which exceed 32-bit, anything beyond the redzone is explicitly bounds-checked") \ |
| 498 | v(bool, crashIfWebAssemblyCantFastMemory, false, Normal, "If true, we will crash if we can't obtain fast memory for wasm.") \ |
| 499 | v(unsigned, maxNumWebAssemblyFastMemories, 4, Normal, nullptr) \ |
| 500 | v(bool, useFastTLSForWasmContext, true, Normal, "If true, we will store context in fast TLS. If false, we will pin it to a register.") \ |
| 501 | v(bool, wasmBBQUsesAir, true, Normal, nullptr) \ |
| 502 | v(bool, useWebAssemblyStreamingApi, enableWebAssemblyStreamingApi, Normal, "Allow to run WebAssembly's Streaming API") \ |
| 503 | v(bool, useCallICsForWebAssemblyToJSCalls, true, Normal, "If true, we will use CallLinkInfo to inline cache Wasm to JS calls.") \ |
| 504 | v(bool, useEagerWebAssemblyModuleHashing, false, Normal, "Unnamed WebAssembly modules are identified in backtraces through their hash, if available.") \ |
| 505 | v(bool, useWebAssemblyReferences, true, Normal, "Allow types from the wasm references spec.") \ |
| 506 | v(bool, useBigInt, false, Normal, "If true, we will enable BigInt support.") \ |
| 507 | v(bool, useIntlNumberFormatToParts, enableIntlNumberFormatToParts, Normal, "If true, we will enable Intl.NumberFormat.prototype.formatToParts") \ |
| 508 | v(bool, useIntlPluralRules, enableIntlPluralRules, Normal, "If true, we will enable Intl.PluralRules.") \ |
| 509 | v(bool, useArrayAllocationProfiling, true, Normal, "If true, we will use our normal array allocation profiling. If false, the allocation profile will always claim to be undecided.") \ |
| 510 | v(bool, forcePolyProto, false, Normal, "If true, create_this will always create an object with a poly proto structure.") \ |
| 511 | v(bool, forceMiniVMMode, false, Normal, "If true, it will force mini VM mode on.") \ |
| 512 | v(bool, useTracePoints, false, Normal, nullptr) \ |
| 513 | v(bool, traceLLIntExecution, false, Configurable, nullptr) \ |
| 514 | v(bool, traceLLIntSlowPath, false, Configurable, nullptr) \ |
| 515 | v(bool, traceBaselineJITExecution, false, Normal, nullptr) \ |
| 516 | v(unsigned, thresholdForGlobalLexicalBindingEpoch, UINT_MAX, Normal, "Threshold for global lexical binding epoch. If the epoch reaches to this value, CodeBlock metadata for scope operations will be revised globally. It needs to be greater than 1.") \ |
| 517 | v(optionString, diskCachePath, nullptr, Restricted, nullptr) \ |
| 518 | v(bool, forceDiskCache, false, Restricted, nullptr) \ |
| 519 | v(bool, validateAbstractInterpreterState, false, Restricted, nullptr) \ |
| 520 | v(double, validateAbstractInterpreterStateProbability, 0.5, Normal, nullptr) \ |
| 521 | v(optionString, dumpJITMemoryPath, nullptr, Restricted, nullptr) \ |
| 522 | v(double, dumpJITMemoryFlushInterval, 10, Restricted, "Maximum time in between flushes of the JIT memory dump in seconds.") \ |
| 523 | |
| 524 | |
| 525 | enum OptionEquivalence { |
| 526 | SameOption, |
| 527 | InvertedOption, |
| 528 | }; |
| 529 | |
| 530 | #define JSC_ALIASED_OPTIONS(v) \ |
| 531 | v(enableFunctionDotArguments, useFunctionDotArguments, SameOption) \ |
| 532 | v(enableTailCalls, useTailCalls, SameOption) \ |
| 533 | v(showDisassembly, dumpDisassembly, SameOption) \ |
| 534 | v(showDFGDisassembly, dumpDFGDisassembly, SameOption) \ |
| 535 | v(showFTLDisassembly, dumpFTLDisassembly, SameOption) \ |
| 536 | v(showAllDFGNodes, dumpAllDFGNodes, SameOption) \ |
| 537 | v(alwaysDoFullCollection, useGenerationalGC, InvertedOption) \ |
| 538 | v(enableOSREntryToDFG, useOSREntryToDFG, SameOption) \ |
| 539 | v(enableOSREntryToFTL, useOSREntryToFTL, SameOption) \ |
| 540 | v(enableAccessInlining, useAccessInlining, SameOption) \ |
| 541 | v(enablePolyvariantDevirtualization, usePolyvariantDevirtualization, SameOption) \ |
| 542 | v(enablePolymorphicAccessInlining, usePolymorphicAccessInlining, SameOption) \ |
| 543 | v(enablePolymorphicCallInlining, usePolymorphicCallInlining, SameOption) \ |
| 544 | v(enableMovHintRemoval, useMovHintRemoval, SameOption) \ |
| 545 | v(enableObjectAllocationSinking, useObjectAllocationSinking, SameOption) \ |
| 546 | v(enableConcurrentJIT, useConcurrentJIT, SameOption) \ |
| 547 | v(enableProfiler, useProfiler, SameOption) \ |
| 548 | v(enableArchitectureSpecificOptimizations, useArchitectureSpecificOptimizations, SameOption) \ |
| 549 | v(enablePolyvariantCallInlining, usePolyvariantCallInlining, SameOption) \ |
| 550 | v(enablePolyvariantByIdInlining, usePolyvariantByIdInlining, SameOption) \ |
| 551 | v(enableMaximalFlushInsertionPhase, useMaximalFlushInsertionPhase, SameOption) \ |
| 552 | v(objectsAreImmortal, useImmortalObjects, SameOption) \ |
| 553 | v(showObjectStatistics, dumpObjectStatistics, SameOption) \ |
| 554 | v(disableGC, useGC, InvertedOption) \ |
| 555 | v(enableTypeProfiler, useTypeProfiler, SameOption) \ |
| 556 | v(enableControlFlowProfiler, useControlFlowProfiler, SameOption) \ |
| 557 | v(enableExceptionFuzz, useExceptionFuzz, SameOption) \ |
| 558 | v(enableExecutableAllocationFuzz, useExecutableAllocationFuzz, SameOption) \ |
| 559 | v(enableOSRExitFuzz, useOSRExitFuzz, SameOption) \ |
| 560 | v(enableDollarVM, useDollarVM, SameOption) \ |
| 561 | v(enableWebAssembly, useWebAssembly, SameOption) \ |
| 562 | v(verboseDFGByteCodeParsing, verboseDFGBytecodeParsing, SameOption) \ |
| 563 | v(maximumOptimizationCandidateInstructionCount, maximumOptimizationCandidateBytecodeCost, SameOption) \ |
| 564 | v(maximumFunctionForCallInlineCandidateInstructionCount, maximumFunctionForCallInlineCandidateBytecodeCost, SameOption) \ |
| 565 | v(maximumFunctionForClosureCallInlineCandidateInstructionCount, maximumFunctionForClosureCallInlineCandidateBytecodeCost, SameOption) \ |
| 566 | v(maximumFunctionForConstructInlineCandidateInstructionCount, maximumFunctionForConstructInlineCandidateBytecoodeCost, SameOption) \ |
| 567 | v(maximumFTLCandidateInstructionCount, maximumFTLCandidateBytecodeCost, SameOption) \ |
| 568 | v(maximumInliningCallerSize, maximumInliningCallerBytecodeCost, SameOption) \ |
| 569 | |
| 570 | |
| 571 | class Options { |
| 572 | public: |
| 573 | enum class DumpLevel { |
| 574 | None = 0, |
| 575 | Overridden, |
| 576 | All, |
| 577 | Verbose |
| 578 | }; |
| 579 | |
| 580 | enum class Availability { |
| 581 | Normal = 0, |
| 582 | Restricted, |
| 583 | Configurable |
| 584 | }; |
| 585 | |
| 586 | // This typedef is to allow us to eliminate the '_' in the field name in |
| 587 | // union inside Entry. This is needed to keep the style checker happy. |
| 588 | typedef int32_t int32; |
| 589 | typedef size_t size; |
| 590 | |
| 591 | // Declare the option IDs: |
| 592 | enum ID { |
| 593 | #define FOR_EACH_OPTION(type_, name_, defaultValue_, availability_, description_) \ |
| 594 | name_##ID, |
| 595 | JSC_OPTIONS(FOR_EACH_OPTION) |
| 596 | #undef FOR_EACH_OPTION |
| 597 | numberOfOptions |
| 598 | }; |
| 599 | |
| 600 | enum class Type { |
| 601 | boolType, |
| 602 | unsignedType, |
| 603 | doubleType, |
| 604 | int32Type, |
| 605 | sizeType, |
| 606 | optionRangeType, |
| 607 | optionStringType, |
| 608 | gcLogLevelType, |
| 609 | }; |
| 610 | |
| 611 | JS_EXPORT_PRIVATE static void initialize(); |
| 612 | |
| 613 | // Parses a string of options where each option is of the format "--<optionName>=<value>" |
| 614 | // and are separated by a space. The leading "--" is optional and will be ignored. |
| 615 | JS_EXPORT_PRIVATE static bool setOptions(const char* optionsList); |
| 616 | |
| 617 | // Parses a single command line option in the format "<optionName>=<value>" |
| 618 | // (no spaces allowed) and set the specified option if appropriate. |
| 619 | JS_EXPORT_PRIVATE static bool setOption(const char* arg); |
| 620 | |
| 621 | JS_EXPORT_PRIVATE static void dumpAllOptions(FILE*, DumpLevel, const char* title = nullptr); |
| 622 | JS_EXPORT_PRIVATE static void dumpAllOptionsInALine(StringBuilder&); |
| 623 | |
| 624 | JS_EXPORT_PRIVATE static void ensureOptionsAreCoherent(); |
| 625 | |
| 626 | JS_EXPORT_PRIVATE static void enableRestrictedOptions(bool enableOrNot); |
| 627 | |
| 628 | // Declare accessors for each option: |
| 629 | #define FOR_EACH_OPTION(type_, name_, defaultValue_, availability_, description_) \ |
| 630 | ALWAYS_INLINE static type_& name_() { return s_options[name_##ID].type_##Val; } \ |
| 631 | ALWAYS_INLINE static type_& name_##Default() { return s_defaultOptions[name_##ID].type_##Val; } |
| 632 | |
| 633 | JSC_OPTIONS(FOR_EACH_OPTION) |
| 634 | #undef FOR_EACH_OPTION |
| 635 | |
| 636 | static bool isAvailable(ID, Availability); |
| 637 | |
| 638 | private: |
| 639 | // For storing for an option value: |
| 640 | union Entry { |
| 641 | bool boolVal; |
| 642 | unsigned unsignedVal; |
| 643 | double doubleVal; |
| 644 | int32 int32Val; |
| 645 | size sizeVal; |
| 646 | OptionRange optionRangeVal; |
| 647 | const char* optionStringVal; |
| 648 | GCLogging::Level gcLogLevelVal; |
| 649 | }; |
| 650 | |
| 651 | // For storing constant meta data about each option: |
| 652 | struct EntryInfo { |
| 653 | const char* name; |
| 654 | const char* description; |
| 655 | Type type; |
| 656 | Availability availability; |
| 657 | }; |
| 658 | |
| 659 | Options(); |
| 660 | |
| 661 | enum DumpDefaultsOption { |
| 662 | DontDumpDefaults, |
| 663 | DumpDefaults |
| 664 | }; |
| 665 | static void dumpOptionsIfNeeded(); |
| 666 | static void dumpAllOptions(StringBuilder&, DumpLevel, const char* title, |
| 667 | const char* separator, const char* , const char* , DumpDefaultsOption); |
| 668 | static void dumpOption(StringBuilder&, DumpLevel, ID, |
| 669 | const char* , const char* , DumpDefaultsOption); |
| 670 | |
| 671 | static bool setOptionWithoutAlias(const char* arg); |
| 672 | static bool setAliasedOption(const char* arg); |
| 673 | static bool overrideAliasedOptionWithHeuristic(const char* name); |
| 674 | |
| 675 | // Declare the singleton instance of the options store: |
| 676 | JS_EXPORT_PRIVATE static Entry s_options[numberOfOptions]; |
| 677 | static Entry s_defaultOptions[numberOfOptions]; |
| 678 | static const EntryInfo s_optionsInfo[numberOfOptions]; |
| 679 | |
| 680 | friend class Option; |
| 681 | }; |
| 682 | |
| 683 | class Option { |
| 684 | public: |
| 685 | Option(Options::ID id) |
| 686 | : m_id(id) |
| 687 | , m_entry(Options::s_options[m_id]) |
| 688 | { |
| 689 | } |
| 690 | |
| 691 | void dump(StringBuilder&) const; |
| 692 | |
| 693 | bool operator==(const Option& other) const; |
| 694 | bool operator!=(const Option& other) const { return !(*this == other); } |
| 695 | |
| 696 | Options::ID id() const { return m_id; } |
| 697 | const char* name() const; |
| 698 | const char* description() const; |
| 699 | Options::Type type() const; |
| 700 | Options::Availability availability() const; |
| 701 | bool isOverridden() const; |
| 702 | const Option defaultOption() const; |
| 703 | |
| 704 | bool& boolVal(); |
| 705 | unsigned& unsignedVal(); |
| 706 | double& doubleVal(); |
| 707 | int32_t& int32Val(); |
| 708 | OptionRange optionRangeVal(); |
| 709 | const char* optionStringVal(); |
| 710 | GCLogging::Level& gcLogLevelVal(); |
| 711 | |
| 712 | private: |
| 713 | // Only used for constructing default Options. |
| 714 | Option(Options::ID id, Options::Entry& entry) |
| 715 | : m_id(id) |
| 716 | , m_entry(entry) |
| 717 | { |
| 718 | } |
| 719 | |
| 720 | Options::ID m_id; |
| 721 | Options::Entry& m_entry; |
| 722 | }; |
| 723 | |
| 724 | inline const char* Option::name() const |
| 725 | { |
| 726 | return Options::s_optionsInfo[m_id].name; |
| 727 | } |
| 728 | |
| 729 | inline const char* Option::description() const |
| 730 | { |
| 731 | return Options::s_optionsInfo[m_id].description; |
| 732 | } |
| 733 | |
| 734 | inline Options::Type Option::type() const |
| 735 | { |
| 736 | return Options::s_optionsInfo[m_id].type; |
| 737 | } |
| 738 | |
| 739 | inline Options::Availability Option::availability() const |
| 740 | { |
| 741 | return Options::s_optionsInfo[m_id].availability; |
| 742 | } |
| 743 | |
| 744 | inline bool Option::isOverridden() const |
| 745 | { |
| 746 | return *this != defaultOption(); |
| 747 | } |
| 748 | |
| 749 | inline const Option Option::defaultOption() const |
| 750 | { |
| 751 | return Option(m_id, Options::s_defaultOptions[m_id]); |
| 752 | } |
| 753 | |
| 754 | inline bool& Option::boolVal() |
| 755 | { |
| 756 | return m_entry.boolVal; |
| 757 | } |
| 758 | |
| 759 | inline unsigned& Option::unsignedVal() |
| 760 | { |
| 761 | return m_entry.unsignedVal; |
| 762 | } |
| 763 | |
| 764 | inline double& Option::doubleVal() |
| 765 | { |
| 766 | return m_entry.doubleVal; |
| 767 | } |
| 768 | |
| 769 | inline int32_t& Option::int32Val() |
| 770 | { |
| 771 | return m_entry.int32Val; |
| 772 | } |
| 773 | |
| 774 | inline OptionRange Option::optionRangeVal() |
| 775 | { |
| 776 | return m_entry.optionRangeVal; |
| 777 | } |
| 778 | |
| 779 | inline const char* Option::optionStringVal() |
| 780 | { |
| 781 | return m_entry.optionStringVal; |
| 782 | } |
| 783 | |
| 784 | inline GCLogging::Level& Option::gcLogLevelVal() |
| 785 | { |
| 786 | return m_entry.gcLogLevelVal; |
| 787 | } |
| 788 | |
| 789 | } // namespace JSC |
| 790 | |