File: | jdk/src/hotspot/share/compiler/compilerDefinitions.cpp |
Warning: | line 109, column 5 Value stored to 'comma' is never read |
Press '?' to see keyboard shortcuts
Keyboard shortcuts:
1 | /* |
2 | * Copyright (c) 2016, 2021, Oracle and/or its affiliates. All rights reserved. |
3 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4 | * |
5 | * This code is free software; you can redistribute it and/or modify it |
6 | * under the terms of the GNU General Public License version 2 only, as |
7 | * published by the Free Software Foundation. |
8 | * |
9 | * This code is distributed in the hope that it will be useful, but WITHOUT |
10 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
11 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
12 | * version 2 for more details (a copy is included in the LICENSE file that |
13 | * accompanied this code). |
14 | * |
15 | * You should have received a copy of the GNU General Public License version |
16 | * 2 along with this work; if not, write to the Free Software Foundation, |
17 | * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
18 | * |
19 | * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
20 | * or visit www.oracle.com if you need additional information or have any |
21 | * questions. |
22 | * |
23 | */ |
24 | |
25 | #include "precompiled.hpp" |
26 | #include "code/codeCache.hpp" |
27 | #include "runtime/arguments.hpp" |
28 | #include "runtime/flags/jvmFlag.hpp" |
29 | #include "runtime/flags/jvmFlagAccess.hpp" |
30 | #include "runtime/flags/jvmFlagLimit.hpp" |
31 | #include "runtime/globals.hpp" |
32 | #include "runtime/globals_extension.hpp" |
33 | #include "compiler/compilerDefinitions.hpp" |
34 | #include "gc/shared/gcConfig.hpp" |
35 | #include "utilities/defaultStream.hpp" |
36 | |
37 | const char* compilertype2name_tab[compiler_number_of_types] = { |
38 | "", |
39 | "c1", |
40 | "c2", |
41 | "jvmci" |
42 | }; |
43 | |
44 | CompilationModeFlag::Mode CompilationModeFlag::_mode = CompilationModeFlag::Mode::NORMAL; |
45 | |
46 | static void print_mode_unavailable(const char* mode_name, const char* reason) { |
47 | warning("%s compilation mode unavailable because %s.", mode_name, reason); |
48 | } |
49 | |
50 | bool CompilationModeFlag::initialize() { |
51 | _mode = Mode::NORMAL; |
52 | // During parsing we want to be very careful not to use any methods of CompilerConfig that depend on |
53 | // CompilationModeFlag. |
54 | if (CompilationMode != NULL__null) { |
55 | if (strcmp(CompilationMode, "default") == 0 || strcmp(CompilationMode, "normal") == 0) { |
56 | assert(_mode == Mode::NORMAL, "Precondition")do { if (!(_mode == Mode::NORMAL)) { (*g_assert_poison) = 'X' ;; report_vm_error("/home/daniel/Projects/java/jdk/src/hotspot/share/compiler/compilerDefinitions.cpp" , 56, "assert(" "_mode == Mode::NORMAL" ") failed", "Precondition" ); ::breakpoint(); } } while (0); |
57 | } else if (strcmp(CompilationMode, "quick-only") == 0) { |
58 | if (!CompilerConfig::has_c1()) { |
59 | print_mode_unavailable("quick-only", "there is no c1 present"); |
60 | } else { |
61 | _mode = Mode::QUICK_ONLY; |
62 | } |
63 | } else if (strcmp(CompilationMode, "high-only") == 0) { |
64 | if (!CompilerConfig::has_c2() && !CompilerConfig::is_jvmci_compiler()) { |
65 | print_mode_unavailable("high-only", "there is no c2 or jvmci compiler present"); |
66 | } else { |
67 | _mode = Mode::HIGH_ONLY; |
68 | } |
69 | } else if (strcmp(CompilationMode, "high-only-quick-internal") == 0) { |
70 | if (!CompilerConfig::has_c1() || !CompilerConfig::is_jvmci_compiler()) { |
71 | print_mode_unavailable("high-only-quick-internal", "there is no c1 and jvmci compiler present"); |
72 | } else { |
73 | _mode = Mode::HIGH_ONLY_QUICK_INTERNAL; |
74 | } |
75 | } else { |
76 | print_error(); |
77 | return false; |
78 | } |
79 | } |
80 | |
81 | // Now that the flag is parsed, we can use any methods of CompilerConfig. |
82 | if (normal()) { |
83 | if (CompilerConfig::is_c1_simple_only()) { |
84 | _mode = Mode::QUICK_ONLY; |
85 | } else if (CompilerConfig::is_c2_or_jvmci_compiler_only()) { |
86 | _mode = Mode::HIGH_ONLY; |
87 | } else if (CompilerConfig::is_jvmci_compiler_enabled() && CompilerConfig::is_c1_enabled() && !TieredCompilation) { |
88 | warning("Disabling tiered compilation with non-native JVMCI compiler is not recommended, " |
89 | "disabling intermediate compilation levels instead. "); |
90 | _mode = Mode::HIGH_ONLY_QUICK_INTERNAL; |
91 | } |
92 | } |
93 | return true; |
94 | } |
95 | |
96 | void CompilationModeFlag::print_error() { |
97 | jio_fprintf(defaultStream::error_stream(), "Unsupported compilation mode '%s', available modes are:", CompilationMode); |
98 | bool comma = false; |
99 | if (CompilerConfig::has_c1()) { |
100 | jio_fprintf(defaultStream::error_stream(), "%s quick-only", comma ? "," : ""); |
101 | comma = true; |
102 | } |
103 | if (CompilerConfig::has_c2() || CompilerConfig::has_jvmci()) { |
104 | jio_fprintf(defaultStream::error_stream(), "%s high-only", comma ? "," : ""); |
105 | comma = true; |
106 | } |
107 | if (CompilerConfig::has_c1() && CompilerConfig::has_jvmci()) { |
108 | jio_fprintf(defaultStream::error_stream(), "%s high-only-quick-internal", comma ? "," : ""); |
109 | comma = true; |
Value stored to 'comma' is never read | |
110 | } |
111 | jio_fprintf(defaultStream::error_stream(), "\n"); |
112 | } |
113 | |
114 | // Returns threshold scaled with CompileThresholdScaling |
115 | intx CompilerConfig::scaled_compile_threshold(intx threshold) { |
116 | return scaled_compile_threshold(threshold, CompileThresholdScaling); |
117 | } |
118 | |
119 | // Returns freq_log scaled with CompileThresholdScaling |
120 | intx CompilerConfig::scaled_freq_log(intx freq_log) { |
121 | return scaled_freq_log(freq_log, CompileThresholdScaling); |
122 | } |
123 | |
124 | // Returns threshold scaled with the value of scale. |
125 | // If scale < 0.0, threshold is returned without scaling. |
126 | intx CompilerConfig::scaled_compile_threshold(intx threshold, double scale) { |
127 | if (scale == 1.0 || scale < 0.0) { |
128 | return threshold; |
129 | } else { |
130 | return (intx)(threshold * scale); |
131 | } |
132 | } |
133 | |
134 | // Returns freq_log scaled with the value of scale. |
135 | // Returned values are in the range of [0, InvocationCounter::number_of_count_bits + 1]. |
136 | // If scale < 0.0, freq_log is returned without scaling. |
137 | intx CompilerConfig::scaled_freq_log(intx freq_log, double scale) { |
138 | // Check if scaling is necessary or if negative value was specified. |
139 | if (scale == 1.0 || scale < 0.0) { |
140 | return freq_log; |
141 | } |
142 | // Check values to avoid calculating log2 of 0. |
143 | if (scale == 0.0 || freq_log == 0) { |
144 | return 0; |
145 | } |
146 | // Determine the maximum notification frequency value currently supported. |
147 | // The largest mask value that the interpreter/C1 can handle is |
148 | // of length InvocationCounter::number_of_count_bits. Mask values are always |
149 | // one bit shorter then the value of the notification frequency. Set |
150 | // max_freq_bits accordingly. |
151 | int max_freq_bits = InvocationCounter::number_of_count_bits + 1; |
152 | intx scaled_freq = scaled_compile_threshold((intx)1 << freq_log, scale); |
153 | |
154 | if (scaled_freq == 0) { |
155 | // Return 0 right away to avoid calculating log2 of 0. |
156 | return 0; |
157 | } else { |
158 | return MIN2(log2i(scaled_freq), max_freq_bits); |
159 | } |
160 | } |
161 | |
162 | void CompilerConfig::set_client_emulation_mode_flags() { |
163 | assert(has_c1(), "Must have C1 compiler present")do { if (!(has_c1())) { (*g_assert_poison) = 'X';; report_vm_error ("/home/daniel/Projects/java/jdk/src/hotspot/share/compiler/compilerDefinitions.cpp" , 163, "assert(" "has_c1()" ") failed", "Must have C1 compiler present" ); ::breakpoint(); } } while (0); |
164 | CompilationModeFlag::set_quick_only(); |
165 | |
166 | FLAG_SET_ERGO(ProfileInterpreter, false)(Flag_ProfileInterpreter_set((false), JVMFlagOrigin::ERGONOMIC )); |
167 | #if INCLUDE_JVMCI1 |
168 | FLAG_SET_ERGO(EnableJVMCI, false)(Flag_EnableJVMCI_set((false), JVMFlagOrigin::ERGONOMIC)); |
169 | FLAG_SET_ERGO(UseJVMCICompiler, false)(Flag_UseJVMCICompiler_set((false), JVMFlagOrigin::ERGONOMIC) ); |
170 | #endif |
171 | if (FLAG_IS_DEFAULT(NeverActAsServerClassMachine)(JVMFlag::is_default(Flag_NeverActAsServerClassMachine_enum))) { |
172 | FLAG_SET_ERGO(NeverActAsServerClassMachine, true)(Flag_NeverActAsServerClassMachine_set((true), JVMFlagOrigin:: ERGONOMIC)); |
173 | } |
174 | if (FLAG_IS_DEFAULT(InitialCodeCacheSize)(JVMFlag::is_default(Flag_InitialCodeCacheSize_enum))) { |
175 | FLAG_SET_ERGO(InitialCodeCacheSize, 160*K)(Flag_InitialCodeCacheSize_set((160*K), JVMFlagOrigin::ERGONOMIC )); |
176 | } |
177 | if (FLAG_IS_DEFAULT(ReservedCodeCacheSize)(JVMFlag::is_default(Flag_ReservedCodeCacheSize_enum))) { |
178 | FLAG_SET_ERGO(ReservedCodeCacheSize, 32*M)(Flag_ReservedCodeCacheSize_set((32*M), JVMFlagOrigin::ERGONOMIC )); |
179 | } |
180 | if (FLAG_IS_DEFAULT(NonProfiledCodeHeapSize)(JVMFlag::is_default(Flag_NonProfiledCodeHeapSize_enum))) { |
181 | FLAG_SET_ERGO(NonProfiledCodeHeapSize, 27*M)(Flag_NonProfiledCodeHeapSize_set((27*M), JVMFlagOrigin::ERGONOMIC )); |
182 | } |
183 | if (FLAG_IS_DEFAULT(ProfiledCodeHeapSize)(JVMFlag::is_default(Flag_ProfiledCodeHeapSize_enum))) { |
184 | FLAG_SET_ERGO(ProfiledCodeHeapSize, 0)(Flag_ProfiledCodeHeapSize_set((0), JVMFlagOrigin::ERGONOMIC) ); |
185 | } |
186 | if (FLAG_IS_DEFAULT(NonNMethodCodeHeapSize)(JVMFlag::is_default(Flag_NonNMethodCodeHeapSize_enum))) { |
187 | FLAG_SET_ERGO(NonNMethodCodeHeapSize, 5*M)(Flag_NonNMethodCodeHeapSize_set((5*M), JVMFlagOrigin::ERGONOMIC )); |
188 | } |
189 | if (FLAG_IS_DEFAULT(CodeCacheExpansionSize)(JVMFlag::is_default(Flag_CodeCacheExpansionSize_enum))) { |
190 | FLAG_SET_ERGO(CodeCacheExpansionSize, 32*K)(Flag_CodeCacheExpansionSize_set((32*K), JVMFlagOrigin::ERGONOMIC )); |
191 | } |
192 | if (FLAG_IS_DEFAULT(MaxRAM)(JVMFlag::is_default(Flag_MaxRAM_enum))) { |
193 | // Do not use FLAG_SET_ERGO to update MaxRAM, as this will impact |
194 | // heap setting done based on available phys_mem (see Arguments::set_heap_size). |
195 | FLAG_SET_DEFAULT(MaxRAM, 1ULL*G)((MaxRAM) = (1ULL*G)); |
196 | } |
197 | if (FLAG_IS_DEFAULT(CICompilerCount)(JVMFlag::is_default(Flag_CICompilerCount_enum))) { |
198 | FLAG_SET_ERGO(CICompilerCount, 1)(Flag_CICompilerCount_set((1), JVMFlagOrigin::ERGONOMIC)); |
199 | } |
200 | } |
201 | |
202 | bool CompilerConfig::is_compilation_mode_selected() { |
203 | return !FLAG_IS_DEFAULT(TieredCompilation)(JVMFlag::is_default(Flag_TieredCompilation_enum)) || |
204 | !FLAG_IS_DEFAULT(TieredStopAtLevel)(JVMFlag::is_default(Flag_TieredStopAtLevel_enum)) || |
205 | !FLAG_IS_DEFAULT(CompilationMode)(JVMFlag::is_default(Flag_CompilationMode_enum)) |
206 | JVMCI_ONLY(|| !FLAG_IS_DEFAULT(EnableJVMCI)|| !(JVMFlag::is_default(Flag_EnableJVMCI_enum)) || !(JVMFlag ::is_default(Flag_UseJVMCICompiler_enum)) |
207 | || !FLAG_IS_DEFAULT(UseJVMCICompiler))|| !(JVMFlag::is_default(Flag_EnableJVMCI_enum)) || !(JVMFlag ::is_default(Flag_UseJVMCICompiler_enum)); |
208 | } |
209 | |
210 | bool CompilerConfig::is_interpreter_only() { |
211 | return Arguments::is_interpreter_only() || TieredStopAtLevel == CompLevel_none; |
212 | } |
213 | |
214 | static bool check_legacy_flags() { |
215 | JVMFlag* compile_threshold_flag = JVMFlag::flag_from_enum(FLAG_MEMBER_ENUM(CompileThreshold)Flag_CompileThreshold_enum); |
216 | if (JVMFlagAccess::check_constraint(compile_threshold_flag, JVMFlagLimit::get_constraint(compile_threshold_flag)->constraint_func(), false) != JVMFlag::SUCCESS) { |
217 | return false; |
218 | } |
219 | JVMFlag* on_stack_replace_percentage_flag = JVMFlag::flag_from_enum(FLAG_MEMBER_ENUM(OnStackReplacePercentage)Flag_OnStackReplacePercentage_enum); |
220 | if (JVMFlagAccess::check_constraint(on_stack_replace_percentage_flag, JVMFlagLimit::get_constraint(on_stack_replace_percentage_flag)->constraint_func(), false) != JVMFlag::SUCCESS) { |
221 | return false; |
222 | } |
223 | JVMFlag* interpreter_profile_percentage_flag = JVMFlag::flag_from_enum(FLAG_MEMBER_ENUM(InterpreterProfilePercentage)Flag_InterpreterProfilePercentage_enum); |
224 | if (JVMFlagAccess::check_range(interpreter_profile_percentage_flag, false) != JVMFlag::SUCCESS) { |
225 | return false; |
226 | } |
227 | return true; |
228 | } |
229 | |
230 | void CompilerConfig::set_legacy_emulation_flags() { |
231 | // Any legacy flags set? |
232 | if (!FLAG_IS_DEFAULT(CompileThreshold)(JVMFlag::is_default(Flag_CompileThreshold_enum)) || |
233 | !FLAG_IS_DEFAULT(OnStackReplacePercentage)(JVMFlag::is_default(Flag_OnStackReplacePercentage_enum)) || |
234 | !FLAG_IS_DEFAULT(InterpreterProfilePercentage)(JVMFlag::is_default(Flag_InterpreterProfilePercentage_enum))) { |
235 | if (CompilerConfig::is_c1_only() || CompilerConfig::is_c2_or_jvmci_compiler_only()) { |
236 | // This function is called before these flags are validated. In order to not confuse the user with extraneous |
237 | // error messages, we check the validity of these flags here and bail out if any of them are invalid. |
238 | if (!check_legacy_flags()) { |
239 | return; |
240 | } |
241 | // Note, we do not scale CompileThreshold before this because the tiered flags are |
242 | // all going to be scaled further in set_compilation_policy_flags(). |
243 | const intx threshold = CompileThreshold; |
244 | const intx profile_threshold = threshold * InterpreterProfilePercentage / 100; |
245 | const intx osr_threshold = threshold * OnStackReplacePercentage / 100; |
246 | const intx osr_profile_threshold = osr_threshold * InterpreterProfilePercentage / 100; |
247 | |
248 | const intx threshold_log = log2i_graceful(CompilerConfig::is_c1_only() ? threshold : profile_threshold); |
249 | const intx osr_threshold_log = log2i_graceful(CompilerConfig::is_c1_only() ? osr_threshold : osr_profile_threshold); |
250 | |
251 | if (Tier0InvokeNotifyFreqLog > threshold_log) { |
252 | FLAG_SET_ERGO(Tier0InvokeNotifyFreqLog, MAX2<intx>(0, threshold_log))(Flag_Tier0InvokeNotifyFreqLog_set((MAX2<intx>(0, threshold_log )), JVMFlagOrigin::ERGONOMIC)); |
253 | } |
254 | |
255 | // Note: Emulation oddity. The legacy policy limited the amount of callbacks from the |
256 | // interpreter for backedge events to once every 1024 counter increments. |
257 | // We simulate this behavior by limiting the backedge notification frequency to be |
258 | // at least 2^10. |
259 | if (Tier0BackedgeNotifyFreqLog > osr_threshold_log) { |
260 | FLAG_SET_ERGO(Tier0BackedgeNotifyFreqLog, MAX2<intx>(10, osr_threshold_log))(Flag_Tier0BackedgeNotifyFreqLog_set((MAX2<intx>(10, osr_threshold_log )), JVMFlagOrigin::ERGONOMIC)); |
261 | } |
262 | // Adjust the tiered policy flags to approximate the legacy behavior. |
263 | if (CompilerConfig::is_c1_only()) { |
264 | FLAG_SET_ERGO(Tier3InvocationThreshold, threshold)(Flag_Tier3InvocationThreshold_set((threshold), JVMFlagOrigin ::ERGONOMIC)); |
265 | FLAG_SET_ERGO(Tier3MinInvocationThreshold, threshold)(Flag_Tier3MinInvocationThreshold_set((threshold), JVMFlagOrigin ::ERGONOMIC)); |
266 | FLAG_SET_ERGO(Tier3CompileThreshold, threshold)(Flag_Tier3CompileThreshold_set((threshold), JVMFlagOrigin::ERGONOMIC )); |
267 | FLAG_SET_ERGO(Tier3BackEdgeThreshold, osr_threshold)(Flag_Tier3BackEdgeThreshold_set((osr_threshold), JVMFlagOrigin ::ERGONOMIC)); |
268 | } else { |
269 | FLAG_SET_ERGO(Tier4InvocationThreshold, threshold)(Flag_Tier4InvocationThreshold_set((threshold), JVMFlagOrigin ::ERGONOMIC)); |
270 | FLAG_SET_ERGO(Tier4MinInvocationThreshold, threshold)(Flag_Tier4MinInvocationThreshold_set((threshold), JVMFlagOrigin ::ERGONOMIC)); |
271 | FLAG_SET_ERGO(Tier4CompileThreshold, threshold)(Flag_Tier4CompileThreshold_set((threshold), JVMFlagOrigin::ERGONOMIC )); |
272 | FLAG_SET_ERGO(Tier4BackEdgeThreshold, osr_threshold)(Flag_Tier4BackEdgeThreshold_set((osr_threshold), JVMFlagOrigin ::ERGONOMIC)); |
273 | FLAG_SET_ERGO(Tier0ProfilingStartPercentage, InterpreterProfilePercentage)(Flag_Tier0ProfilingStartPercentage_set((InterpreterProfilePercentage ), JVMFlagOrigin::ERGONOMIC)); |
274 | } |
275 | } else { |
276 | // Normal tiered mode, ignore legacy flags |
277 | } |
278 | } |
279 | // Scale CompileThreshold |
280 | // CompileThresholdScaling == 0.0 is equivalent to -Xint and leaves CompileThreshold unchanged. |
281 | if (!FLAG_IS_DEFAULT(CompileThresholdScaling)(JVMFlag::is_default(Flag_CompileThresholdScaling_enum)) && CompileThresholdScaling > 0.0 && CompileThreshold > 0) { |
282 | FLAG_SET_ERGO(CompileThreshold, scaled_compile_threshold(CompileThreshold))(Flag_CompileThreshold_set((scaled_compile_threshold(CompileThreshold )), JVMFlagOrigin::ERGONOMIC)); |
283 | } |
284 | } |
285 | |
286 | |
287 | void CompilerConfig::set_compilation_policy_flags() { |
288 | if (is_tiered()) { |
289 | // Increase the code cache size - tiered compiles a lot more. |
290 | if (FLAG_IS_DEFAULT(ReservedCodeCacheSize)(JVMFlag::is_default(Flag_ReservedCodeCacheSize_enum))) { |
291 | FLAG_SET_ERGO(ReservedCodeCacheSize,(Flag_ReservedCodeCacheSize_set((MIN2((2*G), (size_t)ReservedCodeCacheSize * 5)), JVMFlagOrigin::ERGONOMIC)) |
292 | MIN2(CODE_CACHE_DEFAULT_LIMIT, (size_t)ReservedCodeCacheSize * 5))(Flag_ReservedCodeCacheSize_set((MIN2((2*G), (size_t)ReservedCodeCacheSize * 5)), JVMFlagOrigin::ERGONOMIC)); |
293 | } |
294 | // Enable SegmentedCodeCache if tiered compilation is enabled, ReservedCodeCacheSize >= 240M |
295 | // and the code cache contains at least 8 pages (segmentation disables advantage of huge pages). |
296 | if (FLAG_IS_DEFAULT(SegmentedCodeCache)(JVMFlag::is_default(Flag_SegmentedCodeCache_enum)) && ReservedCodeCacheSize >= 240*M && |
297 | 8 * CodeCache::page_size() <= ReservedCodeCacheSize) { |
298 | FLAG_SET_ERGO(SegmentedCodeCache, true)(Flag_SegmentedCodeCache_set((true), JVMFlagOrigin::ERGONOMIC )); |
299 | } |
300 | if (Arguments::is_compiler_only()) { // -Xcomp |
301 | // Be much more aggressive in tiered mode with -Xcomp and exercise C2 more. |
302 | // We will first compile a level 3 version (C1 with full profiling), then do one invocation of it and |
303 | // compile a level 4 (C2) and then continue executing it. |
304 | if (FLAG_IS_DEFAULT(Tier3InvokeNotifyFreqLog)(JVMFlag::is_default(Flag_Tier3InvokeNotifyFreqLog_enum))) { |
305 | FLAG_SET_CMDLINE(Tier3InvokeNotifyFreqLog, 0)(JVMFlag::setOnCmdLine(Flag_Tier3InvokeNotifyFreqLog_enum), Flag_Tier3InvokeNotifyFreqLog_set ((0), JVMFlagOrigin::COMMAND_LINE)); |
306 | } |
307 | if (FLAG_IS_DEFAULT(Tier4InvocationThreshold)(JVMFlag::is_default(Flag_Tier4InvocationThreshold_enum))) { |
308 | FLAG_SET_CMDLINE(Tier4InvocationThreshold, 0)(JVMFlag::setOnCmdLine(Flag_Tier4InvocationThreshold_enum), Flag_Tier4InvocationThreshold_set ((0), JVMFlagOrigin::COMMAND_LINE)); |
309 | } |
310 | } |
311 | } |
312 | |
313 | |
314 | if (CompileThresholdScaling < 0) { |
315 | vm_exit_during_initialization("Negative value specified for CompileThresholdScaling", NULL__null); |
316 | } |
317 | |
318 | if (CompilationModeFlag::disable_intermediate()) { |
319 | if (FLAG_IS_DEFAULT(Tier0ProfilingStartPercentage)(JVMFlag::is_default(Flag_Tier0ProfilingStartPercentage_enum) )) { |
320 | FLAG_SET_DEFAULT(Tier0ProfilingStartPercentage, 33)((Tier0ProfilingStartPercentage) = (33)); |
321 | } |
322 | |
323 | if (FLAG_IS_DEFAULT(Tier4InvocationThreshold)(JVMFlag::is_default(Flag_Tier4InvocationThreshold_enum))) { |
324 | FLAG_SET_DEFAULT(Tier4InvocationThreshold, 5000)((Tier4InvocationThreshold) = (5000)); |
325 | } |
326 | if (FLAG_IS_DEFAULT(Tier4MinInvocationThreshold)(JVMFlag::is_default(Flag_Tier4MinInvocationThreshold_enum))) { |
327 | FLAG_SET_DEFAULT(Tier4MinInvocationThreshold, 600)((Tier4MinInvocationThreshold) = (600)); |
328 | } |
329 | if (FLAG_IS_DEFAULT(Tier4CompileThreshold)(JVMFlag::is_default(Flag_Tier4CompileThreshold_enum))) { |
330 | FLAG_SET_DEFAULT(Tier4CompileThreshold, 10000)((Tier4CompileThreshold) = (10000)); |
331 | } |
332 | if (FLAG_IS_DEFAULT(Tier4BackEdgeThreshold)(JVMFlag::is_default(Flag_Tier4BackEdgeThreshold_enum))) { |
333 | FLAG_SET_DEFAULT(Tier4BackEdgeThreshold, 15000)((Tier4BackEdgeThreshold) = (15000)); |
334 | } |
335 | } |
336 | |
337 | // Scale tiered compilation thresholds. |
338 | // CompileThresholdScaling == 0.0 is equivalent to -Xint and leaves compilation thresholds unchanged. |
339 | if (!FLAG_IS_DEFAULT(CompileThresholdScaling)(JVMFlag::is_default(Flag_CompileThresholdScaling_enum)) && CompileThresholdScaling > 0.0) { |
340 | FLAG_SET_ERGO(Tier0InvokeNotifyFreqLog, scaled_freq_log(Tier0InvokeNotifyFreqLog))(Flag_Tier0InvokeNotifyFreqLog_set((scaled_freq_log(Tier0InvokeNotifyFreqLog )), JVMFlagOrigin::ERGONOMIC)); |
341 | FLAG_SET_ERGO(Tier0BackedgeNotifyFreqLog, scaled_freq_log(Tier0BackedgeNotifyFreqLog))(Flag_Tier0BackedgeNotifyFreqLog_set((scaled_freq_log(Tier0BackedgeNotifyFreqLog )), JVMFlagOrigin::ERGONOMIC)); |
342 | |
343 | FLAG_SET_ERGO(Tier3InvocationThreshold, scaled_compile_threshold(Tier3InvocationThreshold))(Flag_Tier3InvocationThreshold_set((scaled_compile_threshold( Tier3InvocationThreshold)), JVMFlagOrigin::ERGONOMIC)); |
344 | FLAG_SET_ERGO(Tier3MinInvocationThreshold, scaled_compile_threshold(Tier3MinInvocationThreshold))(Flag_Tier3MinInvocationThreshold_set((scaled_compile_threshold (Tier3MinInvocationThreshold)), JVMFlagOrigin::ERGONOMIC)); |
345 | FLAG_SET_ERGO(Tier3CompileThreshold, scaled_compile_threshold(Tier3CompileThreshold))(Flag_Tier3CompileThreshold_set((scaled_compile_threshold(Tier3CompileThreshold )), JVMFlagOrigin::ERGONOMIC)); |
346 | FLAG_SET_ERGO(Tier3BackEdgeThreshold, scaled_compile_threshold(Tier3BackEdgeThreshold))(Flag_Tier3BackEdgeThreshold_set((scaled_compile_threshold(Tier3BackEdgeThreshold )), JVMFlagOrigin::ERGONOMIC)); |
347 | |
348 | // Tier2{Invocation,MinInvocation,Compile,Backedge}Threshold should be scaled here |
349 | // once these thresholds become supported. |
350 | |
351 | FLAG_SET_ERGO(Tier2InvokeNotifyFreqLog, scaled_freq_log(Tier2InvokeNotifyFreqLog))(Flag_Tier2InvokeNotifyFreqLog_set((scaled_freq_log(Tier2InvokeNotifyFreqLog )), JVMFlagOrigin::ERGONOMIC)); |
352 | FLAG_SET_ERGO(Tier2BackedgeNotifyFreqLog, scaled_freq_log(Tier2BackedgeNotifyFreqLog))(Flag_Tier2BackedgeNotifyFreqLog_set((scaled_freq_log(Tier2BackedgeNotifyFreqLog )), JVMFlagOrigin::ERGONOMIC)); |
353 | |
354 | FLAG_SET_ERGO(Tier3InvokeNotifyFreqLog, scaled_freq_log(Tier3InvokeNotifyFreqLog))(Flag_Tier3InvokeNotifyFreqLog_set((scaled_freq_log(Tier3InvokeNotifyFreqLog )), JVMFlagOrigin::ERGONOMIC)); |
355 | FLAG_SET_ERGO(Tier3BackedgeNotifyFreqLog, scaled_freq_log(Tier3BackedgeNotifyFreqLog))(Flag_Tier3BackedgeNotifyFreqLog_set((scaled_freq_log(Tier3BackedgeNotifyFreqLog )), JVMFlagOrigin::ERGONOMIC)); |
356 | |
357 | FLAG_SET_ERGO(Tier23InlineeNotifyFreqLog, scaled_freq_log(Tier23InlineeNotifyFreqLog))(Flag_Tier23InlineeNotifyFreqLog_set((scaled_freq_log(Tier23InlineeNotifyFreqLog )), JVMFlagOrigin::ERGONOMIC)); |
358 | |
359 | FLAG_SET_ERGO(Tier4InvocationThreshold, scaled_compile_threshold(Tier4InvocationThreshold))(Flag_Tier4InvocationThreshold_set((scaled_compile_threshold( Tier4InvocationThreshold)), JVMFlagOrigin::ERGONOMIC)); |
360 | FLAG_SET_ERGO(Tier4MinInvocationThreshold, scaled_compile_threshold(Tier4MinInvocationThreshold))(Flag_Tier4MinInvocationThreshold_set((scaled_compile_threshold (Tier4MinInvocationThreshold)), JVMFlagOrigin::ERGONOMIC)); |
361 | FLAG_SET_ERGO(Tier4CompileThreshold, scaled_compile_threshold(Tier4CompileThreshold))(Flag_Tier4CompileThreshold_set((scaled_compile_threshold(Tier4CompileThreshold )), JVMFlagOrigin::ERGONOMIC)); |
362 | FLAG_SET_ERGO(Tier4BackEdgeThreshold, scaled_compile_threshold(Tier4BackEdgeThreshold))(Flag_Tier4BackEdgeThreshold_set((scaled_compile_threshold(Tier4BackEdgeThreshold )), JVMFlagOrigin::ERGONOMIC)); |
363 | } |
364 | |
365 | #ifdef COMPILER11 |
366 | // Reduce stack usage due to inlining of methods which require much stack. |
367 | // (High tier compiler can inline better based on profiling information.) |
368 | if (FLAG_IS_DEFAULT(C1InlineStackLimit)(JVMFlag::is_default(Flag_C1InlineStackLimit_enum)) && |
369 | TieredStopAtLevel == CompLevel_full_optimization && !CompilerConfig::is_c1_only()) { |
370 | FLAG_SET_DEFAULT(C1InlineStackLimit, 5)((C1InlineStackLimit) = (5)); |
371 | } |
372 | #endif |
373 | |
374 | if (CompilerConfig::is_tiered() && CompilerConfig::is_c2_enabled()) { |
375 | #ifdef COMPILER21 |
376 | // Some inlining tuning |
377 | #ifdef X86 |
378 | if (FLAG_IS_DEFAULT(InlineSmallCode)(JVMFlag::is_default(Flag_InlineSmallCode_enum))) { |
379 | FLAG_SET_DEFAULT(InlineSmallCode, 2500)((InlineSmallCode) = (2500)); |
380 | } |
381 | #endif |
382 | |
383 | #if defined AARCH64 |
384 | if (FLAG_IS_DEFAULT(InlineSmallCode)(JVMFlag::is_default(Flag_InlineSmallCode_enum))) { |
385 | FLAG_SET_DEFAULT(InlineSmallCode, 2500)((InlineSmallCode) = (2500)); |
386 | } |
387 | #endif |
388 | #endif // COMPILER2 |
389 | } |
390 | |
391 | } |
392 | |
393 | #if INCLUDE_JVMCI1 |
394 | void CompilerConfig::set_jvmci_specific_flags() { |
395 | if (UseJVMCICompiler) { |
396 | if (FLAG_IS_DEFAULT(TypeProfileWidth)(JVMFlag::is_default(Flag_TypeProfileWidth_enum))) { |
397 | FLAG_SET_DEFAULT(TypeProfileWidth, 8)((TypeProfileWidth) = (8)); |
398 | } |
399 | if (FLAG_IS_DEFAULT(TypeProfileLevel)(JVMFlag::is_default(Flag_TypeProfileLevel_enum))) { |
400 | FLAG_SET_DEFAULT(TypeProfileLevel, 0)((TypeProfileLevel) = (0)); |
401 | } |
402 | |
403 | if (UseJVMCINativeLibrary) { |
404 | // SVM compiled code requires more stack space |
405 | if (FLAG_IS_DEFAULT(CompilerThreadStackSize)(JVMFlag::is_default(Flag_CompilerThreadStackSize_enum))) { |
406 | // Duplicate logic in the implementations of os::create_thread |
407 | // so that we can then double the computed stack size. Once |
408 | // the stack size requirements of SVM are better understood, |
409 | // this logic can be pushed down into os::create_thread. |
410 | int stack_size = CompilerThreadStackSize; |
411 | if (stack_size == 0) { |
412 | stack_size = VMThreadStackSize; |
413 | } |
414 | if (stack_size != 0) { |
415 | FLAG_SET_DEFAULT(CompilerThreadStackSize, stack_size * 2)((CompilerThreadStackSize) = (stack_size * 2)); |
416 | } |
417 | } |
418 | } else { |
419 | // JVMCI needs values not less than defaults |
420 | if (FLAG_IS_DEFAULT(ReservedCodeCacheSize)(JVMFlag::is_default(Flag_ReservedCodeCacheSize_enum))) { |
421 | FLAG_SET_DEFAULT(ReservedCodeCacheSize, MAX2(64*M, ReservedCodeCacheSize))((ReservedCodeCacheSize) = (MAX2(64*M, ReservedCodeCacheSize) )); |
422 | } |
423 | if (FLAG_IS_DEFAULT(InitialCodeCacheSize)(JVMFlag::is_default(Flag_InitialCodeCacheSize_enum))) { |
424 | FLAG_SET_DEFAULT(InitialCodeCacheSize, MAX2(16*M, InitialCodeCacheSize))((InitialCodeCacheSize) = (MAX2(16*M, InitialCodeCacheSize))); |
425 | } |
426 | if (FLAG_IS_DEFAULT(NewSizeThreadIncrease)(JVMFlag::is_default(Flag_NewSizeThreadIncrease_enum))) { |
427 | FLAG_SET_DEFAULT(NewSizeThreadIncrease, MAX2(4*K, NewSizeThreadIncrease))((NewSizeThreadIncrease) = (MAX2(4*K, NewSizeThreadIncrease)) ); |
428 | } |
429 | if (FLAG_IS_DEFAULT(Tier3DelayOn)(JVMFlag::is_default(Flag_Tier3DelayOn_enum))) { |
430 | // This effectively prevents the compile broker scheduling tier 2 |
431 | // (i.e., limited C1 profiling) compilations instead of tier 3 |
432 | // (i.e., full C1 profiling) compilations when the tier 4 queue |
433 | // backs up (which is quite likely when using a non-AOT compiled JVMCI |
434 | // compiler). The observation based on jargraal is that the downside |
435 | // of skipping full profiling is much worse for performance than the |
436 | // queue backing up. |
437 | FLAG_SET_DEFAULT(Tier3DelayOn, 100000)((Tier3DelayOn) = (100000)); |
438 | } |
439 | } // !UseJVMCINativeLibrary |
440 | } // UseJVMCICompiler |
441 | } |
442 | #endif // INCLUDE_JVMCI |
443 | |
444 | bool CompilerConfig::check_args_consistency(bool status) { |
445 | // Check lower bounds of the code cache |
446 | // Template Interpreter code is approximately 3X larger in debug builds. |
447 | uint min_code_cache_size = CodeCacheMinimumUseSpace DEBUG_ONLY(* 3)* 3; |
448 | if (ReservedCodeCacheSize < InitialCodeCacheSize) { |
449 | jio_fprintf(defaultStream::error_stream(), |
450 | "Invalid ReservedCodeCacheSize: %dK. Must be at least InitialCodeCacheSize=%dK.\n", |
451 | ReservedCodeCacheSize/K, InitialCodeCacheSize/K); |
452 | status = false; |
453 | } else if (ReservedCodeCacheSize < min_code_cache_size) { |
454 | jio_fprintf(defaultStream::error_stream(), |
455 | "Invalid ReservedCodeCacheSize=%dK. Must be at least %uK.\n", ReservedCodeCacheSize/K, |
456 | min_code_cache_size/K); |
457 | status = false; |
458 | } else if (ReservedCodeCacheSize > CODE_CACHE_SIZE_LIMIT(2*G)) { |
459 | // Code cache size larger than CODE_CACHE_SIZE_LIMIT is not supported. |
460 | jio_fprintf(defaultStream::error_stream(), |
461 | "Invalid ReservedCodeCacheSize=%dM. Must be at most %uM.\n", ReservedCodeCacheSize/M, |
462 | CODE_CACHE_SIZE_LIMIT(2*G)/M); |
463 | status = false; |
464 | } else if (NonNMethodCodeHeapSize < min_code_cache_size) { |
465 | jio_fprintf(defaultStream::error_stream(), |
466 | "Invalid NonNMethodCodeHeapSize=%dK. Must be at least %uK.\n", NonNMethodCodeHeapSize/K, |
467 | min_code_cache_size/K); |
468 | status = false; |
469 | } |
470 | |
471 | #ifdef _LP641 |
472 | if (!FLAG_IS_DEFAULT(CICompilerCount)(JVMFlag::is_default(Flag_CICompilerCount_enum)) && !FLAG_IS_DEFAULT(CICompilerCountPerCPU)(JVMFlag::is_default(Flag_CICompilerCountPerCPU_enum)) && CICompilerCountPerCPU) { |
473 | warning("The VM option CICompilerCountPerCPU overrides CICompilerCount."); |
474 | } |
475 | #endif |
476 | |
477 | if (BackgroundCompilation && ReplayCompiles) { |
478 | if (!FLAG_IS_DEFAULT(BackgroundCompilation)(JVMFlag::is_default(Flag_BackgroundCompilation_enum))) { |
479 | warning("BackgroundCompilation disabled due to ReplayCompiles option."); |
480 | } |
481 | FLAG_SET_CMDLINE(BackgroundCompilation, false)(JVMFlag::setOnCmdLine(Flag_BackgroundCompilation_enum), Flag_BackgroundCompilation_set ((false), JVMFlagOrigin::COMMAND_LINE)); |
482 | } |
483 | |
484 | #ifdef COMPILER21 |
485 | if (PostLoopMultiversioning && !RangeCheckElimination) { |
486 | if (!FLAG_IS_DEFAULT(PostLoopMultiversioning)(JVMFlag::is_default(Flag_PostLoopMultiversioning_enum))) { |
487 | warning("PostLoopMultiversioning disabled because RangeCheckElimination is disabled."); |
488 | } |
489 | FLAG_SET_CMDLINE(PostLoopMultiversioning, false)(JVMFlag::setOnCmdLine(Flag_PostLoopMultiversioning_enum), Flag_PostLoopMultiversioning_set ((false), JVMFlagOrigin::COMMAND_LINE)); |
490 | } |
491 | #endif // COMPILER2 |
492 | |
493 | if (CompilerConfig::is_interpreter_only()) { |
494 | if (UseCompiler) { |
495 | if (!FLAG_IS_DEFAULT(UseCompiler)(JVMFlag::is_default(Flag_UseCompiler_enum))) { |
496 | warning("UseCompiler disabled due to -Xint."); |
497 | } |
498 | FLAG_SET_CMDLINE(UseCompiler, false)(JVMFlag::setOnCmdLine(Flag_UseCompiler_enum), Flag_UseCompiler_set ((false), JVMFlagOrigin::COMMAND_LINE)); |
499 | } |
500 | if (ProfileInterpreter) { |
501 | if (!FLAG_IS_DEFAULT(ProfileInterpreter)(JVMFlag::is_default(Flag_ProfileInterpreter_enum))) { |
502 | warning("ProfileInterpreter disabled due to -Xint."); |
503 | } |
504 | FLAG_SET_CMDLINE(ProfileInterpreter, false)(JVMFlag::setOnCmdLine(Flag_ProfileInterpreter_enum), Flag_ProfileInterpreter_set ((false), JVMFlagOrigin::COMMAND_LINE)); |
505 | } |
506 | if (TieredCompilation) { |
507 | if (!FLAG_IS_DEFAULT(TieredCompilation)(JVMFlag::is_default(Flag_TieredCompilation_enum))) { |
508 | warning("TieredCompilation disabled due to -Xint."); |
509 | } |
510 | FLAG_SET_CMDLINE(TieredCompilation, false)(JVMFlag::setOnCmdLine(Flag_TieredCompilation_enum), Flag_TieredCompilation_set ((false), JVMFlagOrigin::COMMAND_LINE)); |
511 | } |
512 | #if INCLUDE_JVMCI1 |
513 | if (EnableJVMCI) { |
514 | if (!FLAG_IS_DEFAULT(EnableJVMCI)(JVMFlag::is_default(Flag_EnableJVMCI_enum)) || !FLAG_IS_DEFAULT(UseJVMCICompiler)(JVMFlag::is_default(Flag_UseJVMCICompiler_enum))) { |
515 | warning("JVMCI Compiler disabled due to -Xint."); |
516 | } |
517 | FLAG_SET_CMDLINE(EnableJVMCI, false)(JVMFlag::setOnCmdLine(Flag_EnableJVMCI_enum), Flag_EnableJVMCI_set ((false), JVMFlagOrigin::COMMAND_LINE)); |
518 | FLAG_SET_CMDLINE(UseJVMCICompiler, false)(JVMFlag::setOnCmdLine(Flag_UseJVMCICompiler_enum), Flag_UseJVMCICompiler_set ((false), JVMFlagOrigin::COMMAND_LINE)); |
519 | } |
520 | #endif |
521 | } else { |
522 | #if INCLUDE_JVMCI1 |
523 | status = status && JVMCIGlobals::check_jvmci_flags_are_consistent(); |
524 | #endif |
525 | } |
526 | |
527 | return status; |
528 | } |
529 | |
530 | void CompilerConfig::ergo_initialize() { |
531 | #if !COMPILER1_OR_COMPILER21 |
532 | return; |
533 | #endif |
534 | |
535 | if (has_c1()) { |
536 | if (!is_compilation_mode_selected()) { |
537 | #if defined(_WINDOWS) && !defined(_LP641) |
538 | if (FLAG_IS_DEFAULT(NeverActAsServerClassMachine)(JVMFlag::is_default(Flag_NeverActAsServerClassMachine_enum))) { |
539 | FLAG_SET_ERGO(NeverActAsServerClassMachine, true)(Flag_NeverActAsServerClassMachine_set((true), JVMFlagOrigin:: ERGONOMIC)); |
540 | } |
541 | #endif |
542 | if (NeverActAsServerClassMachine) { |
543 | set_client_emulation_mode_flags(); |
544 | } |
545 | } else if (!has_c2() && !is_jvmci_compiler()) { |
546 | set_client_emulation_mode_flags(); |
547 | } |
548 | } |
549 | |
550 | set_legacy_emulation_flags(); |
551 | set_compilation_policy_flags(); |
552 | |
553 | #if INCLUDE_JVMCI1 |
554 | // Check that JVMCI supports selected GC. |
555 | // Should be done after GCConfig::initialize() was called. |
556 | JVMCIGlobals::check_jvmci_supported_gc(); |
557 | |
558 | // Do JVMCI specific settings |
559 | set_jvmci_specific_flags(); |
560 | #endif |
561 | |
562 | if (FLAG_IS_DEFAULT(SweeperThreshold)(JVMFlag::is_default(Flag_SweeperThreshold_enum))) { |
563 | if ((SweeperThreshold * ReservedCodeCacheSize / 100) > (1.2 * M)) { |
564 | // Cap default SweeperThreshold value to an equivalent of 1.2 Mb |
565 | FLAG_SET_ERGO(SweeperThreshold, (1.2 * M * 100) / ReservedCodeCacheSize)(Flag_SweeperThreshold_set(((1.2 * M * 100) / ReservedCodeCacheSize ), JVMFlagOrigin::ERGONOMIC)); |
566 | } |
567 | } |
568 | |
569 | if (UseOnStackReplacement && !UseLoopCounter) { |
570 | warning("On-stack-replacement requires loop counters; enabling loop counters"); |
571 | FLAG_SET_DEFAULT(UseLoopCounter, true)((UseLoopCounter) = (true)); |
572 | } |
573 | |
574 | if (ProfileInterpreter && CompilerConfig::is_c1_simple_only()) { |
575 | if (!FLAG_IS_DEFAULT(ProfileInterpreter)(JVMFlag::is_default(Flag_ProfileInterpreter_enum))) { |
576 | warning("ProfileInterpreter disabled due to client emulation mode"); |
577 | } |
578 | FLAG_SET_CMDLINE(ProfileInterpreter, false)(JVMFlag::setOnCmdLine(Flag_ProfileInterpreter_enum), Flag_ProfileInterpreter_set ((false), JVMFlagOrigin::COMMAND_LINE)); |
579 | } |
580 | |
581 | #ifdef COMPILER21 |
582 | if (!EliminateLocks) { |
583 | EliminateNestedLocks = false; |
584 | } |
585 | if (!Inline || !IncrementalInline) { |
586 | IncrementalInline = false; |
587 | IncrementalInlineMH = false; |
588 | IncrementalInlineVirtual = false; |
589 | } |
590 | #ifndef PRODUCT |
591 | if (!IncrementalInline) { |
592 | AlwaysIncrementalInline = false; |
593 | } |
594 | if (FLAG_IS_CMDLINE(PrintIdealGraph)(JVMFlag::is_cmdline(Flag_PrintIdealGraph_enum)) && !PrintIdealGraph) { |
595 | FLAG_SET_ERGO(PrintIdealGraphLevel, -1)(Flag_PrintIdealGraphLevel_set((-1), JVMFlagOrigin::ERGONOMIC )); |
596 | } |
597 | #endif |
598 | if (!UseTypeSpeculation && FLAG_IS_DEFAULT(TypeProfileLevel)(JVMFlag::is_default(Flag_TypeProfileLevel_enum))) { |
599 | // nothing to use the profiling, turn if off |
600 | FLAG_SET_DEFAULT(TypeProfileLevel, 0)((TypeProfileLevel) = (0)); |
601 | } |
602 | if (!FLAG_IS_DEFAULT(OptoLoopAlignment)(JVMFlag::is_default(Flag_OptoLoopAlignment_enum)) && FLAG_IS_DEFAULT(MaxLoopPad)(JVMFlag::is_default(Flag_MaxLoopPad_enum))) { |
603 | FLAG_SET_DEFAULT(MaxLoopPad, OptoLoopAlignment-1)((MaxLoopPad) = (OptoLoopAlignment-1)); |
604 | } |
605 | if (FLAG_IS_DEFAULT(LoopStripMiningIterShortLoop)(JVMFlag::is_default(Flag_LoopStripMiningIterShortLoop_enum))) { |
606 | // blind guess |
607 | LoopStripMiningIterShortLoop = LoopStripMiningIter / 10; |
608 | } |
609 | #endif // COMPILER2 |
610 | } |
611 |