Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/mobile
Path: blob/master/src/hotspot/share/compiler/compilerDefinitions.cpp
40930 views
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) {
55
if (strcmp(CompilationMode, "default") == 0 || strcmp(CompilationMode, "normal") == 0) {
56
assert(_mode == Mode::NORMAL, "Precondition");
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;
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");
164
CompilationModeFlag::set_quick_only();
165
166
FLAG_SET_ERGO(ProfileInterpreter, false);
167
#if INCLUDE_JVMCI
168
FLAG_SET_ERGO(EnableJVMCI, false);
169
FLAG_SET_ERGO(UseJVMCICompiler, false);
170
#endif
171
if (FLAG_IS_DEFAULT(NeverActAsServerClassMachine)) {
172
FLAG_SET_ERGO(NeverActAsServerClassMachine, true);
173
}
174
if (FLAG_IS_DEFAULT(InitialCodeCacheSize)) {
175
FLAG_SET_ERGO(InitialCodeCacheSize, 160*K);
176
}
177
if (FLAG_IS_DEFAULT(ReservedCodeCacheSize)) {
178
FLAG_SET_ERGO(ReservedCodeCacheSize, 32*M);
179
}
180
if (FLAG_IS_DEFAULT(NonProfiledCodeHeapSize)) {
181
FLAG_SET_ERGO(NonProfiledCodeHeapSize, 27*M);
182
}
183
if (FLAG_IS_DEFAULT(ProfiledCodeHeapSize)) {
184
FLAG_SET_ERGO(ProfiledCodeHeapSize, 0);
185
}
186
if (FLAG_IS_DEFAULT(NonNMethodCodeHeapSize)) {
187
FLAG_SET_ERGO(NonNMethodCodeHeapSize, 5*M);
188
}
189
if (FLAG_IS_DEFAULT(CodeCacheExpansionSize)) {
190
FLAG_SET_ERGO(CodeCacheExpansionSize, 32*K);
191
}
192
if (FLAG_IS_DEFAULT(MaxRAM)) {
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);
196
}
197
if (FLAG_IS_DEFAULT(CICompilerCount)) {
198
FLAG_SET_ERGO(CICompilerCount, 1);
199
}
200
}
201
202
bool CompilerConfig::is_compilation_mode_selected() {
203
return !FLAG_IS_DEFAULT(TieredCompilation) ||
204
!FLAG_IS_DEFAULT(TieredStopAtLevel) ||
205
!FLAG_IS_DEFAULT(CompilationMode)
206
JVMCI_ONLY(|| !FLAG_IS_DEFAULT(EnableJVMCI)
207
|| !FLAG_IS_DEFAULT(UseJVMCICompiler));
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));
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));
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));
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) ||
233
!FLAG_IS_DEFAULT(OnStackReplacePercentage) ||
234
!FLAG_IS_DEFAULT(InterpreterProfilePercentage)) {
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));
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));
261
}
262
// Adjust the tiered policy flags to approximate the legacy behavior.
263
if (CompilerConfig::is_c1_only()) {
264
FLAG_SET_ERGO(Tier3InvocationThreshold, threshold);
265
FLAG_SET_ERGO(Tier3MinInvocationThreshold, threshold);
266
FLAG_SET_ERGO(Tier3CompileThreshold, threshold);
267
FLAG_SET_ERGO(Tier3BackEdgeThreshold, osr_threshold);
268
} else {
269
FLAG_SET_ERGO(Tier4InvocationThreshold, threshold);
270
FLAG_SET_ERGO(Tier4MinInvocationThreshold, threshold);
271
FLAG_SET_ERGO(Tier4CompileThreshold, threshold);
272
FLAG_SET_ERGO(Tier4BackEdgeThreshold, osr_threshold);
273
FLAG_SET_ERGO(Tier0ProfilingStartPercentage, InterpreterProfilePercentage);
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) && CompileThresholdScaling > 0.0 && CompileThreshold > 0) {
282
FLAG_SET_ERGO(CompileThreshold, scaled_compile_threshold(CompileThreshold));
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)) {
291
FLAG_SET_ERGO(ReservedCodeCacheSize,
292
MIN2(CODE_CACHE_DEFAULT_LIMIT, (size_t)ReservedCodeCacheSize * 5));
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) && ReservedCodeCacheSize >= 240*M &&
297
8 * CodeCache::page_size() <= ReservedCodeCacheSize) {
298
FLAG_SET_ERGO(SegmentedCodeCache, true);
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)) {
305
FLAG_SET_CMDLINE(Tier3InvokeNotifyFreqLog, 0);
306
}
307
if (FLAG_IS_DEFAULT(Tier4InvocationThreshold)) {
308
FLAG_SET_CMDLINE(Tier4InvocationThreshold, 0);
309
}
310
}
311
}
312
313
314
if (CompileThresholdScaling < 0) {
315
vm_exit_during_initialization("Negative value specified for CompileThresholdScaling", NULL);
316
}
317
318
if (CompilationModeFlag::disable_intermediate()) {
319
if (FLAG_IS_DEFAULT(Tier0ProfilingStartPercentage)) {
320
FLAG_SET_DEFAULT(Tier0ProfilingStartPercentage, 33);
321
}
322
323
if (FLAG_IS_DEFAULT(Tier4InvocationThreshold)) {
324
FLAG_SET_DEFAULT(Tier4InvocationThreshold, 5000);
325
}
326
if (FLAG_IS_DEFAULT(Tier4MinInvocationThreshold)) {
327
FLAG_SET_DEFAULT(Tier4MinInvocationThreshold, 600);
328
}
329
if (FLAG_IS_DEFAULT(Tier4CompileThreshold)) {
330
FLAG_SET_DEFAULT(Tier4CompileThreshold, 10000);
331
}
332
if (FLAG_IS_DEFAULT(Tier4BackEdgeThreshold)) {
333
FLAG_SET_DEFAULT(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) && CompileThresholdScaling > 0.0) {
340
FLAG_SET_ERGO(Tier0InvokeNotifyFreqLog, scaled_freq_log(Tier0InvokeNotifyFreqLog));
341
FLAG_SET_ERGO(Tier0BackedgeNotifyFreqLog, scaled_freq_log(Tier0BackedgeNotifyFreqLog));
342
343
FLAG_SET_ERGO(Tier3InvocationThreshold, scaled_compile_threshold(Tier3InvocationThreshold));
344
FLAG_SET_ERGO(Tier3MinInvocationThreshold, scaled_compile_threshold(Tier3MinInvocationThreshold));
345
FLAG_SET_ERGO(Tier3CompileThreshold, scaled_compile_threshold(Tier3CompileThreshold));
346
FLAG_SET_ERGO(Tier3BackEdgeThreshold, scaled_compile_threshold(Tier3BackEdgeThreshold));
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));
352
FLAG_SET_ERGO(Tier2BackedgeNotifyFreqLog, scaled_freq_log(Tier2BackedgeNotifyFreqLog));
353
354
FLAG_SET_ERGO(Tier3InvokeNotifyFreqLog, scaled_freq_log(Tier3InvokeNotifyFreqLog));
355
FLAG_SET_ERGO(Tier3BackedgeNotifyFreqLog, scaled_freq_log(Tier3BackedgeNotifyFreqLog));
356
357
FLAG_SET_ERGO(Tier23InlineeNotifyFreqLog, scaled_freq_log(Tier23InlineeNotifyFreqLog));
358
359
FLAG_SET_ERGO(Tier4InvocationThreshold, scaled_compile_threshold(Tier4InvocationThreshold));
360
FLAG_SET_ERGO(Tier4MinInvocationThreshold, scaled_compile_threshold(Tier4MinInvocationThreshold));
361
FLAG_SET_ERGO(Tier4CompileThreshold, scaled_compile_threshold(Tier4CompileThreshold));
362
FLAG_SET_ERGO(Tier4BackEdgeThreshold, scaled_compile_threshold(Tier4BackEdgeThreshold));
363
}
364
365
#ifdef COMPILER1
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) &&
369
TieredStopAtLevel == CompLevel_full_optimization && !CompilerConfig::is_c1_only()) {
370
FLAG_SET_DEFAULT(C1InlineStackLimit, 5);
371
}
372
#endif
373
374
if (CompilerConfig::is_tiered() && CompilerConfig::is_c2_enabled()) {
375
#ifdef COMPILER2
376
// Some inlining tuning
377
#ifdef X86
378
if (FLAG_IS_DEFAULT(InlineSmallCode)) {
379
FLAG_SET_DEFAULT(InlineSmallCode, 2500);
380
}
381
#endif
382
383
#if defined AARCH64
384
if (FLAG_IS_DEFAULT(InlineSmallCode)) {
385
FLAG_SET_DEFAULT(InlineSmallCode, 2500);
386
}
387
#endif
388
#endif // COMPILER2
389
}
390
391
}
392
393
#if INCLUDE_JVMCI
394
void CompilerConfig::set_jvmci_specific_flags() {
395
if (UseJVMCICompiler) {
396
if (FLAG_IS_DEFAULT(TypeProfileWidth)) {
397
FLAG_SET_DEFAULT(TypeProfileWidth, 8);
398
}
399
if (FLAG_IS_DEFAULT(TypeProfileLevel)) {
400
FLAG_SET_DEFAULT(TypeProfileLevel, 0);
401
}
402
403
if (UseJVMCINativeLibrary) {
404
// SVM compiled code requires more stack space
405
if (FLAG_IS_DEFAULT(CompilerThreadStackSize)) {
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);
416
}
417
}
418
} else {
419
// JVMCI needs values not less than defaults
420
if (FLAG_IS_DEFAULT(ReservedCodeCacheSize)) {
421
FLAG_SET_DEFAULT(ReservedCodeCacheSize, MAX2(64*M, ReservedCodeCacheSize));
422
}
423
if (FLAG_IS_DEFAULT(InitialCodeCacheSize)) {
424
FLAG_SET_DEFAULT(InitialCodeCacheSize, MAX2(16*M, InitialCodeCacheSize));
425
}
426
if (FLAG_IS_DEFAULT(NewSizeThreadIncrease)) {
427
FLAG_SET_DEFAULT(NewSizeThreadIncrease, MAX2(4*K, NewSizeThreadIncrease));
428
}
429
if (FLAG_IS_DEFAULT(Tier3DelayOn)) {
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);
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);
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) {
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/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 _LP64
472
if (!FLAG_IS_DEFAULT(CICompilerCount) && !FLAG_IS_DEFAULT(CICompilerCountPerCPU) && CICompilerCountPerCPU) {
473
warning("The VM option CICompilerCountPerCPU overrides CICompilerCount.");
474
}
475
#endif
476
477
if (BackgroundCompilation && ReplayCompiles) {
478
if (!FLAG_IS_DEFAULT(BackgroundCompilation)) {
479
warning("BackgroundCompilation disabled due to ReplayCompiles option.");
480
}
481
FLAG_SET_CMDLINE(BackgroundCompilation, false);
482
}
483
484
#ifdef COMPILER2
485
if (PostLoopMultiversioning && !RangeCheckElimination) {
486
if (!FLAG_IS_DEFAULT(PostLoopMultiversioning)) {
487
warning("PostLoopMultiversioning disabled because RangeCheckElimination is disabled.");
488
}
489
FLAG_SET_CMDLINE(PostLoopMultiversioning, false);
490
}
491
#endif // COMPILER2
492
493
if (CompilerConfig::is_interpreter_only()) {
494
if (UseCompiler) {
495
if (!FLAG_IS_DEFAULT(UseCompiler)) {
496
warning("UseCompiler disabled due to -Xint.");
497
}
498
FLAG_SET_CMDLINE(UseCompiler, false);
499
}
500
if (ProfileInterpreter) {
501
if (!FLAG_IS_DEFAULT(ProfileInterpreter)) {
502
warning("ProfileInterpreter disabled due to -Xint.");
503
}
504
FLAG_SET_CMDLINE(ProfileInterpreter, false);
505
}
506
if (TieredCompilation) {
507
if (!FLAG_IS_DEFAULT(TieredCompilation)) {
508
warning("TieredCompilation disabled due to -Xint.");
509
}
510
FLAG_SET_CMDLINE(TieredCompilation, false);
511
}
512
#if INCLUDE_JVMCI
513
if (EnableJVMCI) {
514
if (!FLAG_IS_DEFAULT(EnableJVMCI) || !FLAG_IS_DEFAULT(UseJVMCICompiler)) {
515
warning("JVMCI Compiler disabled due to -Xint.");
516
}
517
FLAG_SET_CMDLINE(EnableJVMCI, false);
518
FLAG_SET_CMDLINE(UseJVMCICompiler, false);
519
}
520
#endif
521
} else {
522
#if INCLUDE_JVMCI
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_COMPILER2
532
return;
533
#endif
534
535
if (has_c1()) {
536
if (!is_compilation_mode_selected()) {
537
#if defined(_WINDOWS) && !defined(_LP64)
538
if (FLAG_IS_DEFAULT(NeverActAsServerClassMachine)) {
539
FLAG_SET_ERGO(NeverActAsServerClassMachine, true);
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_JVMCI
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)) {
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);
566
}
567
}
568
569
if (UseOnStackReplacement && !UseLoopCounter) {
570
warning("On-stack-replacement requires loop counters; enabling loop counters");
571
FLAG_SET_DEFAULT(UseLoopCounter, true);
572
}
573
574
if (ProfileInterpreter && CompilerConfig::is_c1_simple_only()) {
575
if (!FLAG_IS_DEFAULT(ProfileInterpreter)) {
576
warning("ProfileInterpreter disabled due to client emulation mode");
577
}
578
FLAG_SET_CMDLINE(ProfileInterpreter, false);
579
}
580
581
#ifdef COMPILER2
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) && !PrintIdealGraph) {
595
FLAG_SET_ERGO(PrintIdealGraphLevel, -1);
596
}
597
#endif
598
if (!UseTypeSpeculation && FLAG_IS_DEFAULT(TypeProfileLevel)) {
599
// nothing to use the profiling, turn if off
600
FLAG_SET_DEFAULT(TypeProfileLevel, 0);
601
}
602
if (!FLAG_IS_DEFAULT(OptoLoopAlignment) && FLAG_IS_DEFAULT(MaxLoopPad)) {
603
FLAG_SET_DEFAULT(MaxLoopPad, OptoLoopAlignment-1);
604
}
605
if (FLAG_IS_DEFAULT(LoopStripMiningIterShortLoop)) {
606
// blind guess
607
LoopStripMiningIterShortLoop = LoopStripMiningIter / 10;
608
}
609
#endif // COMPILER2
610
}
611
612
613