src/share/vm/runtime/compilationPolicy.cpp

Print this page




 142   bool result = false;
 143   if (comp_level == CompLevel_all) {
 144     if (TieredCompilation) {
 145       // enough to be osr compilable at any level for tiered
 146       result = !m->is_not_osr_compilable(CompLevel_simple) || !m->is_not_osr_compilable(CompLevel_full_optimization);
 147     } else {
 148       // must be osr compilable at available level for non-tiered
 149       result = !m->is_not_osr_compilable(CompLevel_highest_tier);
 150     }
 151   } else if (is_compile(comp_level)) {
 152     result = !m->is_not_osr_compilable(comp_level);
 153   }
 154   return (result && can_be_compiled(m, comp_level));
 155 }
 156 
 157 bool CompilationPolicy::is_compilation_enabled() {
 158   // NOTE: CompileBroker::should_compile_new_jobs() checks for UseCompiler
 159   return !delay_compilation_during_startup() && CompileBroker::should_compile_new_jobs();
 160 }
 161 




















 162 #ifndef PRODUCT
 163 void CompilationPolicy::print_time() {
 164   tty->print_cr ("Accumulated compilationPolicy times:");
 165   tty->print_cr ("---------------------------");
 166   tty->print_cr ("  Total: %3.3f sec.", _accumulated_time.seconds());
 167 }
 168 
 169 void NonTieredCompPolicy::trace_osr_completion(nmethod* osr_nm) {
 170   if (TraceOnStackReplacement) {
 171     if (osr_nm == NULL) tty->print_cr("compilation failed");
 172     else tty->print_cr("nmethod " INTPTR_FORMAT, p2i(osr_nm));
 173   }
 174 }
 175 #endif // !PRODUCT
 176 
 177 void NonTieredCompPolicy::initialize() {
 178   // Setup the compiler thread numbers
 179   if (CICompilerCountPerCPU) {
 180     // Example: if CICompilerCountPerCPU is true, then we get
 181     // max(log2(8)-1,1) = 2 compiler threads on an 8-way machine.


 322 
 323 // This method can be called by any component of the runtime to notify the policy
 324 // that it's recommended to delay the compilation of this method.
 325 void NonTieredCompPolicy::delay_compilation(Method* method) {
 326   MethodCounters* mcs = method->method_counters();
 327   if (mcs != NULL) {
 328     mcs->invocation_counter()->decay();
 329     mcs->backedge_counter()->decay();
 330   }
 331 }
 332 
 333 void NonTieredCompPolicy::disable_compilation(Method* method) {
 334   MethodCounters* mcs = method->method_counters();
 335   if (mcs != NULL) {
 336     mcs->invocation_counter()->set_state(InvocationCounter::wait_for_nothing);
 337     mcs->backedge_counter()->set_state(InvocationCounter::wait_for_nothing);
 338   }
 339 }
 340 
 341 CompileTask* NonTieredCompPolicy::select_task(CompileQueue* compile_queue) {
 342   return compile_queue->first();
 343 }
 344 
 345 bool NonTieredCompPolicy::is_mature(Method* method) {
 346   MethodData* mdo = method->method_data();
 347   assert(mdo != NULL, "Should be");
 348   uint current = mdo->mileage_of(method);
 349   uint initial = mdo->creation_mileage();
 350   if (current < initial)
 351     return true;  // some sort of overflow
 352   uint target;
 353   if (ProfileMaturityPercentage <= 0)
 354     target = (uint) -ProfileMaturityPercentage;  // absolute value
 355   else
 356     target = (uint)( (ProfileMaturityPercentage * CompileThreshold) / 100 );
 357   return (current >= initial + target);
 358 }
 359 
 360 nmethod* NonTieredCompPolicy::event(const methodHandle& method, const methodHandle& inlinee, int branch_bci,
 361                                     int bci, CompLevel comp_level, nmethod* nm, JavaThread* thread) {
 362   assert(comp_level == CompLevel_none, "This should be only called from the interpreter");




 142   bool result = false;
 143   if (comp_level == CompLevel_all) {
 144     if (TieredCompilation) {
 145       // enough to be osr compilable at any level for tiered
 146       result = !m->is_not_osr_compilable(CompLevel_simple) || !m->is_not_osr_compilable(CompLevel_full_optimization);
 147     } else {
 148       // must be osr compilable at available level for non-tiered
 149       result = !m->is_not_osr_compilable(CompLevel_highest_tier);
 150     }
 151   } else if (is_compile(comp_level)) {
 152     result = !m->is_not_osr_compilable(comp_level);
 153   }
 154   return (result && can_be_compiled(m, comp_level));
 155 }
 156 
 157 bool CompilationPolicy::is_compilation_enabled() {
 158   // NOTE: CompileBroker::should_compile_new_jobs() checks for UseCompiler
 159   return !delay_compilation_during_startup() && CompileBroker::should_compile_new_jobs();
 160 }
 161 
 162 CompileTask* CompilationPolicy::select_task_helper(CompileQueue* compile_queue) {
 163 #if INCLUDE_JVMCI
 164   if (UseJVMCICompiler && !BackgroundCompilation) {
 165     /*
 166      * In blocking compilation mode, the CompileBroker will make
 167      * compilations submitted by a JVMCI compiler thread non-blocking. These
 168      * compilations should be scheduled after all blocking compilations
 169      * to service non-compiler related compilations sooner and reduce the
 170      * chance of such compilations timing out.
 171      */
 172     for (CompileTask* task = compile_queue->first(); task != NULL; task = task->next()) {
 173       if (task->is_blocking()) {
 174         return task;
 175       }
 176     }
 177   }
 178 #endif
 179   return compile_queue->first();
 180 }
 181 
 182 #ifndef PRODUCT
 183 void CompilationPolicy::print_time() {
 184   tty->print_cr ("Accumulated compilationPolicy times:");
 185   tty->print_cr ("---------------------------");
 186   tty->print_cr ("  Total: %3.3f sec.", _accumulated_time.seconds());
 187 }
 188 
 189 void NonTieredCompPolicy::trace_osr_completion(nmethod* osr_nm) {
 190   if (TraceOnStackReplacement) {
 191     if (osr_nm == NULL) tty->print_cr("compilation failed");
 192     else tty->print_cr("nmethod " INTPTR_FORMAT, p2i(osr_nm));
 193   }
 194 }
 195 #endif // !PRODUCT
 196 
 197 void NonTieredCompPolicy::initialize() {
 198   // Setup the compiler thread numbers
 199   if (CICompilerCountPerCPU) {
 200     // Example: if CICompilerCountPerCPU is true, then we get
 201     // max(log2(8)-1,1) = 2 compiler threads on an 8-way machine.


 342 
 343 // This method can be called by any component of the runtime to notify the policy
 344 // that it's recommended to delay the compilation of this method.
 345 void NonTieredCompPolicy::delay_compilation(Method* method) {
 346   MethodCounters* mcs = method->method_counters();
 347   if (mcs != NULL) {
 348     mcs->invocation_counter()->decay();
 349     mcs->backedge_counter()->decay();
 350   }
 351 }
 352 
 353 void NonTieredCompPolicy::disable_compilation(Method* method) {
 354   MethodCounters* mcs = method->method_counters();
 355   if (mcs != NULL) {
 356     mcs->invocation_counter()->set_state(InvocationCounter::wait_for_nothing);
 357     mcs->backedge_counter()->set_state(InvocationCounter::wait_for_nothing);
 358   }
 359 }
 360 
 361 CompileTask* NonTieredCompPolicy::select_task(CompileQueue* compile_queue) {
 362   return select_task_helper(compile_queue);
 363 }
 364 
 365 bool NonTieredCompPolicy::is_mature(Method* method) {
 366   MethodData* mdo = method->method_data();
 367   assert(mdo != NULL, "Should be");
 368   uint current = mdo->mileage_of(method);
 369   uint initial = mdo->creation_mileage();
 370   if (current < initial)
 371     return true;  // some sort of overflow
 372   uint target;
 373   if (ProfileMaturityPercentage <= 0)
 374     target = (uint) -ProfileMaturityPercentage;  // absolute value
 375   else
 376     target = (uint)( (ProfileMaturityPercentage * CompileThreshold) / 100 );
 377   return (current >= initial + target);
 378 }
 379 
 380 nmethod* NonTieredCompPolicy::event(const methodHandle& method, const methodHandle& inlinee, int branch_bci,
 381                                     int bci, CompLevel comp_level, nmethod* nm, JavaThread* thread) {
 382   assert(comp_level == CompLevel_none, "This should be only called from the interpreter");