< prev index next >

src/hotspot/share/runtime/tieredThresholdPolicy.cpp

Print this page




 395   if (ReplayCompiles) {
 396     // Don't trigger other compiles in testing mode
 397     return NULL;
 398   }
 399 
 400   handle_counter_overflow(method());
 401   if (method() != inlinee()) {
 402     handle_counter_overflow(inlinee());
 403   }
 404 
 405   if (PrintTieredEvents) {
 406     print_event(bci == InvocationEntryBci ? CALL : LOOP, method, inlinee, bci, comp_level);
 407   }
 408 
 409   if (bci == InvocationEntryBci) {
 410     method_invocation_event(method, inlinee, comp_level, nm, thread);
 411   } else {
 412     // method == inlinee if the event originated in the main method
 413     method_back_branch_event(method, inlinee, bci, comp_level, nm, thread);
 414     // Check if event led to a higher level OSR compilation
 415     CompLevel expected_comp_level = comp_level;
 416     if (inlinee->is_not_osr_compilable(expected_comp_level)) {
 417       // It's not possble to reach the expected level so fall back to simple.
 418       expected_comp_level = CompLevel_simple;
 419     }
 420     nmethod* osr_nm = inlinee->lookup_osr_nmethod_for(bci, expected_comp_level, false);
 421     assert(osr_nm == NULL || osr_nm->comp_level() >= expected_comp_level, "lookup_osr_nmethod_for is broken");
 422     if (osr_nm != NULL) {
 423       // Perform OSR with new nmethod
 424       return osr_nm;
 425     }
 426   }
 427   return NULL;
 428 }
 429 
 430 // Check if the method can be compiled, change level if necessary
 431 void TieredThresholdPolicy::compile(const methodHandle& mh, int bci, CompLevel level, JavaThread* thread) {
 432   assert(level <= TieredStopAtLevel, "Invalid compilation level");
 433   if (level == CompLevel_none) {
 434     return;
 435   }
 436   if (level == CompLevel_aot) {
 437     if (mh->has_aot_code()) {
 438       if (PrintTieredEvents) {
 439         print_event(COMPILE, mh, mh, bci, level);
 440       }
 441       MutexLocker ml(Compile_lock);
 442       NoSafepointVerifier nsv;
 443       if (mh->has_aot_code() && mh->code() != mh->aot_code()) {
 444         mh->aot_code()->make_entrant();
 445         if (mh->has_compiled_code()) {
 446           mh->code()->make_not_entrant();
 447         }
 448         Method::set_code(mh, mh->aot_code());
 449       }
 450     }
 451     return;
 452   }
 453 
 454   // Check if the method can be compiled. If it cannot be compiled with C1, continue profiling
 455   // in the interpreter and then compile with C2 (the transition function will request that,
 456   // see common() ). If the method cannot be compiled with C2 but still can with C1, compile it with
 457   // pure C1.
 458   if ((bci == InvocationEntryBci && !can_be_compiled(mh, level))) {
 459     if (level == CompLevel_full_optimization && can_be_compiled(mh, CompLevel_simple)) {
 460       compile(mh, bci, CompLevel_simple, thread);
 461     }
 462     return;
 463   }
 464   if ((bci != InvocationEntryBci && !can_be_osr_compiled(mh, level))) {
 465     if (level == CompLevel_full_optimization && can_be_osr_compiled(mh, CompLevel_simple)) {
 466       nmethod* osr_nm = mh->lookup_osr_nmethod_for(bci, CompLevel_simple, false);
 467       if (osr_nm != NULL && osr_nm->comp_level() > CompLevel_simple) {
 468         // Invalidate the existing OSR nmethod so that a compile at CompLevel_simple is permitted.
 469         osr_nm->make_not_entrant();
 470       }
 471       compile(mh, bci, CompLevel_simple, thread);
 472     }
 473     return;
 474   }
 475   if (bci != InvocationEntryBci && mh->is_not_osr_compilable(level)) {
 476     return;
 477   }
 478   if (!CompileBroker::compilation_is_in_queue(mh)) {
 479     if (PrintTieredEvents) {
 480       print_event(COMPILE, mh, mh, bci, level);
 481     }
 482     submit_compile(mh, bci, level, thread);
 483   }
 484 }
 485 
 486 // Update the rate and submit compile
 487 void TieredThresholdPolicy::submit_compile(const methodHandle& mh, int bci, CompLevel level, JavaThread* thread) {
 488   int hot_count = (bci == InvocationEntryBci) ? mh->invocation_count() : mh->backedge_count();
 489   update_rate(os::javaTimeMillis(), mh());
 490   CompileBroker::compile_method(mh, bci, level, mh, hot_count, CompileTask::Reason_Tiered, thread);
 491 }




 395   if (ReplayCompiles) {
 396     // Don't trigger other compiles in testing mode
 397     return NULL;
 398   }
 399 
 400   handle_counter_overflow(method());
 401   if (method() != inlinee()) {
 402     handle_counter_overflow(inlinee());
 403   }
 404 
 405   if (PrintTieredEvents) {
 406     print_event(bci == InvocationEntryBci ? CALL : LOOP, method, inlinee, bci, comp_level);
 407   }
 408 
 409   if (bci == InvocationEntryBci) {
 410     method_invocation_event(method, inlinee, comp_level, nm, thread);
 411   } else {
 412     // method == inlinee if the event originated in the main method
 413     method_back_branch_event(method, inlinee, bci, comp_level, nm, thread);
 414     // Check if event led to a higher level OSR compilation
 415     nmethod* osr_nm = inlinee->lookup_osr_nmethod_for(bci, comp_level, false);
 416     if (osr_nm != NULL && osr_nm->comp_level() > comp_level) {






 417       // Perform OSR with new nmethod
 418       return osr_nm;
 419     }
 420   }
 421   return NULL;
 422 }
 423 
 424 // Check if the method can be compiled, change level if necessary
 425 void TieredThresholdPolicy::compile(const methodHandle& mh, int bci, CompLevel level, JavaThread* thread) {
 426   assert(level <= TieredStopAtLevel, "Invalid compilation level");
 427   if (level == CompLevel_none) {
 428     return;
 429   }
 430   if (level == CompLevel_aot) {
 431     if (mh->has_aot_code()) {
 432       if (PrintTieredEvents) {
 433         print_event(COMPILE, mh, mh, bci, level);
 434       }
 435       MutexLocker ml(Compile_lock);
 436       NoSafepointVerifier nsv;
 437       if (mh->has_aot_code() && mh->code() != mh->aot_code()) {
 438         mh->aot_code()->make_entrant();
 439         if (mh->has_compiled_code()) {
 440           mh->code()->make_not_entrant();
 441         }
 442         Method::set_code(mh, mh->aot_code());
 443       }
 444     }
 445     return;
 446   }
 447 
 448   // Check if the method can be compiled. If it cannot be compiled with C1, continue profiling
 449   // in the interpreter and then compile with C2 (the transition function will request that,
 450   // see common() ). If the method cannot be compiled with C2 but still can with C1, compile it with
 451   // pure C1.
 452   if (!can_be_compiled(mh, level)) {
 453     if (level == CompLevel_full_optimization && can_be_compiled(mh, CompLevel_simple)) {
 454         compile(mh, bci, CompLevel_simple, thread);











 455     }
 456     return;
 457   }
 458   if (bci != InvocationEntryBci && mh->is_not_osr_compilable(level)) {
 459     return;
 460   }
 461   if (!CompileBroker::compilation_is_in_queue(mh)) {
 462     if (PrintTieredEvents) {
 463       print_event(COMPILE, mh, mh, bci, level);
 464     }
 465     submit_compile(mh, bci, level, thread);
 466   }
 467 }
 468 
 469 // Update the rate and submit compile
 470 void TieredThresholdPolicy::submit_compile(const methodHandle& mh, int bci, CompLevel level, JavaThread* thread) {
 471   int hot_count = (bci == InvocationEntryBci) ? mh->invocation_count() : mh->backedge_count();
 472   update_rate(os::javaTimeMillis(), mh());
 473   CompileBroker::compile_method(mh, bci, level, mh, hot_count, CompileTask::Reason_Tiered, thread);
 474 }


< prev index next >