2 * Copyright (C) 2011, 2012, 2013, 2014 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.
29 #include "GCLogging.h"
30 #include "JSExportMacros.h"
33 #include <wtf/StdLibExtras.h>
37 // How do JSC VM options work?
38 // ===========================
39 // The JSC_OPTIONS() macro below defines a list of all JSC options in use,
40 // along with their types and default values. The options values are actually
41 // realized as an array of Options::Entry elements.
43 // Options::initialize() will initialize the array of options values with
44 // the defaults specified in JSC_OPTIONS() below. After that, the values can
45 // be programmatically read and written to using an accessor method with the
46 // same name as the option. For example, the option "useJIT" can be read and
49 // bool jitIsOn = Options::useJIT(); // Get the option value.
50 // Options::useJIT() = false; // Sets the option value.
52 // If you want to tweak any of these values programmatically for testing
53 // purposes, you can do so in Options::initialize() after the default values
56 // Alternatively, you can override the default values by specifying
57 // environment variables of the form: JSC_<name of JSC option>.
59 // Note: Options::initialize() tries to ensure some sanity on the option values
60 // which are set by doing some range checks, and value corrections. These
61 // checks are done after the option values are set. If you alter the option
62 // values after the sanity checks (for your own testing), then you're liable to
63 // ensure that the new values set are sane and reasonable for your own run.
67 enum RangeState
{ Uninitialized
, InitError
, Normal
, Inverted
};
69 OptionRange
& operator= (const int& rhs
)
70 { // Only needed for initialization
72 m_state
= Uninitialized
;
80 bool init(const char*);
81 bool isInRange(unsigned);
82 const char* rangeString() { return (m_state
> InitError
) ? m_rangeString
: "<null>"; }
86 const char* m_rangeString
;
91 typedef OptionRange optionRange
;
92 typedef const char* optionString
;
94 #define JSC_OPTIONS(v) \
95 v(bool, useLLInt, true) \
96 v(bool, useJIT, true) \
97 v(bool, useDFGJIT, true) \
98 v(bool, useRegExpJIT, true) \
100 v(unsigned, maxPerThreadStackUsage, 4 * MB) \
101 v(unsigned, reservedZoneSize, 128 * KB) \
102 v(unsigned, errorModeReservedZoneSize, 64 * KB) \
104 v(bool, crashIfCantAllocateJITMemory, false) \
106 v(bool, forceDFGCodeBlockLiveness, false) \
107 v(bool, forceICFailure, false) \
109 v(bool, dumpGeneratedBytecodes, false) \
110 v(bool, dumpBytecodeLivenessResults, false) \
111 v(bool, validateBytecode, false) \
112 v(bool, forceDebuggerBytecodeGeneration, false) \
113 v(bool, forceProfilerBytecodeGeneration, false) \
115 /* showDisassembly implies showDFGDisassembly. */ \
116 v(bool, showDisassembly, false) \
117 v(bool, showDFGDisassembly, false) \
118 v(bool, showFTLDisassembly, false) \
119 v(bool, showAllDFGNodes, false) \
120 v(optionRange, bytecodeRangeToDFGCompile, 0) \
121 v(optionString, dfgFunctionWhitelistFile, nullptr) \
122 v(bool, dumpBytecodeAtDFGTime, false) \
123 v(bool, dumpGraphAtEachPhase, false) \
124 v(bool, verboseDFGByteCodeParsing, false) \
125 v(bool, verboseCompilation, false) \
126 v(bool, verboseFTLCompilation, false) \
127 v(bool, logCompilationChanges, false) \
128 v(bool, printEachOSRExit, false) \
129 v(bool, validateGraph, false) \
130 v(bool, validateGraphAtEachPhase, false) \
131 v(bool, verboseOSR, false) \
132 v(bool, verboseFTLOSRExit, false) \
133 v(bool, verboseCallLink, false) \
134 v(bool, verboseCompilationQueue, false) \
135 v(bool, reportCompileTimes, false) \
136 v(bool, reportFTLCompileTimes, false) \
137 v(bool, verboseCFA, false) \
138 v(bool, verboseFTLToJSThunk, false) \
139 v(bool, verboseFTLFailure, false) \
140 v(bool, alwaysComputeHash, false) \
141 v(bool, testTheFTL, false) \
142 v(bool, verboseSanitizeStack, false) \
143 v(bool, alwaysDoFullCollection, false) \
144 v(bool, eagerlyUpdateTopCallFrame, false) \
146 v(bool, enableOSREntryToDFG, true) \
147 v(bool, enableOSREntryToFTL, true) \
149 v(bool, useFTLJIT, true) \
150 v(bool, enableExperimentalFTLCoverage, false) \
151 v(bool, useFTLTBAA, true) \
152 v(bool, enableLLVMFastISel, false) \
153 v(bool, useLLVMSmallCodeModel, false) \
154 v(bool, dumpLLVMIR, false) \
155 v(bool, validateFTLOSRExitLiveness, false) \
156 v(bool, llvmAlwaysFailsBeforeCompile, false) \
157 v(bool, llvmAlwaysFailsBeforeLink, false) \
158 v(bool, llvmSimpleOpt, true) \
159 v(unsigned, llvmBackendOptimizationLevel, 2) \
160 v(unsigned, llvmOptimizationLevel, 2) \
161 v(unsigned, llvmSizeLevel, 0) \
162 v(unsigned, llvmMaxStackSize, 128 * KB) \
163 v(bool, llvmDisallowAVX, true) \
164 v(bool, ftlCrashes, false) /* fool-proof way of checking that you ended up in the FTL. ;-) */\
165 v(bool, clobberAllRegsInFTLICSlowPath, !ASSERT_DISABLED) \
166 v(bool, assumeAllRegsInFTLICAreLive, false) \
167 v(bool, enableAccessInlining, true) \
168 v(bool, enablePolyvariantDevirtualization, true) \
169 v(bool, enablePolymorphicAccessInlining, true) \
171 v(bool, enableConcurrentJIT, true) \
172 v(unsigned, numberOfDFGCompilerThreads, computeNumberOfWorkerThreads(2, 2) - 1) \
173 v(unsigned, numberOfFTLCompilerThreads, computeNumberOfWorkerThreads(8, 2) - 1) \
174 v(int32, priorityDeltaOfDFGCompilerThreads, computePriorityDeltaOfWorkerThreads(-1, 0)) \
175 v(int32, priorityDeltaOfFTLCompilerThreads, computePriorityDeltaOfWorkerThreads(-2, 0)) \
177 v(bool, enableProfiler, false) \
179 v(bool, forceUDis86Disassembler, false) \
180 v(bool, forceLLVMDisassembler, false) \
182 v(bool, enableArchitectureSpecificOptimizations, true) \
184 v(bool, breakOnThrow, false) \
186 v(unsigned, maximumOptimizationCandidateInstructionCount, 100000) \
188 v(unsigned, maximumFunctionForCallInlineCandidateInstructionCount, 180) \
189 v(unsigned, maximumFunctionForClosureCallInlineCandidateInstructionCount, 100) \
190 v(unsigned, maximumFunctionForConstructInlineCandidateInstructionCount, 100) \
192 v(unsigned, maximumFTLCandidateInstructionCount, 20000) \
194 /* Depth of inline stack, so 1 = no inlining, 2 = one level, etc. */ \
195 v(unsigned, maximumInliningDepth, 5) \
196 v(unsigned, maximumInliningRecursion, 2) \
197 v(unsigned, maximumInliningDepthForMustInline, 7) \
198 v(unsigned, maximumInliningRecursionForMustInline, 3) \
200 /* Maximum size of a caller for enabling inlining. This is purely to protect us */\
201 /* from super long compiles that take a lot of memory. */\
202 v(unsigned, maximumInliningCallerSize, 10000) \
204 v(bool, enablePolyvariantCallInlining, true) \
205 v(bool, enablePolyvariantByIdInlining, true) \
207 v(unsigned, maximumBinaryStringSwitchCaseLength, 50) \
208 v(unsigned, maximumBinaryStringSwitchTotalLength, 2000) \
210 v(int32, thresholdForJITAfterWarmUp, 500) \
211 v(int32, thresholdForJITSoon, 100) \
213 v(int32, thresholdForOptimizeAfterWarmUp, 1000) \
214 v(int32, thresholdForOptimizeAfterLongWarmUp, 1000) \
215 v(int32, thresholdForOptimizeSoon, 1000) \
216 v(int32, executionCounterIncrementForLoop, 1) \
217 v(int32, executionCounterIncrementForEntry, 15) \
219 v(int32, thresholdForFTLOptimizeAfterWarmUp, 100000) \
220 v(int32, thresholdForFTLOptimizeSoon, 1000) \
221 v(int32, ftlTierUpCounterIncrementForLoop, 1) \
222 v(int32, ftlTierUpCounterIncrementForReturn, 15) \
223 v(unsigned, ftlOSREntryFailureCountForReoptimization, 15) \
224 v(unsigned, ftlOSREntryRetryThreshold, 100) \
226 v(int32, evalThresholdMultiplier, 10) \
228 v(bool, randomizeExecutionCountsBetweenCheckpoints, false) \
229 v(int32, maximumExecutionCountsBetweenCheckpointsForBaseline, 1000) \
230 v(int32, maximumExecutionCountsBetweenCheckpointsForUpperTiers, 50000) \
232 v(unsigned, likelyToTakeSlowCaseMinimumCount, 100) \
233 v(unsigned, couldTakeSlowCaseMinimumCount, 10) \
235 v(unsigned, osrExitCountForReoptimization, 100) \
236 v(unsigned, osrExitCountForReoptimizationFromLoop, 5) \
238 v(unsigned, reoptimizationRetryCounterMax, 0) \
239 v(unsigned, reoptimizationRetryCounterStep, 1) \
241 v(unsigned, minimumOptimizationDelay, 1) \
242 v(unsigned, maximumOptimizationDelay, 5) \
243 v(double, desiredProfileLivenessRate, 0.75) \
244 v(double, desiredProfileFullnessRate, 0.35) \
246 v(double, doubleVoteRatioForDoubleFormat, 2) \
247 v(double, structureCheckVoteRatioForHoisting, 1) \
248 v(double, checkArrayVoteRatioForHoisting, 1) \
250 v(unsigned, minimumNumberOfScansBetweenRebalance, 100) \
251 v(unsigned, numberOfGCMarkers, computeNumberOfGCMarkers(7)) \
252 v(unsigned, opaqueRootMergeThreshold, 1000) \
253 v(double, minHeapUtilization, 0.8) \
254 v(double, minCopiedBlockUtilization, 0.9) \
255 v(double, minMarkedBlockUtilization, 0.9) \
256 v(unsigned, slowPathAllocsBetweenGCs, 0) \
258 v(double, percentCPUPerMBForFullTimer, 0.0003125) \
259 v(double, percentCPUPerMBForEdenTimer, 0.0025) \
260 v(double, collectionTimerMaxPercentCPU, 0.05) \
262 v(bool, forceWeakRandomSeed, false) \
263 v(unsigned, forcedWeakRandomSeed, 0) \
265 v(bool, useZombieMode, false) \
266 v(bool, objectsAreImmortal, false) \
267 v(bool, showObjectStatistics, false) \
269 v(gcLogLevel, logGC, GCLogging::None) \
270 v(bool, disableGC, false) \
271 v(unsigned, gcMaxHeapSize, 0) \
272 v(bool, recordGCPauseTimes, false) \
273 v(bool, logHeapStatisticsAtExit, false) \
275 v(bool, enableExceptionFuzz, false) \
276 v(unsigned, fireExceptionFuzzAt, 0)
280 // This typedef is to allow us to eliminate the '_' in the field name in
281 // union inside Entry. This is needed to keep the style checker happy.
282 typedef int32_t int32
;
284 // Declare the option IDs:
286 #define FOR_EACH_OPTION(type_, name_, defaultValue_) \
288 JSC_OPTIONS(FOR_EACH_OPTION
)
289 #undef FOR_EACH_OPTION
294 static void initialize();
296 // Parses a single command line option in the format "<optionName>=<value>"
297 // (no spaces allowed) and set the specified option if appropriate.
298 JS_EXPORT_PRIVATE
static bool setOption(const char* arg
);
299 JS_EXPORT_PRIVATE
static void dumpAllOptions(FILE* stream
= stdout
);
300 static void dumpOption(OptionID id
, FILE* stream
= stdout
, const char* header
= "", const char* footer
= "");
302 // Declare accessors for each option:
303 #define FOR_EACH_OPTION(type_, name_, defaultValue_) \
304 ALWAYS_INLINE static type_& name_() { return s_options[OPT_##name_].u.type_##Val; } \
305 static bool name_##WasOverridden() { return s_options[OPT_##name_].didOverride; }
307 JSC_OPTIONS(FOR_EACH_OPTION
)
308 #undef FOR_EACH_OPTION
321 // For storing for an option value:
325 unsigned unsignedVal
;
328 OptionRange optionRangeVal
;
329 const char* optionStringVal
;
330 GCLogging::Level gcLogLevelVal
;
335 // For storing constant meta data about each option:
343 // Declare the options:
344 #define FOR_EACH_OPTION(type_, name_, defaultValue_) \
346 JSC_OPTIONS(FOR_EACH_OPTION
)
347 #undef FOR_EACH_OPTION
349 // Declare the singleton instance of the options store:
350 JS_EXPORTDATA
static Entry s_options
[numberOfOptions
];
351 static const EntryInfo s_optionsInfo
[numberOfOptions
];