]>
Commit | Line | Data |
---|---|---|
6fe7ccc8 | 1 | /* |
81345200 | 2 | * Copyright (C) 2011, 2012, 2013, 2014 Apple Inc. All rights reserved. |
6fe7ccc8 A |
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 | #ifndef Options_h | |
27 | #define Options_h | |
28 | ||
81345200 | 29 | #include "GCLogging.h" |
93a37866 | 30 | #include "JSExportMacros.h" |
6fe7ccc8 | 31 | #include <stdint.h> |
93a37866 | 32 | #include <stdio.h> |
81345200 | 33 | #include <wtf/StdLibExtras.h> |
93a37866 A |
34 | |
35 | namespace JSC { | |
36 | ||
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. | |
42 | // | |
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 | |
47 | // set like so: | |
48 | // | |
49 | // bool jitIsOn = Options::useJIT(); // Get the option value. | |
50 | // Options::useJIT() = false; // Sets the option value. | |
51 | // | |
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 | |
54 | // are set. | |
55 | // | |
56 | // Alternatively, you can override the default values by specifying | |
57 | // environment variables of the form: JSC_<name of JSC option>. | |
58 | // | |
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. | |
64 | ||
65 | class OptionRange { | |
66 | private: | |
67 | enum RangeState { Uninitialized, InitError, Normal, Inverted }; | |
68 | public: | |
69 | OptionRange& operator= (const int& rhs) | |
70 | { // Only needed for initialization | |
71 | if (!rhs) { | |
72 | m_state = Uninitialized; | |
73 | m_rangeString = 0; | |
74 | m_lowLimit = 0; | |
75 | m_highLimit = 0; | |
76 | } | |
77 | return *this; | |
78 | } | |
79 | ||
80 | bool init(const char*); | |
81 | bool isInRange(unsigned); | |
82 | const char* rangeString() { return (m_state > InitError) ? m_rangeString : "<null>"; } | |
83 | ||
84 | private: | |
85 | RangeState m_state; | |
86 | const char* m_rangeString; | |
87 | unsigned m_lowLimit; | |
88 | unsigned m_highLimit; | |
89 | }; | |
90 | ||
91 | typedef OptionRange optionRange; | |
81345200 | 92 | typedef const char* optionString; |
93a37866 A |
93 | |
94 | #define JSC_OPTIONS(v) \ | |
81345200 | 95 | v(bool, useLLInt, true) \ |
93a37866 A |
96 | v(bool, useJIT, true) \ |
97 | v(bool, useDFGJIT, true) \ | |
98 | v(bool, useRegExpJIT, true) \ | |
99 | \ | |
81345200 A |
100 | v(unsigned, maxPerThreadStackUsage, 4 * MB) \ |
101 | v(unsigned, reservedZoneSize, 128 * KB) \ | |
102 | v(unsigned, errorModeReservedZoneSize, 64 * KB) \ | |
103 | \ | |
104 | v(bool, crashIfCantAllocateJITMemory, false) \ | |
105 | \ | |
93a37866 | 106 | v(bool, forceDFGCodeBlockLiveness, false) \ |
81345200 | 107 | v(bool, forceICFailure, false) \ |
93a37866 A |
108 | \ |
109 | v(bool, dumpGeneratedBytecodes, false) \ | |
81345200 A |
110 | v(bool, dumpBytecodeLivenessResults, false) \ |
111 | v(bool, validateBytecode, false) \ | |
112 | v(bool, forceDebuggerBytecodeGeneration, false) \ | |
113 | v(bool, forceProfilerBytecodeGeneration, false) \ | |
93a37866 A |
114 | \ |
115 | /* showDisassembly implies showDFGDisassembly. */ \ | |
116 | v(bool, showDisassembly, false) \ | |
117 | v(bool, showDFGDisassembly, false) \ | |
81345200 | 118 | v(bool, showFTLDisassembly, false) \ |
93a37866 A |
119 | v(bool, showAllDFGNodes, false) \ |
120 | v(optionRange, bytecodeRangeToDFGCompile, 0) \ | |
81345200 | 121 | v(optionString, dfgFunctionWhitelistFile, nullptr) \ |
93a37866 A |
122 | v(bool, dumpBytecodeAtDFGTime, false) \ |
123 | v(bool, dumpGraphAtEachPhase, false) \ | |
81345200 | 124 | v(bool, verboseDFGByteCodeParsing, false) \ |
93a37866 | 125 | v(bool, verboseCompilation, false) \ |
81345200 | 126 | v(bool, verboseFTLCompilation, false) \ |
93a37866 A |
127 | v(bool, logCompilationChanges, false) \ |
128 | v(bool, printEachOSRExit, false) \ | |
129 | v(bool, validateGraph, false) \ | |
130 | v(bool, validateGraphAtEachPhase, false) \ | |
81345200 A |
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) \ | |
145 | \ | |
146 | v(bool, enableOSREntryToDFG, true) \ | |
147 | v(bool, enableOSREntryToFTL, true) \ | |
148 | \ | |
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) \ | |
170 | \ | |
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)) \ | |
93a37866 A |
176 | \ |
177 | v(bool, enableProfiler, false) \ | |
178 | \ | |
81345200 A |
179 | v(bool, forceUDis86Disassembler, false) \ |
180 | v(bool, forceLLVMDisassembler, false) \ | |
181 | \ | |
182 | v(bool, enableArchitectureSpecificOptimizations, true) \ | |
183 | \ | |
184 | v(bool, breakOnThrow, false) \ | |
93a37866 | 185 | \ |
81345200 | 186 | v(unsigned, maximumOptimizationCandidateInstructionCount, 100000) \ |
93a37866 A |
187 | \ |
188 | v(unsigned, maximumFunctionForCallInlineCandidateInstructionCount, 180) \ | |
189 | v(unsigned, maximumFunctionForClosureCallInlineCandidateInstructionCount, 100) \ | |
190 | v(unsigned, maximumFunctionForConstructInlineCandidateInstructionCount, 100) \ | |
191 | \ | |
81345200 A |
192 | v(unsigned, maximumFTLCandidateInstructionCount, 20000) \ |
193 | \ | |
93a37866 A |
194 | /* Depth of inline stack, so 1 = no inlining, 2 = one level, etc. */ \ |
195 | v(unsigned, maximumInliningDepth, 5) \ | |
81345200 A |
196 | v(unsigned, maximumInliningRecursion, 2) \ |
197 | v(unsigned, maximumInliningDepthForMustInline, 7) \ | |
198 | v(unsigned, maximumInliningRecursionForMustInline, 3) \ | |
199 | \ | |
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) \ | |
203 | \ | |
204 | v(bool, enablePolyvariantCallInlining, true) \ | |
205 | v(bool, enablePolyvariantByIdInlining, true) \ | |
206 | \ | |
207 | v(unsigned, maximumBinaryStringSwitchCaseLength, 50) \ | |
208 | v(unsigned, maximumBinaryStringSwitchTotalLength, 2000) \ | |
93a37866 | 209 | \ |
81345200 | 210 | v(int32, thresholdForJITAfterWarmUp, 500) \ |
93a37866 A |
211 | v(int32, thresholdForJITSoon, 100) \ |
212 | \ | |
213 | v(int32, thresholdForOptimizeAfterWarmUp, 1000) \ | |
214 | v(int32, thresholdForOptimizeAfterLongWarmUp, 1000) \ | |
215 | v(int32, thresholdForOptimizeSoon, 1000) \ | |
93a37866 | 216 | v(int32, executionCounterIncrementForLoop, 1) \ |
81345200 A |
217 | v(int32, executionCounterIncrementForEntry, 15) \ |
218 | \ | |
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) \ | |
93a37866 A |
225 | \ |
226 | v(int32, evalThresholdMultiplier, 10) \ | |
227 | \ | |
228 | v(bool, randomizeExecutionCountsBetweenCheckpoints, false) \ | |
81345200 A |
229 | v(int32, maximumExecutionCountsBetweenCheckpointsForBaseline, 1000) \ |
230 | v(int32, maximumExecutionCountsBetweenCheckpointsForUpperTiers, 50000) \ | |
93a37866 A |
231 | \ |
232 | v(unsigned, likelyToTakeSlowCaseMinimumCount, 100) \ | |
233 | v(unsigned, couldTakeSlowCaseMinimumCount, 10) \ | |
234 | \ | |
235 | v(unsigned, osrExitCountForReoptimization, 100) \ | |
236 | v(unsigned, osrExitCountForReoptimizationFromLoop, 5) \ | |
237 | \ | |
238 | v(unsigned, reoptimizationRetryCounterMax, 0) \ | |
239 | v(unsigned, reoptimizationRetryCounterStep, 1) \ | |
240 | \ | |
241 | v(unsigned, minimumOptimizationDelay, 1) \ | |
242 | v(unsigned, maximumOptimizationDelay, 5) \ | |
243 | v(double, desiredProfileLivenessRate, 0.75) \ | |
244 | v(double, desiredProfileFullnessRate, 0.35) \ | |
245 | \ | |
246 | v(double, doubleVoteRatioForDoubleFormat, 2) \ | |
247 | v(double, structureCheckVoteRatioForHoisting, 1) \ | |
81345200 | 248 | v(double, checkArrayVoteRatioForHoisting, 1) \ |
93a37866 A |
249 | \ |
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) \ | |
81345200 A |
255 | v(double, minMarkedBlockUtilization, 0.9) \ |
256 | v(unsigned, slowPathAllocsBetweenGCs, 0) \ | |
257 | \ | |
258 | v(double, percentCPUPerMBForFullTimer, 0.0003125) \ | |
259 | v(double, percentCPUPerMBForEdenTimer, 0.0025) \ | |
260 | v(double, collectionTimerMaxPercentCPU, 0.05) \ | |
93a37866 A |
261 | \ |
262 | v(bool, forceWeakRandomSeed, false) \ | |
263 | v(unsigned, forcedWeakRandomSeed, 0) \ | |
264 | \ | |
265 | v(bool, useZombieMode, false) \ | |
266 | v(bool, objectsAreImmortal, false) \ | |
267 | v(bool, showObjectStatistics, false) \ | |
268 | \ | |
81345200 A |
269 | v(gcLogLevel, logGC, GCLogging::None) \ |
270 | v(bool, disableGC, false) \ | |
93a37866 A |
271 | v(unsigned, gcMaxHeapSize, 0) \ |
272 | v(bool, recordGCPauseTimes, false) \ | |
81345200 A |
273 | v(bool, logHeapStatisticsAtExit, false) \ |
274 | \ | |
275 | v(bool, enableExceptionFuzz, false) \ | |
276 | v(unsigned, fireExceptionFuzzAt, 0) | |
93a37866 A |
277 | |
278 | class Options { | |
279 | public: | |
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; | |
283 | ||
284 | // Declare the option IDs: | |
285 | enum OptionID { | |
286 | #define FOR_EACH_OPTION(type_, name_, defaultValue_) \ | |
287 | OPT_##name_, | |
288 | JSC_OPTIONS(FOR_EACH_OPTION) | |
289 | #undef FOR_EACH_OPTION | |
290 | numberOfOptions | |
291 | }; | |
292 | ||
293 | ||
294 | static void initialize(); | |
295 | ||
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 = ""); | |
301 | ||
302 | // Declare accessors for each option: | |
303 | #define FOR_EACH_OPTION(type_, name_, defaultValue_) \ | |
81345200 A |
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; } | |
93a37866 A |
306 | |
307 | JSC_OPTIONS(FOR_EACH_OPTION) | |
308 | #undef FOR_EACH_OPTION | |
309 | ||
310 | private: | |
311 | enum EntryType { | |
312 | boolType, | |
313 | unsignedType, | |
314 | doubleType, | |
315 | int32Type, | |
316 | optionRangeType, | |
81345200 A |
317 | optionStringType, |
318 | gcLogLevelType, | |
93a37866 A |
319 | }; |
320 | ||
321 | // For storing for an option value: | |
322 | struct Entry { | |
323 | union { | |
324 | bool boolVal; | |
325 | unsigned unsignedVal; | |
326 | double doubleVal; | |
327 | int32 int32Val; | |
328 | OptionRange optionRangeVal; | |
81345200 A |
329 | const char* optionStringVal; |
330 | GCLogging::Level gcLogLevelVal; | |
93a37866 | 331 | } u; |
81345200 | 332 | bool didOverride; |
93a37866 A |
333 | }; |
334 | ||
335 | // For storing constant meta data about each option: | |
336 | struct EntryInfo { | |
337 | const char* name; | |
338 | EntryType type; | |
339 | }; | |
340 | ||
341 | Options(); | |
342 | ||
343 | // Declare the options: | |
344 | #define FOR_EACH_OPTION(type_, name_, defaultValue_) \ | |
345 | type_ m_##name_; | |
346 | JSC_OPTIONS(FOR_EACH_OPTION) | |
347 | #undef FOR_EACH_OPTION | |
348 | ||
349 | // Declare the singleton instance of the options store: | |
350 | JS_EXPORTDATA static Entry s_options[numberOfOptions]; | |
351 | static const EntryInfo s_optionsInfo[numberOfOptions]; | |
352 | }; | |
353 | ||
354 | } // namespace JSC | |
6fe7ccc8 A |
355 | |
356 | #endif // Options_h |