|
1 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- |
|
2 * vim: set ts=8 sts=4 et sw=4 tw=99: |
|
3 * This Source Code Form is subject to the terms of the Mozilla Public |
|
4 * License, v. 2.0. If a copy of the MPL was not distributed with this |
|
5 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ |
|
6 |
|
7 #include "jit/JitOptions.h" |
|
8 |
|
9 #include "jsscript.h" |
|
10 |
|
11 using namespace js; |
|
12 using namespace js::jit; |
|
13 |
|
14 namespace js { |
|
15 namespace jit { |
|
16 |
|
17 JitOptions js_JitOptions; |
|
18 |
|
19 JitOptions::JitOptions() |
|
20 { |
|
21 // Whether to perform expensive graph-consistency DEBUG-only assertions. |
|
22 // It can be useful to disable this to reduce DEBUG-compile time of large |
|
23 // asm.js programs. |
|
24 checkGraphConsistency = true; |
|
25 |
|
26 #ifdef CHECK_OSIPOINT_REGISTERS |
|
27 // Emit extra code to verify live regs at the start of a VM call |
|
28 // are not modified before its OsiPoint. |
|
29 checkOsiPointRegisters = false; |
|
30 #endif |
|
31 |
|
32 // Whether to enable extra code to perform dynamic validation of |
|
33 // RangeAnalysis results. |
|
34 checkRangeAnalysis = false; |
|
35 |
|
36 // Whether Ion should compile try-catch statements. |
|
37 compileTryCatch = true; |
|
38 |
|
39 // Toggle whether global value numbering is globally disabled. |
|
40 disableGvn = false; |
|
41 |
|
42 // Toggles whether loop invariant code motion is globally disabled. |
|
43 disableLicm = false; |
|
44 |
|
45 // Toggles whether inlining is globally disabled. |
|
46 disableInlining = false; |
|
47 |
|
48 // Toggles whether Edge Case Analysis is gobally disabled. |
|
49 disableEdgeCaseAnalysis = false; |
|
50 |
|
51 // Toggles whether Range Analysis is globally disabled. |
|
52 disableRangeAnalysis = false; |
|
53 |
|
54 // Toggles whether Unreachable Code Elimination is globally disabled. |
|
55 disableUce = false; |
|
56 |
|
57 // Toggles whether Effective Address Analysis is globally disabled. |
|
58 disableEaa = false; |
|
59 |
|
60 // Whether functions are compiled immediately. |
|
61 eagerCompilation = false; |
|
62 |
|
63 // Force how many invocation or loop iterations are needed before compiling |
|
64 // a function with the highest ionmonkey optimization level. |
|
65 // (i.e. OptimizationLevel_Normal) |
|
66 forceDefaultIonUsesBeforeCompile = false; |
|
67 forcedDefaultIonUsesBeforeCompile = 1000; |
|
68 |
|
69 // Force the GVN kind to be optimistic or pessimistic instead of letting |
|
70 // the optimization pass decide. |
|
71 forceGvnKind = false; |
|
72 forcedGvnKind = GVN_Optimistic; |
|
73 |
|
74 // Force the used register allocator instead of letting the |
|
75 // optimization pass decide. |
|
76 forceRegisterAllocator = false; |
|
77 forcedRegisterAllocator = RegisterAllocator_LSRA; |
|
78 |
|
79 // Toggles whether large scripts are rejected. |
|
80 limitScriptSize = true; |
|
81 |
|
82 // Toggles whether functions may be entered at loop headers. |
|
83 osr = true; |
|
84 |
|
85 // How many invocations or loop iterations are needed before functions |
|
86 // are compiled with the baseline compiler. |
|
87 baselineUsesBeforeCompile = 10; |
|
88 |
|
89 // Number of exception bailouts (resuming into catch/finally block) before |
|
90 // we invalidate and forbid Ion compilation. |
|
91 exceptionBailoutThreshold = 10; |
|
92 |
|
93 // Number of bailouts without invalidation before we set |
|
94 // JSScript::hadFrequentBailouts and invalidate. |
|
95 frequentBailoutThreshold = 10; |
|
96 |
|
97 // How many actual arguments are accepted on the C stack. |
|
98 maxStackArgs = 4096; |
|
99 |
|
100 // How many times we will try to enter a script via OSR before |
|
101 // invalidating the script. |
|
102 osrPcMismatchesBeforeRecompile = 6000; |
|
103 |
|
104 // The bytecode length limit for small function. |
|
105 // |
|
106 // The default for this was arrived at empirically via benchmarking. |
|
107 // We may want to tune it further after other optimizations have gone |
|
108 // in. |
|
109 smallFunctionMaxBytecodeLength_ = 100; |
|
110 |
|
111 // How many uses of a parallel kernel before we attempt compilation. |
|
112 usesBeforeCompilePar = 1; |
|
113 |
|
114 // Whether to profile inlined functions in Ion or not. |
|
115 profileInlineFrames = false; |
|
116 } |
|
117 |
|
118 bool |
|
119 JitOptions::isSmallFunction(JSScript *script) const |
|
120 { |
|
121 return script->length() <= smallFunctionMaxBytecodeLength_; |
|
122 } |
|
123 |
|
124 void |
|
125 JitOptions::setEagerCompilation() |
|
126 { |
|
127 eagerCompilation = true; |
|
128 baselineUsesBeforeCompile = 0; |
|
129 forceDefaultIonUsesBeforeCompile = true; |
|
130 forcedDefaultIonUsesBeforeCompile = 0; |
|
131 } |
|
132 |
|
133 void |
|
134 JitOptions::setUsesBeforeCompile(uint32_t useCount) |
|
135 { |
|
136 forceDefaultIonUsesBeforeCompile = true; |
|
137 forcedDefaultIonUsesBeforeCompile = useCount; |
|
138 |
|
139 // Undo eager compilation |
|
140 if (eagerCompilation && useCount != 0) { |
|
141 jit::JitOptions defaultValues; |
|
142 eagerCompilation = false; |
|
143 baselineUsesBeforeCompile = defaultValues.baselineUsesBeforeCompile; |
|
144 } |
|
145 } |
|
146 |
|
147 void |
|
148 JitOptions::resetUsesBeforeCompile() |
|
149 { |
|
150 forceDefaultIonUsesBeforeCompile = false; |
|
151 |
|
152 // Undo eager compilation |
|
153 if (eagerCompilation) { |
|
154 jit::JitOptions defaultValues; |
|
155 eagerCompilation = false; |
|
156 baselineUsesBeforeCompile = defaultValues.baselineUsesBeforeCompile; |
|
157 } |
|
158 } |
|
159 |
|
160 } // namespace jit |
|
161 } // namespace js |