1 /*
   2  * Copyright (c) 2016, 2019, 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/globals.hpp"
  28 #include "runtime/globals_extension.hpp"
  29 #include "compiler/compilerDefinitions.hpp"
  30 #include "gc/shared/gcConfig.hpp"
  31 #include "utilities/defaultStream.hpp"
  32 
  33 const char* compilertype2name_tab[compiler_number_of_types] = {
  34   "",
  35   "c1",
  36   "c2",
  37   "jvmci"
  38 };
  39 
  40 #ifdef TIERED
  41 bool CompilationModeFlag::_quick_only = false;
  42 bool CompilationModeFlag::_high_only = false;
  43 bool CompilationModeFlag::_high_only_quick_internal = false;
  44 
  45 
  46 bool CompilationModeFlag::initialize() {
  47   if (CompilationMode != NULL) {
  48     if (strcmp(CompilationMode, "default") == 0) {
  49       // Do nothing, just support the "default" keyword.
  50     } else if (strcmp(CompilationMode, "quick-only") == 0) {
  51       _quick_only = true;
  52     } else if (strcmp(CompilationMode, "high-only") == 0) {
  53       _high_only = true;
  54     } else if (strcmp(CompilationMode, "high-only-quick-internal") == 0) {
  55       _high_only_quick_internal = true;
  56     } else {
  57       jio_fprintf(defaultStream::error_stream(), "Unsupported compilation mode '%s', supported modes are: quick-only, high-only, high-only-quick-internal\n", CompilationMode);
  58       return false;
  59     }
  60     if (disable_intermediate()) {
  61       CompLevel_initial_compile = CompLevel_full_optimization;
  62     }
  63   }
  64   return true;
  65 }
  66 
  67 #endif
  68 
  69 #if defined(COMPILER2)
  70 CompLevel  CompLevel_highest_tier      = CompLevel_full_optimization;  // pure C2 and tiered or JVMCI and tiered
  71 #elif defined(COMPILER1)
  72 CompLevel  CompLevel_highest_tier      = CompLevel_simple;             // pure C1 or JVMCI
  73 #else
  74 CompLevel  CompLevel_highest_tier      = CompLevel_none;
  75 #endif
  76 
  77 #if defined(TIERED)
  78 CompLevel  CompLevel_initial_compile   = CompLevel_full_profile;        // tiered
  79 #elif defined(COMPILER1) || INCLUDE_JVMCI
  80 CompLevel  CompLevel_initial_compile   = CompLevel_simple;              // pure C1 or JVMCI
  81 #elif defined(COMPILER2)
  82 CompLevel  CompLevel_initial_compile   = CompLevel_full_optimization;   // pure C2
  83 #else
  84 CompLevel  CompLevel_initial_compile   = CompLevel_none;
  85 #endif
  86 
  87 #if defined(COMPILER2)
  88 CompMode  Compilation_mode             = CompMode_server;
  89 #elif defined(COMPILER1)
  90 CompMode  Compilation_mode             = CompMode_client;
  91 #else
  92 CompMode  Compilation_mode             = CompMode_none;
  93 #endif
  94 
  95 // Returns threshold scaled with CompileThresholdScaling
  96 intx CompilerConfig::scaled_compile_threshold(intx threshold) {
  97   return scaled_compile_threshold(threshold, CompileThresholdScaling);
  98 }
  99 
 100 // Returns freq_log scaled with CompileThresholdScaling
 101 intx CompilerConfig::scaled_freq_log(intx freq_log) {
 102   return scaled_freq_log(freq_log, CompileThresholdScaling);
 103 }
 104 
 105 // Returns threshold scaled with the value of scale.
 106 // If scale < 0.0, threshold is returned without scaling.
 107 intx CompilerConfig::scaled_compile_threshold(intx threshold, double scale) {
 108   if (scale == 1.0 || scale < 0.0) {
 109     return threshold;
 110   } else {
 111     return (intx)(threshold * scale);
 112   }
 113 }
 114 
 115 // Returns freq_log scaled with the value of scale.
 116 // Returned values are in the range of [0, InvocationCounter::number_of_count_bits + 1].
 117 // If scale < 0.0, freq_log is returned without scaling.
 118 intx CompilerConfig::scaled_freq_log(intx freq_log, double scale) {
 119   // Check if scaling is necessary or if negative value was specified.
 120   if (scale == 1.0 || scale < 0.0) {
 121     return freq_log;
 122   }
 123   // Check values to avoid calculating log2 of 0.
 124   if (scale == 0.0 || freq_log == 0) {
 125     return 0;
 126   }
 127   // Determine the maximum notification frequency value currently supported.
 128   // The largest mask value that the interpreter/C1 can handle is
 129   // of length InvocationCounter::number_of_count_bits. Mask values are always
 130   // one bit shorter then the value of the notification frequency. Set
 131   // max_freq_bits accordingly.
 132   intx max_freq_bits = InvocationCounter::number_of_count_bits + 1;
 133   intx scaled_freq = scaled_compile_threshold((intx)1 << freq_log, scale);
 134   if (scaled_freq == 0) {
 135     // Return 0 right away to avoid calculating log2 of 0.
 136     return 0;
 137   } else if (scaled_freq > nth_bit(max_freq_bits)) {
 138     return max_freq_bits;
 139   } else {
 140     return log2_intptr(scaled_freq);
 141   }
 142 }
 143 
 144 #ifdef TIERED
 145 void set_client_compilation_mode() {
 146   Compilation_mode = CompMode_client;
 147   CompLevel_highest_tier = CompLevel_simple;
 148   CompLevel_initial_compile = CompLevel_simple;
 149   FLAG_SET_ERGO(TieredCompilation, false);
 150   FLAG_SET_ERGO(ProfileInterpreter, false);
 151 #if INCLUDE_JVMCI
 152   FLAG_SET_ERGO(EnableJVMCI, false);
 153   FLAG_SET_ERGO(UseJVMCICompiler, false);
 154 #endif
 155 #if INCLUDE_AOT
 156   FLAG_SET_ERGO(UseAOT, false);
 157 #endif
 158   if (FLAG_IS_DEFAULT(NeverActAsServerClassMachine)) {
 159     FLAG_SET_ERGO(NeverActAsServerClassMachine, true);
 160   }
 161   if (FLAG_IS_DEFAULT(InitialCodeCacheSize)) {
 162     FLAG_SET_ERGO(InitialCodeCacheSize, 160*K);
 163   }
 164   if (FLAG_IS_DEFAULT(ReservedCodeCacheSize)) {
 165     FLAG_SET_ERGO(ReservedCodeCacheSize, 32*M);
 166   }
 167   if (FLAG_IS_DEFAULT(NonProfiledCodeHeapSize)) {
 168     FLAG_SET_ERGO(NonProfiledCodeHeapSize, 27*M);
 169   }
 170   if (FLAG_IS_DEFAULT(ProfiledCodeHeapSize)) {
 171     FLAG_SET_ERGO(ProfiledCodeHeapSize, 0);
 172   }
 173   if (FLAG_IS_DEFAULT(NonNMethodCodeHeapSize)) {
 174     FLAG_SET_ERGO(NonNMethodCodeHeapSize, 5*M);
 175   }
 176   if (FLAG_IS_DEFAULT(CodeCacheExpansionSize)) {
 177     FLAG_SET_ERGO(CodeCacheExpansionSize, 32*K);
 178   }
 179   if (FLAG_IS_DEFAULT(MetaspaceSize)) {
 180     FLAG_SET_ERGO(MetaspaceSize, MIN2(12*M, MaxMetaspaceSize));
 181   }
 182   if (FLAG_IS_DEFAULT(MaxRAM)) {
 183     // Do not use FLAG_SET_ERGO to update MaxRAM, as this will impact
 184     // heap setting done based on available phys_mem (see Arguments::set_heap_size).
 185     FLAG_SET_DEFAULT(MaxRAM, 1ULL*G);
 186   }
 187   if (FLAG_IS_DEFAULT(CompileThreshold)) {
 188     FLAG_SET_ERGO(CompileThreshold, 1500);
 189   }
 190   if (FLAG_IS_DEFAULT(OnStackReplacePercentage)) {
 191     FLAG_SET_ERGO(OnStackReplacePercentage, 933);
 192   }
 193   if (FLAG_IS_DEFAULT(CICompilerCount)) {
 194     FLAG_SET_ERGO(CICompilerCount, 1);
 195   }
 196 }
 197 
 198 bool compilation_mode_selected() {
 199   return !FLAG_IS_DEFAULT(TieredCompilation) ||
 200          !FLAG_IS_DEFAULT(TieredStopAtLevel) ||
 201          !FLAG_IS_DEFAULT(UseAOT)
 202          JVMCI_ONLY(|| !FLAG_IS_DEFAULT(EnableJVMCI)
 203                     || !FLAG_IS_DEFAULT(UseJVMCICompiler));
 204 }
 205 
 206 void select_compilation_mode_ergonomically() {
 207 #if defined(_WINDOWS) && !defined(_LP64)
 208   if (FLAG_IS_DEFAULT(NeverActAsServerClassMachine)) {
 209     FLAG_SET_ERGO(NeverActAsServerClassMachine, true);
 210   }
 211 #endif
 212   if (NeverActAsServerClassMachine) {
 213     set_client_compilation_mode();
 214   }
 215 }
 216 
 217 
 218 void CompilerConfig::set_tiered_flags() {
 219   // Increase the code cache size - tiered compiles a lot more.
 220   if (FLAG_IS_DEFAULT(ReservedCodeCacheSize)) {
 221     FLAG_SET_ERGO(ReservedCodeCacheSize,
 222                   MIN2(CODE_CACHE_DEFAULT_LIMIT, (size_t)ReservedCodeCacheSize * 5));
 223   }
 224   // Enable SegmentedCodeCache if TieredCompilation is enabled, ReservedCodeCacheSize >= 240M
 225   // and the code cache contains at least 8 pages (segmentation disables advantage of huge pages).
 226   if (FLAG_IS_DEFAULT(SegmentedCodeCache) && ReservedCodeCacheSize >= 240*M &&
 227       8 * CodeCache::page_size() <= ReservedCodeCacheSize) {
 228     FLAG_SET_ERGO(SegmentedCodeCache, true);
 229   }
 230   if (!UseInterpreter) { // -Xcomp
 231     Tier3InvokeNotifyFreqLog = 0;
 232     Tier4InvocationThreshold = 0;
 233   }
 234 
 235   if (CompileThresholdScaling < 0) {
 236     vm_exit_during_initialization("Negative value specified for CompileThresholdScaling", NULL);
 237   }
 238 
 239   if (CompilationModeFlag::disable_intermediate()) {
 240     if (FLAG_IS_DEFAULT(Tier0ProfilingStartPercentage)) {
 241       FLAG_SET_DEFAULT(Tier0ProfilingStartPercentage, 33);
 242     }
 243   }
 244 
 245   // Scale tiered compilation thresholds.
 246   // CompileThresholdScaling == 0.0 is equivalent to -Xint and leaves compilation thresholds unchanged.
 247   if (!FLAG_IS_DEFAULT(CompileThresholdScaling) && CompileThresholdScaling > 0.0) {
 248     FLAG_SET_ERGO(Tier0InvokeNotifyFreqLog, scaled_freq_log(Tier0InvokeNotifyFreqLog));
 249     FLAG_SET_ERGO(Tier0BackedgeNotifyFreqLog, scaled_freq_log(Tier0BackedgeNotifyFreqLog));
 250 
 251     FLAG_SET_ERGO(Tier3InvocationThreshold, scaled_compile_threshold(Tier3InvocationThreshold));
 252     FLAG_SET_ERGO(Tier3MinInvocationThreshold, scaled_compile_threshold(Tier3MinInvocationThreshold));
 253     FLAG_SET_ERGO(Tier3CompileThreshold, scaled_compile_threshold(Tier3CompileThreshold));
 254     FLAG_SET_ERGO(Tier3BackEdgeThreshold, scaled_compile_threshold(Tier3BackEdgeThreshold));
 255 
 256     // Tier2{Invocation,MinInvocation,Compile,Backedge}Threshold should be scaled here
 257     // once these thresholds become supported.
 258 
 259     FLAG_SET_ERGO(Tier2InvokeNotifyFreqLog, scaled_freq_log(Tier2InvokeNotifyFreqLog));
 260     FLAG_SET_ERGO(Tier2BackedgeNotifyFreqLog, scaled_freq_log(Tier2BackedgeNotifyFreqLog));
 261 
 262     FLAG_SET_ERGO(Tier3InvokeNotifyFreqLog, scaled_freq_log(Tier3InvokeNotifyFreqLog));
 263     FLAG_SET_ERGO(Tier3BackedgeNotifyFreqLog, scaled_freq_log(Tier3BackedgeNotifyFreqLog));
 264 
 265     FLAG_SET_ERGO(Tier23InlineeNotifyFreqLog, scaled_freq_log(Tier23InlineeNotifyFreqLog));
 266 
 267     FLAG_SET_ERGO(Tier4InvocationThreshold, scaled_compile_threshold(Tier4InvocationThreshold));
 268     FLAG_SET_ERGO(Tier4MinInvocationThreshold, scaled_compile_threshold(Tier4MinInvocationThreshold));
 269     FLAG_SET_ERGO(Tier4CompileThreshold, scaled_compile_threshold(Tier4CompileThreshold));
 270     FLAG_SET_ERGO(Tier4BackEdgeThreshold, scaled_compile_threshold(Tier4BackEdgeThreshold));
 271 
 272     if (CompilationModeFlag::disable_intermediate()) {
 273       FLAG_SET_ERGO(Tier40InvocationThreshold, scaled_compile_threshold(Tier40InvocationThreshold));
 274       FLAG_SET_ERGO(Tier40MinInvocationThreshold, scaled_compile_threshold(Tier40MinInvocationThreshold));
 275       FLAG_SET_ERGO(Tier40CompileThreshold, scaled_compile_threshold(Tier40CompileThreshold));
 276       FLAG_SET_ERGO(Tier40BackEdgeThreshold, scaled_compile_threshold(Tier40BackEdgeThreshold));
 277     }
 278 
 279 #if INCLUDE_AOT
 280     if (UseAOT) {
 281       FLAG_SET_ERGO(Tier3AOTInvocationThreshold, scaled_compile_threshold(Tier3AOTInvocationThreshold));
 282       FLAG_SET_ERGO(Tier3AOTMinInvocationThreshold, scaled_compile_threshold(Tier3AOTMinInvocationThreshold));
 283       FLAG_SET_ERGO(Tier3AOTCompileThreshold, scaled_compile_threshold(Tier3AOTCompileThreshold));
 284       FLAG_SET_ERGO(Tier3AOTBackEdgeThreshold, scaled_compile_threshold(Tier3AOTBackEdgeThreshold));
 285 
 286       if (CompilationModeFlag::disable_intermediate()) {
 287         FLAG_SET_ERGO(Tier0AOTInvocationThreshold, scaled_compile_threshold(Tier0AOTInvocationThreshold));
 288         FLAG_SET_ERGO(Tier0AOTMinInvocationThreshold, scaled_compile_threshold(Tier0AOTMinInvocationThreshold));
 289         FLAG_SET_ERGO(Tier0AOTCompileThreshold, scaled_compile_threshold(Tier0AOTCompileThreshold));
 290         FLAG_SET_ERGO(Tier0AOTBackEdgeThreshold, scaled_compile_threshold(Tier0AOTBackEdgeThreshold));
 291       }
 292     }
 293 #endif // INCLUDE_AOT
 294   }
 295 }
 296 
 297 #endif // TIERED
 298 
 299 #if INCLUDE_JVMCI
 300 void set_jvmci_specific_flags() {
 301   if (UseJVMCICompiler) {
 302     Compilation_mode = CompMode_server;
 303 
 304     if (FLAG_IS_DEFAULT(TypeProfileWidth)) {
 305       FLAG_SET_DEFAULT(TypeProfileWidth, 8);
 306     }
 307     if (FLAG_IS_DEFAULT(TypeProfileLevel)) {
 308       FLAG_SET_DEFAULT(TypeProfileLevel, 0);
 309     }
 310 
 311     if (UseJVMCINativeLibrary) {
 312       // SVM compiled code requires more stack space
 313       if (FLAG_IS_DEFAULT(CompilerThreadStackSize)) {
 314         // Duplicate logic in the implementations of os::create_thread
 315         // so that we can then double the computed stack size. Once
 316         // the stack size requirements of SVM are better understood,
 317         // this logic can be pushed down into os::create_thread.
 318         int stack_size = CompilerThreadStackSize;
 319         if (stack_size == 0) {
 320           stack_size = VMThreadStackSize;
 321         }
 322         if (stack_size != 0) {
 323           FLAG_SET_DEFAULT(CompilerThreadStackSize, stack_size * 2);
 324         }
 325       }
 326     } else {
 327 #ifdef TIERED
 328       if (!TieredCompilation) {
 329          warning("Disabling tiered compilation with non-native JVMCI compiler is not recommended. "
 330                  "Turning on tiered compilation and disabling intermediate compilation levels instead. ");
 331          FLAG_SET_ERGO(TieredCompilation, true);
 332          if (CompilationModeFlag::normal()) {
 333            CompilationModeFlag::set_high_only_quick_internal(true);
 334          }
 335          if (CICompilerCount < 2 && CompilationModeFlag::quick_internal()) {
 336             warning("Increasing number of compiler threads for JVMCI compiler.");
 337             FLAG_SET_ERGO(CICompilerCount, 2);
 338          }
 339       }
 340 #else // TIERED
 341       // Adjust the on stack replacement percentage to avoid early
 342       // OSR compilations while JVMCI itself is warming up
 343       if (FLAG_IS_DEFAULT(OnStackReplacePercentage)) {
 344         FLAG_SET_DEFAULT(OnStackReplacePercentage, 933);
 345       }
 346 #endif // !TIERED
 347       // JVMCI needs values not less than defaults
 348       if (FLAG_IS_DEFAULT(ReservedCodeCacheSize)) {
 349         FLAG_SET_DEFAULT(ReservedCodeCacheSize, MAX2(64*M, ReservedCodeCacheSize));
 350       }
 351       if (FLAG_IS_DEFAULT(InitialCodeCacheSize)) {
 352         FLAG_SET_DEFAULT(InitialCodeCacheSize, MAX2(16*M, InitialCodeCacheSize));
 353       }
 354       if (FLAG_IS_DEFAULT(MetaspaceSize)) {
 355         FLAG_SET_DEFAULT(MetaspaceSize, clamp(MetaspaceSize, 12*M, MaxMetaspaceSize));
 356       }
 357       if (FLAG_IS_DEFAULT(NewSizeThreadIncrease)) {
 358         FLAG_SET_DEFAULT(NewSizeThreadIncrease, MAX2(4*K, NewSizeThreadIncrease));
 359       }
 360     } // !UseJVMCINativeLibrary
 361   } // UseJVMCICompiler
 362 }
 363 #endif // INCLUDE_JVMCI
 364 
 365 bool CompilerConfig::check_args_consistency(bool status) {
 366   // Check lower bounds of the code cache
 367   // Template Interpreter code is approximately 3X larger in debug builds.
 368   uint min_code_cache_size = CodeCacheMinimumUseSpace DEBUG_ONLY(* 3);
 369   if (ReservedCodeCacheSize < InitialCodeCacheSize) {
 370     jio_fprintf(defaultStream::error_stream(),
 371                 "Invalid ReservedCodeCacheSize: %dK. Must be at least InitialCodeCacheSize=%dK.\n",
 372                 ReservedCodeCacheSize/K, InitialCodeCacheSize/K);
 373     status = false;
 374   } else if (ReservedCodeCacheSize < min_code_cache_size) {
 375     jio_fprintf(defaultStream::error_stream(),
 376                 "Invalid ReservedCodeCacheSize=%dK. Must be at least %uK.\n", ReservedCodeCacheSize/K,
 377                 min_code_cache_size/K);
 378     status = false;
 379   } else if (ReservedCodeCacheSize > CODE_CACHE_SIZE_LIMIT) {
 380     // Code cache size larger than CODE_CACHE_SIZE_LIMIT is not supported.
 381     jio_fprintf(defaultStream::error_stream(),
 382                 "Invalid ReservedCodeCacheSize=%dM. Must be at most %uM.\n", ReservedCodeCacheSize/M,
 383                 CODE_CACHE_SIZE_LIMIT/M);
 384     status = false;
 385   } else if (NonNMethodCodeHeapSize < min_code_cache_size) {
 386     jio_fprintf(defaultStream::error_stream(),
 387                 "Invalid NonNMethodCodeHeapSize=%dK. Must be at least %uK.\n", NonNMethodCodeHeapSize/K,
 388                 min_code_cache_size/K);
 389     status = false;
 390   }
 391 
 392 #ifdef _LP64
 393   if (!FLAG_IS_DEFAULT(CICompilerCount) && !FLAG_IS_DEFAULT(CICompilerCountPerCPU) && CICompilerCountPerCPU) {
 394     warning("The VM option CICompilerCountPerCPU overrides CICompilerCount.");
 395   }
 396 #endif
 397 
 398   if (BackgroundCompilation && ReplayCompiles) {
 399     if (!FLAG_IS_DEFAULT(BackgroundCompilation)) {
 400       warning("BackgroundCompilation disabled due to ReplayCompiles option.");
 401     }
 402     FLAG_SET_CMDLINE(BackgroundCompilation, false);
 403   }
 404 
 405 #ifdef COMPILER2
 406   if (PostLoopMultiversioning && !RangeCheckElimination) {
 407     if (!FLAG_IS_DEFAULT(PostLoopMultiversioning)) {
 408       warning("PostLoopMultiversioning disabled because RangeCheckElimination is disabled.");
 409     }
 410     FLAG_SET_CMDLINE(PostLoopMultiversioning, false);
 411   }
 412   if (UseCountedLoopSafepoints && LoopStripMiningIter == 0) {
 413     if (!FLAG_IS_DEFAULT(UseCountedLoopSafepoints) || !FLAG_IS_DEFAULT(LoopStripMiningIter)) {
 414       warning("When counted loop safepoints are enabled, LoopStripMiningIter must be at least 1 (a safepoint every 1 iteration): setting it to 1");
 415     }
 416     LoopStripMiningIter = 1;
 417   } else if (!UseCountedLoopSafepoints && LoopStripMiningIter > 0) {
 418     if (!FLAG_IS_DEFAULT(UseCountedLoopSafepoints) || !FLAG_IS_DEFAULT(LoopStripMiningIter)) {
 419       warning("Disabling counted safepoints implies no loop strip mining: setting LoopStripMiningIter to 0");
 420     }
 421     LoopStripMiningIter = 0;
 422   }
 423 #endif // COMPILER2
 424 
 425   if (Arguments::is_interpreter_only()) {
 426     if (UseCompiler) {
 427       if (!FLAG_IS_DEFAULT(UseCompiler)) {
 428         warning("UseCompiler disabled due to -Xint.");
 429       }
 430       FLAG_SET_CMDLINE(UseCompiler, false);
 431     }
 432     if (ProfileInterpreter) {
 433       if (!FLAG_IS_DEFAULT(ProfileInterpreter)) {
 434         warning("ProfileInterpreter disabled due to -Xint.");
 435       }
 436       FLAG_SET_CMDLINE(ProfileInterpreter, false);
 437     }
 438     if (TieredCompilation) {
 439       if (!FLAG_IS_DEFAULT(TieredCompilation)) {
 440         warning("TieredCompilation disabled due to -Xint.");
 441       }
 442       FLAG_SET_CMDLINE(TieredCompilation, false);
 443     }
 444 #if INCLUDE_JVMCI
 445     if (EnableJVMCI) {
 446       if (!FLAG_IS_DEFAULT(EnableJVMCI) || !FLAG_IS_DEFAULT(UseJVMCICompiler)) {
 447         warning("JVMCI Compiler disabled due to -Xint.");
 448       }
 449       FLAG_SET_CMDLINE(EnableJVMCI, false);
 450       FLAG_SET_CMDLINE(UseJVMCICompiler, false);
 451     }
 452 #endif
 453   } else {
 454 #if INCLUDE_JVMCI
 455     status = status && JVMCIGlobals::check_jvmci_flags_are_consistent();
 456 #endif
 457   }
 458   return status;
 459 }
 460 
 461 void CompilerConfig::ergo_initialize() {
 462   if (Arguments::is_interpreter_only()) {
 463     return; // Nothing to do.
 464   }
 465 
 466 #ifdef TIERED
 467   if (!compilation_mode_selected()) {
 468     select_compilation_mode_ergonomically();
 469   }
 470 #endif
 471 
 472 #if INCLUDE_JVMCI
 473   // Check that JVMCI compiler supports selested GC.
 474   // Should be done after GCConfig::initialize() was called.
 475   JVMCIGlobals::check_jvmci_supported_gc();
 476 
 477   // Do JVMCI specific settings
 478   set_jvmci_specific_flags();
 479 #endif
 480 
 481 #ifdef TIERED
 482   if (TieredCompilation) {
 483     set_tiered_flags();
 484   } else
 485 #endif
 486   {
 487     // Scale CompileThreshold
 488     // CompileThresholdScaling == 0.0 is equivalent to -Xint and leaves CompileThreshold unchanged.
 489     if (!FLAG_IS_DEFAULT(CompileThresholdScaling) && CompileThresholdScaling > 0.0) {
 490       FLAG_SET_ERGO(CompileThreshold, scaled_compile_threshold(CompileThreshold));
 491     }
 492   }
 493 
 494   if (UseOnStackReplacement && !UseLoopCounter) {
 495     warning("On-stack-replacement requires loop counters; enabling loop counters");
 496     FLAG_SET_DEFAULT(UseLoopCounter, true);
 497   }
 498 
 499 #ifdef COMPILER2
 500   if (!EliminateLocks) {
 501     EliminateNestedLocks = false;
 502   }
 503   if (!Inline) {
 504     IncrementalInline = false;
 505   }
 506 #ifndef PRODUCT
 507   if (!IncrementalInline) {
 508     AlwaysIncrementalInline = false;
 509   }
 510   if (PrintIdealGraphLevel > 0) {
 511     FLAG_SET_ERGO(PrintIdealGraph, true);
 512   }
 513 #endif
 514   if (!UseTypeSpeculation && FLAG_IS_DEFAULT(TypeProfileLevel)) {
 515     // nothing to use the profiling, turn if off
 516     FLAG_SET_DEFAULT(TypeProfileLevel, 0);
 517   }
 518   if (!FLAG_IS_DEFAULT(OptoLoopAlignment) && FLAG_IS_DEFAULT(MaxLoopPad)) {
 519     FLAG_SET_DEFAULT(MaxLoopPad, OptoLoopAlignment-1);
 520   }
 521   if (FLAG_IS_DEFAULT(LoopStripMiningIterShortLoop)) {
 522     // blind guess
 523     LoopStripMiningIterShortLoop = LoopStripMiningIter / 10;
 524   }
 525 #endif // COMPILER2
 526 }