2 * Copyright (C) 2011, 2012, 2013 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 "JSExportMacros.h"
35 // How do JSC VM options work?
36 // ===========================
37 // The JSC_OPTIONS() macro below defines a list of all JSC options in use,
38 // along with their types and default values. The options values are actually
39 // realized as an array of Options::Entry elements.
41 // Options::initialize() will initialize the array of options values with
42 // the defaults specified in JSC_OPTIONS() below. After that, the values can
43 // be programmatically read and written to using an accessor method with the
44 // same name as the option. For example, the option "useJIT" can be read and
47 // bool jitIsOn = Options::useJIT(); // Get the option value.
48 // Options::useJIT() = false; // Sets the option value.
50 // If you want to tweak any of these values programmatically for testing
51 // purposes, you can do so in Options::initialize() after the default values
54 // Alternatively, you can override the default values by specifying
55 // environment variables of the form: JSC_<name of JSC option>.
57 // Note: Options::initialize() tries to ensure some sanity on the option values
58 // which are set by doing some range checks, and value corrections. These
59 // checks are done after the option values are set. If you alter the option
60 // values after the sanity checks (for your own testing), then you're liable to
61 // ensure that the new values set are sane and reasonable for your own run.
65 enum RangeState { Uninitialized, InitError, Normal, Inverted };
67 OptionRange& operator= (const int& rhs)
68 { // Only needed for initialization
70 m_state = Uninitialized;
78 bool init(const char*);
79 bool isInRange(unsigned);
80 const char* rangeString() { return (m_state > InitError) ? m_rangeString : "<null>"; }
84 const char* m_rangeString;
89 typedef OptionRange optionRange;
91 #define JSC_OPTIONS(v) \
92 v(bool, useJIT, true) \
93 v(bool, useDFGJIT, true) \
94 v(bool, useRegExpJIT, true) \
96 v(bool, forceDFGCodeBlockLiveness, false) \
98 v(bool, dumpGeneratedBytecodes, false) \
100 /* showDisassembly implies showDFGDisassembly. */ \
101 v(bool, showDisassembly, false) \
102 v(bool, showDFGDisassembly, false) \
103 v(bool, showAllDFGNodes, false) \
104 v(optionRange, bytecodeRangeToDFGCompile, 0) \
105 v(bool, dumpBytecodeAtDFGTime, false) \
106 v(bool, dumpGraphAtEachPhase, false) \
107 v(bool, verboseCompilation, false) \
108 v(bool, logCompilationChanges, false) \
109 v(bool, printEachOSRExit, false) \
110 v(bool, validateGraph, false) \
111 v(bool, validateGraphAtEachPhase, false) \
112 v(bool, verboseOSR, false) \
113 v(bool, verboseCallLink, false) \
114 v(bool, verboseCompilationQueue, false) \
115 v(bool, reportCompileTimes, false) \
116 v(bool, verboseCFA, false) \
118 v(bool, enableOSREntryInLoops, true) \
120 v(bool, useExperimentalFTL, false) \
121 v(bool, useFTLTBAA, true) \
122 v(bool, enableLLVMFastISel, false) \
123 v(bool, useLLVMSmallCodeModel, false) \
124 v(bool, ftlTrapsOnOSRExit, false) \
125 v(bool, ftlOSRExitOmitsMarshalling, false) \
126 v(bool, useLLVMOSRExitIntrinsic, false) \
127 v(bool, dumpLLVMIR, false) \
128 v(bool, llvmAlwaysFails, false) \
129 v(unsigned, llvmBackendOptimizationLevel, 2) \
130 v(unsigned, llvmOptimizationLevel, 2) \
131 v(unsigned, llvmSizeLevel, 0) \
132 v(bool, ftlCrashes, false) /* fool-proof way of checking that you ended up in the FTL. ;-) */\
134 v(bool, enableConcurrentJIT, true) \
135 v(unsigned, numberOfCompilerThreads, computeNumberOfWorkerThreads(2) - 1) \
137 v(bool, enableProfiler, false) \
139 v(bool, forceUDis86Disassembler, false) \
140 v(bool, forceLLVMDisassembler, false) \
142 v(unsigned, maximumOptimizationCandidateInstructionCount, 10000) \
144 v(unsigned, maximumFunctionForCallInlineCandidateInstructionCount, 180) \
145 v(unsigned, maximumFunctionForClosureCallInlineCandidateInstructionCount, 100) \
146 v(unsigned, maximumFunctionForConstructInlineCandidateInstructionCount, 100) \
148 /* Depth of inline stack, so 1 = no inlining, 2 = one level, etc. */ \
149 v(unsigned, maximumInliningDepth, 5) \
151 v(unsigned, maximumBinaryStringSwitchCaseLength, 50) \
152 v(unsigned, maximumBinaryStringSwitchTotalLength, 2000) \
154 v(int32, thresholdForJITAfterWarmUp, 100) \
155 v(int32, thresholdForJITSoon, 100) \
157 v(int32, thresholdForOptimizeAfterWarmUp, 1000) \
158 v(int32, thresholdForOptimizeAfterLongWarmUp, 1000) \
159 v(int32, thresholdForOptimizeSoon, 1000) \
160 v(int32, executionCounterIncrementForLoop, 1) \
161 v(int32, executionCounterIncrementForEntry, 15) \
163 v(int32, thresholdForFTLOptimizeAfterWarmUp, 25000) \
164 v(int32, thresholdForFTLOptimizeSoon, 1000) \
165 v(int32, ftlTierUpCounterIncrementForLoop, 1) \
166 v(int32, ftlTierUpCounterIncrementForReturn, 15) \
167 v(unsigned, ftlOSREntryFailureCountForReoptimization, 15) \
169 v(int32, evalThresholdMultiplier, 10) \
171 v(bool, randomizeExecutionCountsBetweenCheckpoints, false) \
172 v(int32, maximumExecutionCountsBetweenCheckpoints, 1000) \
174 v(unsigned, likelyToTakeSlowCaseMinimumCount, 100) \
175 v(unsigned, couldTakeSlowCaseMinimumCount, 10) \
177 v(unsigned, osrExitCountForReoptimization, 100) \
178 v(unsigned, osrExitCountForReoptimizationFromLoop, 5) \
180 v(unsigned, reoptimizationRetryCounterMax, 0) \
181 v(unsigned, reoptimizationRetryCounterStep, 1) \
183 v(unsigned, minimumOptimizationDelay, 1) \
184 v(unsigned, maximumOptimizationDelay, 5) \
185 v(double, desiredProfileLivenessRate, 0.75) \
186 v(double, desiredProfileFullnessRate, 0.35) \
188 v(double, doubleVoteRatioForDoubleFormat, 2) \
189 v(double, structureCheckVoteRatioForHoisting, 1) \
190 v(double, checkArrayVoteRatioForHoisting, 1) \
192 v(unsigned, minimumNumberOfScansBetweenRebalance, 100) \
193 v(unsigned, numberOfGCMarkers, computeNumberOfGCMarkers(7)) \
194 v(unsigned, opaqueRootMergeThreshold, 1000) \
195 v(double, minHeapUtilization, 0.8) \
196 v(double, minCopiedBlockUtilization, 0.9) \
198 v(bool, forceWeakRandomSeed, false) \
199 v(unsigned, forcedWeakRandomSeed, 0) \
201 v(bool, useZombieMode, false) \
202 v(bool, objectsAreImmortal, false) \
203 v(bool, showObjectStatistics, false) \
205 v(bool, logGC, false) \
206 v(unsigned, gcMaxHeapSize, 0) \
207 v(bool, recordGCPauseTimes, false) \
208 v(bool, logHeapStatisticsAtExit, false)
212 // This typedef is to allow us to eliminate the '_' in the field name in
213 // union inside Entry. This is needed to keep the style checker happy.
214 typedef int32_t int32;
216 // Declare the option IDs:
218 #define FOR_EACH_OPTION(type_, name_, defaultValue_) \
220 JSC_OPTIONS(FOR_EACH_OPTION)
221 #undef FOR_EACH_OPTION
226 static void initialize();
228 // Parses a single command line option in the format "<optionName>=<value>"
229 // (no spaces allowed) and set the specified option if appropriate.
230 JS_EXPORT_PRIVATE static bool setOption(const char* arg);
231 JS_EXPORT_PRIVATE static void dumpAllOptions(FILE* stream = stdout);
232 static void dumpOption(OptionID id, FILE* stream = stdout, const char* header = "", const char* footer = "");
234 // Declare accessors for each option:
235 #define FOR_EACH_OPTION(type_, name_, defaultValue_) \
236 ALWAYS_INLINE static type_& name_() { return s_options[OPT_##name_].u.type_##Val; }
238 JSC_OPTIONS(FOR_EACH_OPTION)
239 #undef FOR_EACH_OPTION
250 // For storing for an option value:
254 unsigned unsignedVal;
257 OptionRange optionRangeVal;
261 // For storing constant meta data about each option:
269 // Declare the options:
270 #define FOR_EACH_OPTION(type_, name_, defaultValue_) \
272 JSC_OPTIONS(FOR_EACH_OPTION)
273 #undef FOR_EACH_OPTION
275 // Declare the singleton instance of the options store:
276 JS_EXPORTDATA static Entry s_options[numberOfOptions];
277 static const EntryInfo s_optionsInfo[numberOfOptions];