src/hotspot/share/runtime/tieredThresholdPolicy.cpp
changeset 52325 0451e0a2f1f5
parent 51369 f32e61253792
child 52675 7d3cde494494
equal deleted inserted replaced
52324:0c5fc2063221 52325:0451e0a2f1f5
    35 #if INCLUDE_JVMCI
    35 #if INCLUDE_JVMCI
    36 #include "jvmci/jvmciRuntime.hpp"
    36 #include "jvmci/jvmciRuntime.hpp"
    37 #endif
    37 #endif
    38 
    38 
    39 #ifdef TIERED
    39 #ifdef TIERED
       
    40 
       
    41 #include "c1/c1_Compiler.hpp"
       
    42 #include "opto/c2compiler.hpp"
    40 
    43 
    41 template<CompLevel level>
    44 template<CompLevel level>
    42 bool TieredThresholdPolicy::call_predicate_helper(int i, int b, double scale, Method* method) {
    45 bool TieredThresholdPolicy::call_predicate_helper(int i, int b, double scale, Method* method) {
    43   double threshold_scaling;
    46   double threshold_scaling;
    44   if (CompilerOracle::has_option_value(method, "CompileThresholdScaling", threshold_scaling)) {
    47   if (CompilerOracle::has_option_value(method, "CompileThresholdScaling", threshold_scaling)) {
   213   tty->print_cr("]");
   216   tty->print_cr("]");
   214 }
   217 }
   215 
   218 
   216 void TieredThresholdPolicy::initialize() {
   219 void TieredThresholdPolicy::initialize() {
   217   int count = CICompilerCount;
   220   int count = CICompilerCount;
       
   221   bool c1_only = TieredStopAtLevel < CompLevel_full_optimization;
   218 #ifdef _LP64
   222 #ifdef _LP64
   219   // Turn on ergonomic compiler count selection
   223   // Turn on ergonomic compiler count selection
   220   if (FLAG_IS_DEFAULT(CICompilerCountPerCPU) && FLAG_IS_DEFAULT(CICompilerCount)) {
   224   if (FLAG_IS_DEFAULT(CICompilerCountPerCPU) && FLAG_IS_DEFAULT(CICompilerCount)) {
   221     FLAG_SET_DEFAULT(CICompilerCountPerCPU, true);
   225     FLAG_SET_DEFAULT(CICompilerCountPerCPU, true);
   222   }
   226   }
   223   if (CICompilerCountPerCPU) {
   227   if (CICompilerCountPerCPU) {
   224     // Simple log n seems to grow too slowly for tiered, try something faster: log n * log log n
   228     // Simple log n seems to grow too slowly for tiered, try something faster: log n * log log n
   225     int log_cpu = log2_intptr(os::active_processor_count());
   229     int log_cpu = log2_intptr(os::active_processor_count());
   226     int loglog_cpu = log2_intptr(MAX2(log_cpu, 1));
   230     int loglog_cpu = log2_intptr(MAX2(log_cpu, 1));
   227     count = MAX2(log_cpu * loglog_cpu * 3 / 2, 2);
   231     count = MAX2(log_cpu * loglog_cpu * 3 / 2, 2);
       
   232     // Make sure there is enough space in the code cache to hold all the compiler buffers
       
   233     size_t c1_size = Compiler::code_buffer_size();
       
   234     size_t c2_size = C2Compiler::initial_code_buffer_size();
       
   235     size_t buffer_size = c1_only ? c1_size : (c1_size/3 + 2*c2_size/3);
       
   236     int max_count = (ReservedCodeCacheSize - (CodeCacheMinimumUseSpace DEBUG_ONLY(* 3))) / (int)buffer_size;
       
   237     if (count > max_count) {
       
   238       // Lower the compiler count such that all buffers fit into the code cache
       
   239       count = MAX2(max_count, c1_only ? 1 : 2);
       
   240     }
   228     FLAG_SET_ERGO(intx, CICompilerCount, count);
   241     FLAG_SET_ERGO(intx, CICompilerCount, count);
   229   }
   242   }
   230 #else
   243 #else
   231   // On 32-bit systems, the number of compiler threads is limited to 3.
   244   // On 32-bit systems, the number of compiler threads is limited to 3.
   232   // On these systems, the virtual address space available to the JVM
   245   // On these systems, the virtual address space available to the JVM
   239     count = 3;
   252     count = 3;
   240     FLAG_SET_ERGO(intx, CICompilerCount, count);
   253     FLAG_SET_ERGO(intx, CICompilerCount, count);
   241   }
   254   }
   242 #endif
   255 #endif
   243 
   256 
   244   if (TieredStopAtLevel < CompLevel_full_optimization) {
   257   if (c1_only) {
   245     // No C2 compiler thread required
   258     // No C2 compiler thread required
   246     set_c1_count(count);
   259     set_c1_count(count);
   247   } else {
   260   } else {
   248     set_c1_count(MAX2(count / 3, 1));
   261     set_c1_count(MAX2(count / 3, 1));
   249     set_c2_count(MAX2(count - c1_count(), 1));
   262     set_c2_count(MAX2(count - c1_count(), 1));