]>
Commit | Line | Data |
---|---|---|
6fe7ccc8 | 1 | /* |
93a37866 | 2 | * Copyright (C) 2011, 2012 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 | ||
93a37866 | 29 | #include "JSExportMacros.h" |
6fe7ccc8 | 30 | #include <stdint.h> |
93a37866 A |
31 | #include <stdio.h> |
32 | ||
33 | namespace JSC { | |
34 | ||
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. | |
40 | // | |
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 | |
45 | // set like so: | |
46 | // | |
47 | // bool jitIsOn = Options::useJIT(); // Get the option value. | |
48 | // Options::useJIT() = false; // Sets the option value. | |
49 | // | |
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 | |
52 | // are set. | |
53 | // | |
54 | // Alternatively, you can override the default values by specifying | |
55 | // environment variables of the form: JSC_<name of JSC option>. | |
56 | // | |
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. | |
62 | ||
63 | class OptionRange { | |
64 | private: | |
65 | enum RangeState { Uninitialized, InitError, Normal, Inverted }; | |
66 | public: | |
67 | OptionRange& operator= (const int& rhs) | |
68 | { // Only needed for initialization | |
69 | if (!rhs) { | |
70 | m_state = Uninitialized; | |
71 | m_rangeString = 0; | |
72 | m_lowLimit = 0; | |
73 | m_highLimit = 0; | |
74 | } | |
75 | return *this; | |
76 | } | |
77 | ||
78 | bool init(const char*); | |
79 | bool isInRange(unsigned); | |
80 | const char* rangeString() { return (m_state > InitError) ? m_rangeString : "<null>"; } | |
81 | ||
82 | private: | |
83 | RangeState m_state; | |
84 | const char* m_rangeString; | |
85 | unsigned m_lowLimit; | |
86 | unsigned m_highLimit; | |
87 | }; | |
88 | ||
89 | typedef OptionRange optionRange; | |
90 | ||
91 | #define JSC_OPTIONS(v) \ | |
92 | v(bool, useJIT, true) \ | |
93 | v(bool, useDFGJIT, true) \ | |
94 | v(bool, useRegExpJIT, true) \ | |
95 | \ | |
96 | v(bool, forceDFGCodeBlockLiveness, false) \ | |
97 | \ | |
98 | v(bool, dumpGeneratedBytecodes, false) \ | |
99 | \ | |
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 | \ | |
113 | v(bool, enableProfiler, false) \ | |
114 | \ | |
115 | v(bool, crashIfCantAllocateJITMemory, false) \ | |
116 | \ | |
117 | v(unsigned, maximumOptimizationCandidateInstructionCount, 10000) \ | |
118 | \ | |
119 | v(unsigned, maximumFunctionForCallInlineCandidateInstructionCount, 180) \ | |
120 | v(unsigned, maximumFunctionForClosureCallInlineCandidateInstructionCount, 100) \ | |
121 | v(unsigned, maximumFunctionForConstructInlineCandidateInstructionCount, 100) \ | |
122 | \ | |
123 | /* Depth of inline stack, so 1 = no inlining, 2 = one level, etc. */ \ | |
124 | v(unsigned, maximumInliningDepth, 5) \ | |
125 | \ | |
126 | v(int32, thresholdForJITAfterWarmUp, 100) \ | |
127 | v(int32, thresholdForJITSoon, 100) \ | |
128 | \ | |
129 | v(int32, thresholdForOptimizeAfterWarmUp, 1000) \ | |
130 | v(int32, thresholdForOptimizeAfterLongWarmUp, 1000) \ | |
131 | v(int32, thresholdForOptimizeSoon, 1000) \ | |
132 | \ | |
133 | v(int32, executionCounterIncrementForLoop, 1) \ | |
134 | v(int32, executionCounterIncrementForReturn, 15) \ | |
135 | \ | |
136 | v(int32, evalThresholdMultiplier, 10) \ | |
137 | \ | |
138 | v(bool, randomizeExecutionCountsBetweenCheckpoints, false) \ | |
139 | v(int32, maximumExecutionCountsBetweenCheckpoints, 1000) \ | |
140 | \ | |
141 | v(unsigned, likelyToTakeSlowCaseMinimumCount, 100) \ | |
142 | v(unsigned, couldTakeSlowCaseMinimumCount, 10) \ | |
143 | \ | |
144 | v(unsigned, osrExitCountForReoptimization, 100) \ | |
145 | v(unsigned, osrExitCountForReoptimizationFromLoop, 5) \ | |
146 | \ | |
147 | v(unsigned, reoptimizationRetryCounterMax, 0) \ | |
148 | v(unsigned, reoptimizationRetryCounterStep, 1) \ | |
149 | \ | |
150 | v(unsigned, minimumOptimizationDelay, 1) \ | |
151 | v(unsigned, maximumOptimizationDelay, 5) \ | |
152 | v(double, desiredProfileLivenessRate, 0.75) \ | |
153 | v(double, desiredProfileFullnessRate, 0.35) \ | |
154 | \ | |
155 | v(double, doubleVoteRatioForDoubleFormat, 2) \ | |
156 | v(double, structureCheckVoteRatioForHoisting, 1) \ | |
157 | \ | |
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) \ | |
163 | \ | |
164 | v(bool, forceWeakRandomSeed, false) \ | |
165 | v(unsigned, forcedWeakRandomSeed, 0) \ | |
166 | \ | |
167 | v(bool, useZombieMode, false) \ | |
168 | v(bool, objectsAreImmortal, false) \ | |
169 | v(bool, showObjectStatistics, false) \ | |
170 | \ | |
171 | v(unsigned, gcMaxHeapSize, 0) \ | |
172 | v(bool, recordGCPauseTimes, false) \ | |
173 | v(bool, logHeapStatisticsAtExit, false) | |
174 | ||
175 | class Options { | |
176 | public: | |
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; | |
180 | ||
181 | // Declare the option IDs: | |
182 | enum OptionID { | |
183 | #define FOR_EACH_OPTION(type_, name_, defaultValue_) \ | |
184 | OPT_##name_, | |
185 | JSC_OPTIONS(FOR_EACH_OPTION) | |
186 | #undef FOR_EACH_OPTION | |
187 | numberOfOptions | |
188 | }; | |
189 | ||
190 | ||
191 | static void initialize(); | |
192 | ||
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 = ""); | |
198 | ||
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; } | |
202 | ||
203 | JSC_OPTIONS(FOR_EACH_OPTION) | |
204 | #undef FOR_EACH_OPTION | |
205 | ||
206 | private: | |
207 | enum EntryType { | |
208 | boolType, | |
209 | unsignedType, | |
210 | doubleType, | |
211 | int32Type, | |
212 | optionRangeType, | |
213 | }; | |
214 | ||
215 | // For storing for an option value: | |
216 | struct Entry { | |
217 | union { | |
218 | bool boolVal; | |
219 | unsigned unsignedVal; | |
220 | double doubleVal; | |
221 | int32 int32Val; | |
222 | OptionRange optionRangeVal; | |
223 | } u; | |
224 | }; | |
225 | ||
226 | // For storing constant meta data about each option: | |
227 | struct EntryInfo { | |
228 | const char* name; | |
229 | EntryType type; | |
230 | }; | |
231 | ||
232 | Options(); | |
233 | ||
234 | // Declare the options: | |
235 | #define FOR_EACH_OPTION(type_, name_, defaultValue_) \ | |
236 | type_ m_##name_; | |
237 | JSC_OPTIONS(FOR_EACH_OPTION) | |
238 | #undef FOR_EACH_OPTION | |
239 | ||
240 | // Declare the singleton instance of the options store: | |
241 | JS_EXPORTDATA static Entry s_options[numberOfOptions]; | |
242 | static const EntryInfo s_optionsInfo[numberOfOptions]; | |
243 | }; | |
244 | ||
245 | } // namespace JSC | |
6fe7ccc8 A |
246 | |
247 | #endif // Options_h |