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