2 * Copyright (C) 2011-2019 Apple Inc. All rights reserved.
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions
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.
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.
28 #include "GCLogging.h"
29 #include "JSExportMacros.h"
32 #include <wtf/PrintStream.h>
33 #include <wtf/StdLibExtras.h>
38 using WTF::StringBuilder;
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.
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
54 // bool jitIsOn = Options::useJIT(); // Get the option value.
55 // Options::useJIT() = false; // Sets the option value.
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
61 // Alternatively, you can override the default values by specifying
62 // environment variables of the form: JSC_<name of JSC option>.
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.
72 enum RangeState { Uninitialized, InitError, Normal, Inverted };
74 OptionRange& operator= (const int& rhs)
75 { // Only needed for initialization
77 m_state = Uninitialized;
85 bool init(const char*);
86 bool isInRange(unsigned);
87 const char* rangeString() const { return (m_state > InitError) ? m_rangeString : s_nullRangeStr; }
89 void dump(PrintStream& out) const;
92 static const char* const s_nullRangeStr;
95 const char* m_rangeString;
100 typedef OptionRange optionRange;
101 typedef const char* optionString;
103 #if PLATFORM(IOS_FAMILY)
104 #define MAXIMUM_NUMBER_OF_FTL_COMPILER_THREADS 2
106 #define MAXIMUM_NUMBER_OF_FTL_COMPILER_THREADS 8
109 #if ENABLE(WEBASSEMBLY_STREAMING_API)
110 constexpr bool enableWebAssemblyStreamingApi = true;
112 constexpr bool enableWebAssemblyStreamingApi = false;
115 #define JSC_OPTIONS(v) \
116 v(bool, useKernTCSM, true, Normal, "Note: this needs to go before other options since they depend on this value.") \
117 v(bool, validateOptions, false, Normal, "crashes if mis-typed JSC options were passed to the VM") \
118 v(unsigned, dumpOptions, 0, Normal, "dumps JSC options (0 = None, 1 = Overridden only, 2 = All, 3 = Verbose)") \
119 v(optionString, configFile, nullptr, Normal, "file to configure JSC options and logging location") \
121 v(bool, useLLInt, true, Normal, "allows the LLINT to be used if true") \
122 v(bool, useJIT, jitEnabledByDefault(), Normal, "allows the executable pages to be allocated for JIT and thunks if true") \
123 v(bool, useBaselineJIT, true, Normal, "allows the baseline JIT to be used if true") \
124 v(bool, useDFGJIT, true, Normal, "allows the DFG JIT to be used if true") \
125 v(bool, useRegExpJIT, jitEnabledByDefault(), Normal, "allows the RegExp JIT to be used if true") \
126 v(bool, useDOMJIT, is64Bit(), Normal, "allows the DOMJIT to be used if true") \
128 v(bool, reportMustSucceedExecutableAllocations, false, Normal, nullptr) \
130 v(unsigned, maxPerThreadStackUsage, 4 * MB, Normal, "Max allowed stack usage by the VM") \
131 v(unsigned, softReservedZoneSize, 128 * KB, Normal, "A buffer greater than reservedZoneSize that reserves space for stringifying exceptions.") \
132 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).") \
134 v(bool, crashIfCantAllocateJITMemory, false, Normal, nullptr) \
135 v(unsigned, jitMemoryReservationSize, 0, Normal, "Set this number to change the executable allocation size in ExecutableAllocatorFixedVMPool. (In bytes.)") \
136 v(bool, useSeparatedWXHeap, false, Normal, nullptr) \
138 v(bool, forceCodeBlockLiveness, false, Normal, nullptr) \
139 v(bool, forceICFailure, false, Normal, nullptr) \
141 v(unsigned, repatchCountForCoolDown, 8, Normal, nullptr) \
142 v(unsigned, initialCoolDownCount, 20, Normal, nullptr) \
143 v(unsigned, repatchBufferingCountdown, 8, Normal, nullptr) \
145 v(bool, dumpGeneratedBytecodes, false, Normal, nullptr) \
146 v(bool, dumpBytecodeLivenessResults, false, Normal, nullptr) \
147 v(bool, validateBytecode, false, Normal, nullptr) \
148 v(bool, forceDebuggerBytecodeGeneration, false, Normal, nullptr) \
149 v(bool, dumpBytecodesBeforeGeneratorification, false, Normal, nullptr) \
151 v(bool, useFunctionDotArguments, true, Normal, nullptr) \
152 v(bool, useTailCalls, true, Normal, nullptr) \
153 v(bool, optimizeRecursiveTailCalls, true, Normal, nullptr) \
154 v(bool, alwaysUseShadowChicken, false, Normal, nullptr) \
155 v(unsigned, shadowChickenLogSize, 1000, Normal, nullptr) \
156 v(unsigned, shadowChickenMaxTailDeletedFramesSize, 128, Normal, nullptr) \
158 /* dumpDisassembly implies dumpDFGDisassembly. */ \
159 v(bool, dumpDisassembly, false, Normal, "dumps disassembly of all JIT compiled code upon compilation") \
160 v(bool, asyncDisassembly, false, Normal, nullptr) \
161 v(bool, dumpDFGDisassembly, false, Normal, "dumps disassembly of DFG function upon compilation") \
162 v(bool, dumpFTLDisassembly, false, Normal, "dumps disassembly of FTL function upon compilation") \
163 v(bool, dumpRegExpDisassembly, false, Normal, "dumps disassembly of RegExp upon compilation") \
164 v(bool, dumpAllDFGNodes, false, Normal, nullptr) \
165 v(bool, logJITCodeForPerf, false, Configurable, nullptr) \
166 v(optionRange, bytecodeRangeToJITCompile, 0, Normal, "bytecode size range to allow compilation on, e.g. 1:100") \
167 v(optionRange, bytecodeRangeToDFGCompile, 0, Normal, "bytecode size range to allow DFG compilation on, e.g. 1:100") \
168 v(optionRange, bytecodeRangeToFTLCompile, 0, Normal, "bytecode size range to allow FTL compilation on, e.g. 1:100") \
169 v(optionString, jitWhitelist, nullptr, Normal, "file with list of function signatures to allow compilation on") \
170 v(optionString, dfgWhitelist, nullptr, Normal, "file with list of function signatures to allow DFG compilation on") \
171 v(optionString, ftlWhitelist, nullptr, Normal, "file with list of function signatures to allow FTL compilation on") \
172 v(bool, dumpSourceAtDFGTime, false, Normal, "dumps source code of JS function being DFG compiled") \
173 v(bool, dumpBytecodeAtDFGTime, false, Normal, "dumps bytecode of JS function being DFG compiled") \
174 v(bool, dumpGraphAfterParsing, false, Normal, nullptr) \
175 v(bool, dumpGraphAtEachPhase, false, Normal, nullptr) \
176 v(bool, dumpDFGGraphAtEachPhase, false, Normal, "dumps the DFG graph at each phase of DFG compilation (note this excludes DFG graphs during FTL compilation)") \
177 v(bool, dumpDFGFTLGraphAtEachPhase, false, Normal, "dumps the DFG graph at each phase of DFG compilation when compiling FTL code") \
178 v(bool, dumpB3GraphAtEachPhase, false, Normal, "dumps the B3 graph at each phase of compilation") \
179 v(bool, dumpAirGraphAtEachPhase, false, Normal, "dumps the Air graph at each phase of compilation") \
180 v(bool, verboseDFGBytecodeParsing, false, Normal, nullptr) \
181 v(bool, safepointBeforeEachPhase, true, Normal, nullptr) \
182 v(bool, verboseCompilation, false, Normal, nullptr) \
183 v(bool, verboseFTLCompilation, false, Normal, nullptr) \
184 v(bool, logCompilationChanges, false, Normal, nullptr) \
185 v(bool, useProbeOSRExit, false, Normal, nullptr) \
186 v(bool, printEachOSRExit, false, Normal, nullptr) \
187 v(bool, validateGraph, false, Normal, nullptr) \
188 v(bool, validateGraphAtEachPhase, false, Normal, nullptr) \
189 v(bool, verboseValidationFailure, false, Normal, nullptr) \
190 v(bool, verboseOSR, false, Normal, nullptr) \
191 v(bool, verboseDFGOSRExit, false, Normal, nullptr) \
192 v(bool, verboseFTLOSRExit, false, Normal, nullptr) \
193 v(bool, verboseCallLink, false, Normal, nullptr) \
194 v(bool, verboseCompilationQueue, false, Normal, nullptr) \
195 v(bool, reportCompileTimes, false, Normal, "dumps JS function signature and the time it took to compile in all tiers") \
196 v(bool, reportBaselineCompileTimes, false, Normal, "dumps JS function signature and the time it took to BaselineJIT compile") \
197 v(bool, reportDFGCompileTimes, false, Normal, "dumps JS function signature and the time it took to DFG and FTL compile") \
198 v(bool, reportFTLCompileTimes, false, Normal, "dumps JS function signature and the time it took to FTL compile") \
199 v(bool, reportTotalCompileTimes, false, Normal, nullptr) \
200 v(bool, reportParseTimes, false, Normal, "dumps JS function signature and the time it took to parse") \
201 v(bool, reportBytecodeCompileTimes, false, Normal, "dumps JS function signature and the time it took to bytecode compile") \
202 v(bool, countParseTimes, false, Normal, "counts parse times") \
203 v(bool, verboseExitProfile, false, Normal, nullptr) \
204 v(bool, verboseCFA, false, Normal, nullptr) \
205 v(bool, verboseDFGFailure, false, Normal, nullptr) \
206 v(bool, verboseFTLToJSThunk, false, Normal, nullptr) \
207 v(bool, verboseFTLFailure, false, Normal, nullptr) \
208 v(bool, alwaysComputeHash, false, Normal, nullptr) \
209 v(bool, testTheFTL, false, Normal, nullptr) \
210 v(bool, verboseSanitizeStack, false, Normal, nullptr) \
211 v(bool, useGenerationalGC, true, Normal, nullptr) \
212 v(bool, useConcurrentGC, true, Normal, nullptr) \
213 v(bool, collectContinuously, false, Normal, nullptr) \
214 v(double, collectContinuouslyPeriodMS, 1, Normal, nullptr) \
215 v(bool, forceFencedBarrier, false, Normal, nullptr) \
216 v(bool, verboseVisitRace, false, Normal, nullptr) \
217 v(bool, optimizeParallelSlotVisitorsForStoppedMutator, false, Normal, nullptr) \
218 v(unsigned, largeHeapSize, 32 * 1024 * 1024, Normal, nullptr) \
219 v(unsigned, smallHeapSize, 1 * 1024 * 1024, Normal, nullptr) \
220 v(double, smallHeapRAMFraction, 0.25, Normal, nullptr) \
221 v(double, smallHeapGrowthFactor, 2, Normal, nullptr) \
222 v(double, mediumHeapRAMFraction, 0.5, Normal, nullptr) \
223 v(double, mediumHeapGrowthFactor, 1.5, Normal, nullptr) \
224 v(double, largeHeapGrowthFactor, 1.24, Normal, nullptr) \
225 v(double, miniVMHeapGrowthFactor, 1.27, Normal, nullptr) \
226 v(double, criticalGCMemoryThreshold, 0.80, Normal, "percent memory in use the GC considers critical. The collector is much more aggressive above this threshold") \
227 v(double, minimumMutatorUtilization, 0, Normal, nullptr) \
228 v(double, maximumMutatorUtilization, 0.7, Normal, nullptr) \
229 v(double, epsilonMutatorUtilization, 0.01, Normal, nullptr) \
230 v(double, concurrentGCMaxHeadroom, 1.5, Normal, nullptr) \
231 v(double, concurrentGCPeriodMS, 2, Normal, nullptr) \
232 v(bool, useStochasticMutatorScheduler, true, Normal, nullptr) \
233 v(double, minimumGCPauseMS, 0.3, Normal, nullptr) \
234 v(double, gcPauseScale, 0.3, Normal, nullptr) \
235 v(double, gcIncrementBytes, 10000, Normal, nullptr) \
236 v(double, gcIncrementMaxBytes, 100000, Normal, nullptr) \
237 v(double, gcIncrementScale, 0, Normal, nullptr) \
238 v(bool, scribbleFreeCells, false, Normal, nullptr) \
239 v(double, sizeClassProgression, 1.4, Normal, nullptr) \
240 v(unsigned, largeAllocationCutoff, 100000, Normal, nullptr) \
241 v(bool, dumpSizeClasses, false, Normal, nullptr) \
242 v(bool, useBumpAllocator, true, Normal, nullptr) \
243 v(bool, stealEmptyBlocksFromOtherAllocators, true, Normal, nullptr) \
244 v(bool, eagerlyUpdateTopCallFrame, false, Normal, nullptr) \
245 v(bool, dumpZappedCellCrashData, false, Normal, nullptr) \
247 v(bool, useOSREntryToDFG, true, Normal, nullptr) \
248 v(bool, useOSREntryToFTL, true, Normal, nullptr) \
250 v(bool, useFTLJIT, true, Normal, "allows the FTL JIT to be used if true") \
251 v(bool, useFTLTBAA, true, Normal, nullptr) \
252 v(bool, validateFTLOSRExitLiveness, false, Normal, nullptr) \
253 v(unsigned, defaultB3OptLevel, 2, Normal, nullptr) \
254 v(bool, b3AlwaysFailsBeforeCompile, false, Normal, nullptr) \
255 v(bool, b3AlwaysFailsBeforeLink, false, Normal, nullptr) \
256 v(bool, ftlCrashes, false, Normal, nullptr) /* fool-proof way of checking that you ended up in the FTL. ;-) */\
257 v(bool, clobberAllRegsInFTLICSlowPath, !ASSERT_DISABLED, Normal, nullptr) \
258 v(bool, enableJITDebugAssertions, !ASSERT_DISABLED, Normal, nullptr) \
259 v(bool, useAccessInlining, true, Normal, nullptr) \
260 v(unsigned, maxAccessVariantListSize, 8, Normal, nullptr) \
261 v(bool, usePolyvariantDevirtualization, true, Normal, nullptr) \
262 v(bool, usePolymorphicAccessInlining, true, Normal, nullptr) \
263 v(unsigned, maxPolymorphicAccessInliningListSize, 8, Normal, nullptr) \
264 v(bool, usePolymorphicCallInlining, true, Normal, nullptr) \
265 v(bool, usePolymorphicCallInliningForNonStubStatus, false, Normal, nullptr) \
266 v(unsigned, maxPolymorphicCallVariantListSize, 15, Normal, nullptr) \
267 v(unsigned, maxPolymorphicCallVariantListSizeForTopTier, 5, Normal, nullptr) \
268 v(unsigned, maxPolymorphicCallVariantListSizeForWebAssemblyToJS, 5, Normal, nullptr) \
269 v(unsigned, maxPolymorphicCallVariantsForInlining, 5, Normal, nullptr) \
270 v(unsigned, frequentCallThreshold, 2, Normal, nullptr) \
271 v(double, minimumCallToKnownRate, 0.51, Normal, nullptr) \
272 v(bool, createPreHeaders, true, Normal, nullptr) \
273 v(bool, useMovHintRemoval, true, Normal, nullptr) \
274 v(bool, usePutStackSinking, true, Normal, nullptr) \
275 v(bool, useObjectAllocationSinking, true, Normal, nullptr) \
276 v(bool, useValueRepElimination, true, Normal, nullptr) \
277 v(bool, useArityFixupInlining, true, Normal, nullptr) \
278 v(bool, logExecutableAllocation, false, Normal, nullptr) \
279 v(unsigned, maxDFGNodesInBasicBlockForPreciseAnalysis, 20000, Normal, "Disable precise but costly analysis and give conservative results if the number of DFG nodes in a block exceeds this threshold") \
281 v(bool, useConcurrentJIT, true, Normal, "allows the DFG / FTL compilation in threads other than the executing JS thread") \
282 v(unsigned, numberOfDFGCompilerThreads, computeNumberOfWorkerThreads(3, 2) - 1, Normal, nullptr) \
283 v(unsigned, numberOfFTLCompilerThreads, computeNumberOfWorkerThreads(MAXIMUM_NUMBER_OF_FTL_COMPILER_THREADS, 2) - 1, Normal, nullptr) \
284 v(int32, priorityDeltaOfDFGCompilerThreads, computePriorityDeltaOfWorkerThreads(-1, 0), Normal, nullptr) \
285 v(int32, priorityDeltaOfFTLCompilerThreads, computePriorityDeltaOfWorkerThreads(-2, 0), Normal, nullptr) \
286 v(int32, priorityDeltaOfWasmCompilerThreads, computePriorityDeltaOfWorkerThreads(-1, 0), Normal, nullptr) \
288 v(bool, useProfiler, false, Normal, nullptr) \
289 v(bool, disassembleBaselineForProfiler, true, Normal, nullptr) \
291 v(bool, useArchitectureSpecificOptimizations, true, Normal, nullptr) \
293 v(bool, breakOnThrow, false, Normal, nullptr) \
295 v(unsigned, maximumOptimizationCandidateBytecodeCost, 100000, Normal, nullptr) \
297 v(unsigned, maximumFunctionForCallInlineCandidateBytecodeCost, 120, Normal, nullptr) \
298 v(unsigned, maximumFunctionForClosureCallInlineCandidateBytecodeCost, 100, Normal, nullptr) \
299 v(unsigned, maximumFunctionForConstructInlineCandidateBytecoodeCost, 100, Normal, nullptr) \
301 v(unsigned, maximumFTLCandidateBytecodeCost, 20000, Normal, nullptr) \
303 /* Depth of inline stack, so 1 = no inlining, 2 = one level, etc. */ \
304 v(unsigned, maximumInliningDepth, 5, Normal, "maximum allowed inlining depth. Depth of 1 means no inlining") \
305 v(unsigned, maximumInliningRecursion, 2, Normal, nullptr) \
307 /* Maximum size of a caller for enabling inlining. This is purely to protect us */\
308 /* from super long compiles that take a lot of memory. */\
309 v(unsigned, maximumInliningCallerBytecodeCost, 10000, Normal, nullptr) \
311 v(unsigned, maximumVarargsForInlining, 100, Normal, nullptr) \
313 v(bool, useMaximalFlushInsertionPhase, false, Normal, "Setting to true allows the DFG's MaximalFlushInsertionPhase to run.") \
315 v(unsigned, maximumBinaryStringSwitchCaseLength, 50, Normal, nullptr) \
316 v(unsigned, maximumBinaryStringSwitchTotalLength, 2000, Normal, nullptr) \
318 v(double, jitPolicyScale, 1.0, Normal, "scale JIT thresholds to this specified ratio between 0.0 (compile ASAP) and 1.0 (compile like normal).") \
319 v(bool, forceEagerCompilation, false, Normal, nullptr) \
320 v(int32, thresholdForJITAfterWarmUp, 500, Normal, nullptr) \
321 v(int32, thresholdForJITSoon, 100, Normal, nullptr) \
323 v(int32, thresholdForOptimizeAfterWarmUp, 1000, Normal, nullptr) \
324 v(int32, thresholdForOptimizeAfterLongWarmUp, 1000, Normal, nullptr) \
325 v(int32, thresholdForOptimizeSoon, 1000, Normal, nullptr) \
326 v(int32, executionCounterIncrementForLoop, 1, Normal, nullptr) \
327 v(int32, executionCounterIncrementForEntry, 15, Normal, nullptr) \
329 v(int32, thresholdForFTLOptimizeAfterWarmUp, 100000, Normal, nullptr) \
330 v(int32, thresholdForFTLOptimizeSoon, 1000, Normal, nullptr) \
331 v(int32, ftlTierUpCounterIncrementForLoop, 1, Normal, nullptr) \
332 v(int32, ftlTierUpCounterIncrementForReturn, 15, Normal, nullptr) \
333 v(unsigned, ftlOSREntryFailureCountForReoptimization, 15, Normal, nullptr) \
334 v(unsigned, ftlOSREntryRetryThreshold, 100, Normal, nullptr) \
336 v(int32, evalThresholdMultiplier, 10, Normal, nullptr) \
337 v(unsigned, maximumEvalCacheableSourceLength, 256, Normal, nullptr) \
339 v(bool, randomizeExecutionCountsBetweenCheckpoints, false, Normal, nullptr) \
340 v(int32, maximumExecutionCountsBetweenCheckpointsForBaseline, 1000, Normal, nullptr) \
341 v(int32, maximumExecutionCountsBetweenCheckpointsForUpperTiers, 50000, Normal, nullptr) \
343 v(unsigned, likelyToTakeSlowCaseMinimumCount, 20, Normal, nullptr) \
344 v(unsigned, couldTakeSlowCaseMinimumCount, 10, Normal, nullptr) \
346 v(unsigned, osrExitCountForReoptimization, 100, Normal, nullptr) \
347 v(unsigned, osrExitCountForReoptimizationFromLoop, 5, Normal, nullptr) \
349 v(unsigned, reoptimizationRetryCounterMax, 0, Normal, nullptr) \
351 v(unsigned, minimumOptimizationDelay, 1, Normal, nullptr) \
352 v(unsigned, maximumOptimizationDelay, 5, Normal, nullptr) \
353 v(double, desiredProfileLivenessRate, 0.75, Normal, nullptr) \
354 v(double, desiredProfileFullnessRate, 0.35, Normal, nullptr) \
356 v(double, doubleVoteRatioForDoubleFormat, 2, Normal, nullptr) \
357 v(double, structureCheckVoteRatioForHoisting, 1, Normal, nullptr) \
358 v(double, checkArrayVoteRatioForHoisting, 1, Normal, nullptr) \
360 v(unsigned, maximumDirectCallStackSize, 200, Normal, nullptr) \
362 v(unsigned, minimumNumberOfScansBetweenRebalance, 100, Normal, nullptr) \
363 v(unsigned, numberOfGCMarkers, computeNumberOfGCMarkers(8), Normal, nullptr) \
364 v(bool, useParallelMarkingConstraintSolver, true, Normal, nullptr) \
365 v(unsigned, opaqueRootMergeThreshold, 1000, Normal, nullptr) \
366 v(double, minHeapUtilization, 0.8, Normal, nullptr) \
367 v(double, minMarkedBlockUtilization, 0.9, Normal, nullptr) \
368 v(unsigned, slowPathAllocsBetweenGCs, 0, Normal, "force a GC on every Nth slow path alloc, where N is specified by this option") \
370 v(double, percentCPUPerMBForFullTimer, 0.0003125, Normal, nullptr) \
371 v(double, percentCPUPerMBForEdenTimer, 0.0025, Normal, nullptr) \
372 v(double, collectionTimerMaxPercentCPU, 0.05, Normal, nullptr) \
374 v(bool, forceWeakRandomSeed, false, Normal, nullptr) \
375 v(unsigned, forcedWeakRandomSeed, 0, Normal, nullptr) \
377 v(bool, useZombieMode, false, Normal, "debugging option to scribble over dead objects with 0xbadbeef0") \
378 v(bool, useImmortalObjects, false, Normal, "debugging option to keep all objects alive forever") \
379 v(bool, sweepSynchronously, false, Normal, "debugging option to sweep all dead objects synchronously at GC end before resuming mutator") \
380 v(unsigned, maxSingleAllocationSize, 0, Configurable, "debugging option to limit individual allocations to a max size (0 = limit not set, N = limit size in bytes)") \
382 v(gcLogLevel, logGC, GCLogging::None, Normal, "debugging option to log GC activity (0 = None, 1 = Basic, 2 = Verbose)") \
383 v(bool, useGC, true, Normal, nullptr) \
384 v(bool, gcAtEnd, false, Normal, "If true, the jsc CLI will do a GC before exiting") \
385 v(bool, forceGCSlowPaths, false, Normal, "If true, we will force all JIT fast allocations down their slow paths.") \
386 v(unsigned, gcMaxHeapSize, 0, Normal, nullptr) \
387 v(unsigned, forceRAMSize, 0, Normal, nullptr) \
388 v(bool, recordGCPauseTimes, false, Normal, nullptr) \
389 v(bool, dumpHeapStatisticsAtVMDestruction, false, Normal, nullptr) \
390 v(bool, forceCodeBlockToJettisonDueToOldAge, false, Normal, "If true, this means that anytime we can jettison a CodeBlock due to old age, we do.") \
391 v(bool, useEagerCodeBlockJettisonTiming, false, Normal, "If true, the time slices for jettisoning a CodeBlock due to old age are shrunk significantly.") \
393 v(bool, useTypeProfiler, false, Normal, nullptr) \
394 v(bool, useControlFlowProfiler, false, Normal, nullptr) \
396 v(bool, useSamplingProfiler, false, Normal, nullptr) \
397 v(unsigned, sampleInterval, 1000, Normal, "Time between stack traces in microseconds.") \
398 v(bool, collectSamplingProfilerDataForJSCShell, false, Normal, "This corresponds to the JSC shell's --sample option.") \
399 v(unsigned, samplingProfilerTopFunctionsCount, 12, Normal, "Number of top functions to report when using the command line interface.") \
400 v(unsigned, samplingProfilerTopBytecodesCount, 40, Normal, "Number of top bytecodes to report when using the command line interface.") \
401 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.") \
402 v(bool, sampleCCode, false, Normal, "Causes the sampling profiler to record profiling data for C frames.") \
404 v(bool, alwaysGeneratePCToCodeOriginMap, false, Normal, "This will make sure we always generate a PCToCodeOriginMap for JITed code.") \
406 v(bool, verifyHeap, false, Normal, nullptr) \
407 v(unsigned, numberOfGCCyclesToRecordForVerification, 3, Normal, nullptr) \
409 v(unsigned, exceptionStackTraceLimit, 100, Normal, "Stack trace limit for internal Exception object") \
410 v(unsigned, defaultErrorStackTraceLimit, 100, Normal, "The default value for Error.stackTraceLimit") \
411 v(bool, useExceptionFuzz, false, Normal, nullptr) \
412 v(unsigned, fireExceptionFuzzAt, 0, Normal, nullptr) \
413 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 */\
414 v(bool, dumpSimulatedThrows, false, Normal, "Dumps the call stack of the last simulated throw if exception scope verification fails") \
415 v(bool, validateExceptionChecks, false, Normal, "Verifies that needed exception checks are performed.") \
416 v(unsigned, unexpectedExceptionStackTraceLimit, 100, Normal, "Stack trace limit for debugging unexpected exceptions observed in the VM") \
418 v(bool, useExecutableAllocationFuzz, false, Normal, nullptr) \
419 v(unsigned, fireExecutableAllocationFuzzAt, 0, Normal, nullptr) \
420 v(unsigned, fireExecutableAllocationFuzzAtOrAfter, 0, Normal, nullptr) \
421 v(bool, verboseExecutableAllocationFuzz, false, Normal, nullptr) \
423 v(bool, useOSRExitFuzz, false, Normal, nullptr) \
424 v(unsigned, fireOSRExitFuzzAtStatic, 0, Normal, nullptr) \
425 v(unsigned, fireOSRExitFuzzAt, 0, Normal, nullptr) \
426 v(unsigned, fireOSRExitFuzzAtOrAfter, 0, Normal, nullptr) \
428 v(bool, useRandomizingFuzzerAgent, false, Normal, nullptr) \
429 v(unsigned, seedOfRandomizingFuzzerAgent, 1, Normal, nullptr) \
430 v(bool, dumpRandomizingFuzzerAgentPredictions, false, Normal, nullptr) \
431 v(bool, useDoublePredictionFuzzerAgent, false, Normal, nullptr) \
433 v(bool, logPhaseTimes, false, Normal, nullptr) \
434 v(double, rareBlockPenalty, 0.001, Normal, nullptr) \
435 v(bool, airLinearScanVerbose, false, Normal, nullptr) \
436 v(bool, airLinearScanSpillsEverything, false, Normal, nullptr) \
437 v(bool, airForceBriggsAllocator, false, Normal, nullptr) \
438 v(bool, airForceIRCAllocator, false, Normal, nullptr) \
439 v(bool, airRandomizeRegs, false, Normal, nullptr) \
440 v(unsigned, airRandomizeRegsSeed, 0, Normal, nullptr) \
441 v(bool, coalesceSpillSlots, true, Normal, nullptr) \
442 v(bool, logAirRegisterPressure, false, Normal, nullptr) \
443 v(bool, useB3TailDup, true, Normal, nullptr) \
444 v(unsigned, maxB3TailDupBlockSize, 3, Normal, nullptr) \
445 v(unsigned, maxB3TailDupBlockSuccessors, 3, Normal, nullptr) \
447 v(bool, useDollarVM, false, Restricted, "installs the $vm debugging tool in global objects") \
448 v(optionString, functionOverrides, nullptr, Restricted, "file with debugging overrides for function bodies") \
449 v(bool, useSigillCrashAnalyzer, false, Configurable, "logs data about SIGILL crashes") \
451 v(unsigned, watchdog, 0, Normal, "watchdog timeout (0 = Disabled, N = a timeout period of N milliseconds)") \
452 v(bool, usePollingTraps, false, Normal, "use polling (instead of signalling) VM traps") \
454 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)") \
456 v(bool, useICStats, false, Normal, nullptr) \
458 v(unsigned, prototypeHitCountForLLIntCaching, 2, Normal, "Number of prototype property hits before caching a prototype in the LLInt. A count of 0 means never cache.") \
460 v(bool, dumpCompiledRegExpPatterns, false, Normal, nullptr) \
462 v(bool, dumpModuleRecord, false, Normal, nullptr) \
463 v(bool, dumpModuleLoadingState, false, Normal, nullptr) \
464 v(bool, exposeInternalModuleLoader, false, Normal, "expose the internal module loader object to the global space for debugging") \
466 v(bool, useSuperSampler, false, Normal, nullptr) \
468 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.") \
469 v(bool, useCodeCache, true, Normal, "If false, the unlinked byte code cache will not be used.") \
471 v(bool, useWebAssembly, true, Normal, "Expose the WebAssembly global object.") \
473 v(bool, enableSpectreMitigations, true, Restricted, "Enable Spectre mitigations.") \
474 v(bool, enableSpectreGadgets, false, Restricted, "enable gadgets to test Spectre mitigations.") \
475 v(bool, zeroStackFrame, false, Normal, "Zero stack frame on entry to a function.") \
477 v(bool, failToCompileWebAssemblyCode, false, Normal, "If true, no Wasm::Plan will sucessfully compile a function.") \
478 v(size, webAssemblyPartialCompileLimit, 5000, Normal, "Limit on the number of bytes a Wasm::Plan::compile should attempt before checking for other work.") \
479 v(unsigned, webAssemblyBBQAirOptimizationLevel, 0, Normal, "Air Optimization level for BBQ Web Assembly module compilations.") \
480 v(unsigned, webAssemblyBBQB3OptimizationLevel, 1, Normal, "B3 Optimization level for BBQ Web Assembly module compilations.") \
481 v(unsigned, webAssemblyOMGOptimizationLevel, Options::defaultB3OptLevel(), Normal, "B3 Optimization level for OMG Web Assembly module compilations.") \
483 v(bool, useBBQTierUpChecks, true, Normal, "Enables tier up checks for our BBQ code.") \
484 v(bool, useWebAssemblyOSR, true, Normal, nullptr) \
485 v(int32, thresholdForOMGOptimizeAfterWarmUp, 50000, Normal, "The count before we tier up a function to OMG.") \
486 v(int32, thresholdForOMGOptimizeSoon, 500, Normal, nullptr) \
487 v(int32, omgTierUpCounterIncrementForLoop, 1, Normal, "The amount the tier up counter is incremented on each loop backedge.") \
488 v(int32, omgTierUpCounterIncrementForEntry, 15, Normal, "The amount the tier up counter is incremented on each function entry.") \
489 /* FIXME: enable fast memories on iOS and pre-allocate them. https://bugs.webkit.org/show_bug.cgi?id=170774 */ \
490 v(bool, useWebAssemblyFastMemory, !isIOS(), Normal, "If true, we will try to use a 32-bit address space with a signal handler to bounds check wasm memory.") \
491 v(bool, logWebAssemblyMemory, false, Normal, nullptr) \
492 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") \
493 v(bool, crashIfWebAssemblyCantFastMemory, false, Normal, "If true, we will crash if we can't obtain fast memory for wasm.") \
494 v(unsigned, maxNumWebAssemblyFastMemories, 4, Normal, nullptr) \
495 v(bool, useFastTLSForWasmContext, true, Normal, "If true, we will store context in fast TLS. If false, we will pin it to a register.") \
496 v(bool, wasmBBQUsesAir, true, Normal, nullptr) \
497 v(size, webAssemblyBBQAirModeThreshold, isIOS() ? (10 * MB) : 0, Normal, "If 0, we always use BBQ Air. If Wasm module code size hits this threshold, we compile Wasm module with B3 BBQ mode.") \
498 v(bool, useWebAssemblyStreamingApi, enableWebAssemblyStreamingApi, Normal, "Allow to run WebAssembly's Streaming API") \
499 v(bool, useCallICsForWebAssemblyToJSCalls, true, Normal, "If true, we will use CallLinkInfo to inline cache Wasm to JS calls.") \
500 v(bool, useEagerWebAssemblyModuleHashing, false, Normal, "Unnamed WebAssembly modules are identified in backtraces through their hash, if available.") \
501 v(bool, useWebAssemblyReferences, true, Normal, "Allow types from the wasm references spec.") \
502 v(bool, useWeakRefs, false, Normal, "Expose the WeakRef constructor.") \
503 v(bool, useBigInt, false, Normal, "If true, we will enable BigInt support.") \
504 v(bool, useNullishAwareOperators, false, Normal, "Enable support for ?. and ?? operators.") \
505 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.") \
506 v(bool, forcePolyProto, false, Normal, "If true, create_this will always create an object with a poly proto structure.") \
507 v(bool, forceMiniVMMode, false, Normal, "If true, it will force mini VM mode on.") \
508 v(bool, useTracePoints, false, Normal, nullptr) \
509 v(bool, traceLLIntExecution, false, Configurable, nullptr) \
510 v(bool, traceLLIntSlowPath, false, Configurable, nullptr) \
511 v(bool, traceBaselineJITExecution, false, Normal, nullptr) \
512 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.") \
513 v(optionString, diskCachePath, nullptr, Restricted, nullptr) \
514 v(bool, forceDiskCache, false, Restricted, nullptr) \
515 v(bool, validateAbstractInterpreterState, false, Restricted, nullptr) \
516 v(double, validateAbstractInterpreterStateProbability, 0.5, Normal, nullptr) \
517 v(optionString, dumpJITMemoryPath, nullptr, Restricted, nullptr) \
518 v(double, dumpJITMemoryFlushInterval, 10, Restricted, "Maximum time in between flushes of the JIT memory dump in seconds.") \
519 v(bool, useUnlinkedCodeBlockJettisoning, false, Normal, "If true, UnlinkedCodeBlock can be jettisoned.") \
522 enum OptionEquivalence {
527 #define JSC_ALIASED_OPTIONS(v) \
528 v(enableFunctionDotArguments, useFunctionDotArguments, SameOption) \
529 v(enableTailCalls, useTailCalls, SameOption) \
530 v(showDisassembly, dumpDisassembly, SameOption) \
531 v(showDFGDisassembly, dumpDFGDisassembly, SameOption) \
532 v(showFTLDisassembly, dumpFTLDisassembly, SameOption) \
533 v(showAllDFGNodes, dumpAllDFGNodes, SameOption) \
534 v(alwaysDoFullCollection, useGenerationalGC, InvertedOption) \
535 v(enableOSREntryToDFG, useOSREntryToDFG, SameOption) \
536 v(enableOSREntryToFTL, useOSREntryToFTL, SameOption) \
537 v(enableAccessInlining, useAccessInlining, SameOption) \
538 v(enablePolyvariantDevirtualization, usePolyvariantDevirtualization, SameOption) \
539 v(enablePolymorphicAccessInlining, usePolymorphicAccessInlining, SameOption) \
540 v(enablePolymorphicCallInlining, usePolymorphicCallInlining, SameOption) \
541 v(enableMovHintRemoval, useMovHintRemoval, SameOption) \
542 v(enableObjectAllocationSinking, useObjectAllocationSinking, SameOption) \
543 v(enableConcurrentJIT, useConcurrentJIT, SameOption) \
544 v(enableProfiler, useProfiler, SameOption) \
545 v(enableArchitectureSpecificOptimizations, useArchitectureSpecificOptimizations, SameOption) \
546 v(enablePolyvariantCallInlining, usePolyvariantCallInlining, SameOption) \
547 v(enablePolyvariantByIdInlining, usePolyvariantByIdInlining, SameOption) \
548 v(enableMaximalFlushInsertionPhase, useMaximalFlushInsertionPhase, SameOption) \
549 v(objectsAreImmortal, useImmortalObjects, SameOption) \
550 v(showObjectStatistics, dumpObjectStatistics, SameOption) \
551 v(disableGC, useGC, InvertedOption) \
552 v(enableTypeProfiler, useTypeProfiler, SameOption) \
553 v(enableControlFlowProfiler, useControlFlowProfiler, SameOption) \
554 v(enableExceptionFuzz, useExceptionFuzz, SameOption) \
555 v(enableExecutableAllocationFuzz, useExecutableAllocationFuzz, SameOption) \
556 v(enableOSRExitFuzz, useOSRExitFuzz, SameOption) \
557 v(enableDollarVM, useDollarVM, SameOption) \
558 v(enableWebAssembly, useWebAssembly, SameOption) \
559 v(verboseDFGByteCodeParsing, verboseDFGBytecodeParsing, SameOption) \
560 v(maximumOptimizationCandidateInstructionCount, maximumOptimizationCandidateBytecodeCost, SameOption) \
561 v(maximumFunctionForCallInlineCandidateInstructionCount, maximumFunctionForCallInlineCandidateBytecodeCost, SameOption) \
562 v(maximumFunctionForClosureCallInlineCandidateInstructionCount, maximumFunctionForClosureCallInlineCandidateBytecodeCost, SameOption) \
563 v(maximumFunctionForConstructInlineCandidateInstructionCount, maximumFunctionForConstructInlineCandidateBytecoodeCost, SameOption) \
564 v(maximumFTLCandidateInstructionCount, maximumFTLCandidateBytecodeCost, SameOption) \
565 v(maximumInliningCallerSize, maximumInliningCallerBytecodeCost, SameOption) \
570 enum class DumpLevel {
577 enum class Availability {
583 // This typedef is to allow us to eliminate the '_' in the field name in
584 // union inside Entry. This is needed to keep the style checker happy.
585 typedef int32_t int32;
588 // Declare the option IDs:
590 #define FOR_EACH_OPTION(type_, name_, defaultValue_, availability_, description_) \
592 JSC_OPTIONS(FOR_EACH_OPTION)
593 #undef FOR_EACH_OPTION
608 JS_EXPORT_PRIVATE static void initialize();
610 // Parses a string of options where each option is of the format "--<optionName>=<value>"
611 // and are separated by a space. The leading "--" is optional and will be ignored.
612 JS_EXPORT_PRIVATE static bool setOptions(const char* optionsList);
614 // Parses a single command line option in the format "<optionName>=<value>"
615 // (no spaces allowed) and set the specified option if appropriate.
616 JS_EXPORT_PRIVATE static bool setOption(const char* arg);
618 JS_EXPORT_PRIVATE static void dumpAllOptions(FILE*, DumpLevel, const char* title = nullptr);
619 JS_EXPORT_PRIVATE static void dumpAllOptionsInALine(StringBuilder&);
621 JS_EXPORT_PRIVATE static void ensureOptionsAreCoherent();
623 JS_EXPORT_PRIVATE static void enableRestrictedOptions(bool enableOrNot);
625 // Declare accessors for each option:
626 #define FOR_EACH_OPTION(type_, name_, defaultValue_, availability_, description_) \
627 ALWAYS_INLINE static type_& name_() { return s_options[name_##ID].type_##Val; } \
628 ALWAYS_INLINE static type_& name_##Default() { return s_defaultOptions[name_##ID].type_##Val; }
630 JSC_OPTIONS(FOR_EACH_OPTION)
631 #undef FOR_EACH_OPTION
633 static bool isAvailable(ID, Availability);
636 // For storing for an option value:
639 unsigned unsignedVal;
643 OptionRange optionRangeVal;
644 const char* optionStringVal;
645 GCLogging::Level gcLogLevelVal;
648 // For storing constant meta data about each option:
651 const char* description;
653 Availability availability;
658 enum DumpDefaultsOption {
662 static void dumpOptionsIfNeeded();
663 static void dumpAllOptions(StringBuilder&, DumpLevel, const char* title,
664 const char* separator, const char* optionHeader, const char* optionFooter, DumpDefaultsOption);
665 static void dumpOption(StringBuilder&, DumpLevel, ID,
666 const char* optionHeader, const char* optionFooter, DumpDefaultsOption);
668 static bool setOptionWithoutAlias(const char* arg);
669 static bool setAliasedOption(const char* arg);
670 static bool overrideAliasedOptionWithHeuristic(const char* name);
672 // Declare the singleton instance of the options store:
673 JS_EXPORT_PRIVATE static Entry s_options[numberOfOptions];
674 JS_EXPORT_PRIVATE static Entry s_defaultOptions[numberOfOptions];
675 static const EntryInfo s_optionsInfo[numberOfOptions];
682 Option(Options::ID id)
684 , m_entry(Options::s_options[m_id])
688 void dump(StringBuilder&) const;
690 bool operator==(const Option& other) const;
691 bool operator!=(const Option& other) const { return !(*this == other); }
693 Options::ID id() const { return m_id; }
694 const char* name() const;
695 const char* description() const;
696 Options::Type type() const;
697 Options::Availability availability() const;
698 bool isOverridden() const;
699 const Option defaultOption() const;
702 unsigned& unsignedVal();
705 OptionRange optionRangeVal();
706 const char* optionStringVal();
707 GCLogging::Level& gcLogLevelVal();
710 // Only used for constructing default Options.
711 Option(Options::ID id, Options::Entry& entry)
718 Options::Entry& m_entry;
721 inline const char* Option::name() const
723 return Options::s_optionsInfo[m_id].name;
726 inline const char* Option::description() const
728 return Options::s_optionsInfo[m_id].description;
731 inline Options::Type Option::type() const
733 return Options::s_optionsInfo[m_id].type;
736 inline Options::Availability Option::availability() const
738 return Options::s_optionsInfo[m_id].availability;
741 inline bool Option::isOverridden() const
743 return *this != defaultOption();
746 inline const Option Option::defaultOption() const
748 return Option(m_id, Options::s_defaultOptions[m_id]);
751 inline bool& Option::boolVal()
753 return m_entry.boolVal;
756 inline unsigned& Option::unsignedVal()
758 return m_entry.unsignedVal;
761 inline double& Option::doubleVal()
763 return m_entry.doubleVal;
766 inline int32_t& Option::int32Val()
768 return m_entry.int32Val;
771 inline OptionRange Option::optionRangeVal()
773 return m_entry.optionRangeVal;
776 inline const char* Option::optionStringVal()
778 return m_entry.optionStringVal;
781 inline GCLogging::Level& Option::gcLogLevelVal()
783 return m_entry.gcLogLevelVal;