2 * Copyright (C) 2011, 2012 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) \
113 v(bool, enableProfiler, false) \
115 v(bool, crashIfCantAllocateJITMemory, false) \
117 v(unsigned, maximumOptimizationCandidateInstructionCount, 10000) \
119 v(unsigned, maximumFunctionForCallInlineCandidateInstructionCount, 180) \
120 v(unsigned, maximumFunctionForClosureCallInlineCandidateInstructionCount, 100) \
121 v(unsigned, maximumFunctionForConstructInlineCandidateInstructionCount, 100) \
123 /* Depth of inline stack, so 1 = no inlining, 2 = one level, etc. */ \
124 v(unsigned, maximumInliningDepth, 5) \
126 v(int32, thresholdForJITAfterWarmUp, 100) \
127 v(int32, thresholdForJITSoon, 100) \
129 v(int32, thresholdForOptimizeAfterWarmUp, 1000) \
130 v(int32, thresholdForOptimizeAfterLongWarmUp, 1000) \
131 v(int32, thresholdForOptimizeSoon, 1000) \
133 v(int32, executionCounterIncrementForLoop, 1) \
134 v(int32, executionCounterIncrementForReturn, 15) \
136 v(int32, evalThresholdMultiplier, 10) \
138 v(bool, randomizeExecutionCountsBetweenCheckpoints, false) \
139 v(int32, maximumExecutionCountsBetweenCheckpoints, 1000) \
141 v(unsigned, likelyToTakeSlowCaseMinimumCount, 100) \
142 v(unsigned, couldTakeSlowCaseMinimumCount, 10) \
144 v(unsigned, osrExitCountForReoptimization, 100) \
145 v(unsigned, osrExitCountForReoptimizationFromLoop, 5) \
147 v(unsigned, reoptimizationRetryCounterMax, 0) \
148 v(unsigned, reoptimizationRetryCounterStep, 1) \
150 v(unsigned, minimumOptimizationDelay, 1) \
151 v(unsigned, maximumOptimizationDelay, 5) \
152 v(double, desiredProfileLivenessRate, 0.75) \
153 v(double, desiredProfileFullnessRate, 0.35) \
155 v(double, doubleVoteRatioForDoubleFormat, 2) \
156 v(double, structureCheckVoteRatioForHoisting, 1) \
158 v(unsigned, minimumNumberOfScansBetweenRebalance, 100) \
159 v(unsigned, numberOfGCMarkers, computeNumberOfGCMarkers(7)) \
160 v(unsigned, opaqueRootMergeThreshold, 1000) \
161 v(double, minHeapUtilization, 0.8) \
162 v(double, minCopiedBlockUtilization, 0.9) \
164 v(bool, forceWeakRandomSeed, false) \
165 v(unsigned, forcedWeakRandomSeed, 0) \
167 v(bool, useZombieMode, false) \
168 v(bool, objectsAreImmortal, false) \
169 v(bool, showObjectStatistics, false) \
171 v(unsigned, gcMaxHeapSize, 0) \
172 v(bool, recordGCPauseTimes, false) \
173 v(bool, logHeapStatisticsAtExit, false)
177 // This typedef is to allow us to eliminate the '_' in the field name in
178 // union inside Entry. This is needed to keep the style checker happy.
179 typedef int32_t int32
;
181 // Declare the option IDs:
183 #define FOR_EACH_OPTION(type_, name_, defaultValue_) \
185 JSC_OPTIONS(FOR_EACH_OPTION
)
186 #undef FOR_EACH_OPTION
191 static void initialize();
193 // Parses a single command line option in the format "<optionName>=<value>"
194 // (no spaces allowed) and set the specified option if appropriate.
195 JS_EXPORT_PRIVATE
static bool setOption(const char* arg
);
196 JS_EXPORT_PRIVATE
static void dumpAllOptions(FILE* stream
= stdout
);
197 static void dumpOption(OptionID id
, FILE* stream
= stdout
, const char* header
= "", const char* footer
= "");
199 // Declare accessors for each option:
200 #define FOR_EACH_OPTION(type_, name_, defaultValue_) \
201 ALWAYS_INLINE static type_& name_() { return s_options[OPT_##name_].u.type_##Val; }
203 JSC_OPTIONS(FOR_EACH_OPTION
)
204 #undef FOR_EACH_OPTION
215 // For storing for an option value:
219 unsigned unsignedVal
;
222 OptionRange optionRangeVal
;
226 // For storing constant meta data about each option:
234 // Declare the options:
235 #define FOR_EACH_OPTION(type_, name_, defaultValue_) \
237 JSC_OPTIONS(FOR_EACH_OPTION
)
238 #undef FOR_EACH_OPTION
240 // Declare the singleton instance of the options store:
241 JS_EXPORTDATA
static Entry s_options
[numberOfOptions
];
242 static const EntryInfo s_optionsInfo
[numberOfOptions
];