25 #include "precompiled.hpp" |
25 #include "precompiled.hpp" |
26 #include "code/codeCache.hpp" |
26 #include "code/codeCache.hpp" |
27 #include "compiler/compileTask.hpp" |
27 #include "compiler/compileTask.hpp" |
28 #include "runtime/advancedThresholdPolicy.hpp" |
28 #include "runtime/advancedThresholdPolicy.hpp" |
29 #include "runtime/simpleThresholdPolicy.inline.hpp" |
29 #include "runtime/simpleThresholdPolicy.inline.hpp" |
|
30 #if INCLUDE_JVMCI |
|
31 #include "jvmci/jvmciRuntime.hpp" |
|
32 #endif |
30 |
33 |
31 #ifdef TIERED |
34 #ifdef TIERED |
32 // Print an event. |
35 // Print an event. |
33 void AdvancedThresholdPolicy::print_specific(EventType type, methodHandle mh, methodHandle imh, |
36 void AdvancedThresholdPolicy::print_specific(EventType type, methodHandle mh, methodHandle imh, |
34 int bci, CompLevel level) { |
37 int bci, CompLevel level) { |
451 } |
454 } |
452 return MIN2(next_level, (CompLevel)TieredStopAtLevel); |
455 return MIN2(next_level, (CompLevel)TieredStopAtLevel); |
453 } |
456 } |
454 |
457 |
455 // Determine if a method should be compiled with a normal entry point at a different level. |
458 // Determine if a method should be compiled with a normal entry point at a different level. |
456 CompLevel AdvancedThresholdPolicy::call_event(Method* method, CompLevel cur_level) { |
459 CompLevel AdvancedThresholdPolicy::call_event(Method* method, CompLevel cur_level, JavaThread * thread) { |
457 CompLevel osr_level = MIN2((CompLevel) method->highest_osr_comp_level(), |
460 CompLevel osr_level = MIN2((CompLevel) method->highest_osr_comp_level(), |
458 common(&AdvancedThresholdPolicy::loop_predicate, method, cur_level, true)); |
461 common(&AdvancedThresholdPolicy::loop_predicate, method, cur_level, true)); |
459 CompLevel next_level = common(&AdvancedThresholdPolicy::call_predicate, method, cur_level); |
462 CompLevel next_level = common(&AdvancedThresholdPolicy::call_predicate, method, cur_level); |
460 |
463 |
461 // If OSR method level is greater than the regular method level, the levels should be |
464 // If OSR method level is greater than the regular method level, the levels should be |
468 next_level = CompLevel_full_optimization; |
471 next_level = CompLevel_full_optimization; |
469 } |
472 } |
470 } else { |
473 } else { |
471 next_level = MAX2(osr_level, next_level); |
474 next_level = MAX2(osr_level, next_level); |
472 } |
475 } |
|
476 #if INCLUDE_JVMCI |
|
477 if (UseJVMCICompiler) { |
|
478 next_level = JVMCIRuntime::adjust_comp_level(method, false, next_level, thread); |
|
479 } |
|
480 #endif |
473 return next_level; |
481 return next_level; |
474 } |
482 } |
475 |
483 |
476 // Determine if we should do an OSR compilation of a given method. |
484 // Determine if we should do an OSR compilation of a given method. |
477 CompLevel AdvancedThresholdPolicy::loop_event(Method* method, CompLevel cur_level) { |
485 CompLevel AdvancedThresholdPolicy::loop_event(Method* method, CompLevel cur_level, JavaThread * thread) { |
478 CompLevel next_level = common(&AdvancedThresholdPolicy::loop_predicate, method, cur_level, true); |
486 CompLevel next_level = common(&AdvancedThresholdPolicy::loop_predicate, method, cur_level, true); |
479 if (cur_level == CompLevel_none) { |
487 if (cur_level == CompLevel_none) { |
480 // If there is a live OSR method that means that we deopted to the interpreter |
488 // If there is a live OSR method that means that we deopted to the interpreter |
481 // for the transition. |
489 // for the transition. |
482 CompLevel osr_level = MIN2((CompLevel)method->highest_osr_comp_level(), next_level); |
490 CompLevel osr_level = MIN2((CompLevel)method->highest_osr_comp_level(), next_level); |
483 if (osr_level > CompLevel_none) { |
491 if (osr_level > CompLevel_none) { |
484 return osr_level; |
492 return osr_level; |
485 } |
493 } |
486 } |
494 } |
|
495 #if INCLUDE_JVMCI |
|
496 if (UseJVMCICompiler) { |
|
497 next_level = JVMCIRuntime::adjust_comp_level(method, true, next_level, thread); |
|
498 } |
|
499 #endif |
487 return next_level; |
500 return next_level; |
488 } |
501 } |
489 |
502 |
490 // Update the rate and submit compile |
503 // Update the rate and submit compile |
491 void AdvancedThresholdPolicy::submit_compile(const methodHandle& mh, int bci, CompLevel level, JavaThread* thread) { |
504 void AdvancedThresholdPolicy::submit_compile(const methodHandle& mh, int bci, CompLevel level, JavaThread* thread) { |
499 CompLevel level, CompiledMethod* nm, JavaThread* thread) { |
512 CompLevel level, CompiledMethod* nm, JavaThread* thread) { |
500 if (should_create_mdo(mh(), level)) { |
513 if (should_create_mdo(mh(), level)) { |
501 create_mdo(mh, thread); |
514 create_mdo(mh, thread); |
502 } |
515 } |
503 if (is_compilation_enabled() && !CompileBroker::compilation_is_in_queue(mh)) { |
516 if (is_compilation_enabled() && !CompileBroker::compilation_is_in_queue(mh)) { |
504 CompLevel next_level = call_event(mh(), level); |
517 CompLevel next_level = call_event(mh(), level, thread); |
505 if (next_level != level) { |
518 if (next_level != level) { |
506 compile(mh, InvocationEntryBci, next_level, thread); |
519 compile(mh, InvocationEntryBci, next_level, thread); |
507 } |
520 } |
508 } |
521 } |
509 } |
522 } |
519 if (should_create_mdo(imh(), level)) { |
532 if (should_create_mdo(imh(), level)) { |
520 create_mdo(imh, thread); |
533 create_mdo(imh, thread); |
521 } |
534 } |
522 |
535 |
523 if (is_compilation_enabled()) { |
536 if (is_compilation_enabled()) { |
524 CompLevel next_osr_level = loop_event(imh(), level); |
537 CompLevel next_osr_level = loop_event(imh(), level, thread); |
525 CompLevel max_osr_level = (CompLevel)imh->highest_osr_comp_level(); |
538 CompLevel max_osr_level = (CompLevel)imh->highest_osr_comp_level(); |
526 // At the very least compile the OSR version |
539 // At the very least compile the OSR version |
527 if (!CompileBroker::compilation_is_in_queue(imh) && (next_osr_level != level)) { |
540 if (!CompileBroker::compilation_is_in_queue(imh) && (next_osr_level != level)) { |
528 compile(imh, bci, next_osr_level, thread); |
541 compile(imh, bci, next_osr_level, thread); |
529 } |
542 } |
532 // enough calls. |
545 // enough calls. |
533 CompLevel cur_level, next_level; |
546 CompLevel cur_level, next_level; |
534 if (mh() != imh()) { // If there is an enclosing method |
547 if (mh() != imh()) { // If there is an enclosing method |
535 guarantee(nm != NULL, "Should have nmethod here"); |
548 guarantee(nm != NULL, "Should have nmethod here"); |
536 cur_level = comp_level(mh()); |
549 cur_level = comp_level(mh()); |
537 next_level = call_event(mh(), cur_level); |
550 next_level = call_event(mh(), cur_level, thread); |
538 |
551 |
539 if (max_osr_level == CompLevel_full_optimization) { |
552 if (max_osr_level == CompLevel_full_optimization) { |
540 // The inlinee OSRed to full opt, we need to modify the enclosing method to avoid deopts |
553 // The inlinee OSRed to full opt, we need to modify the enclosing method to avoid deopts |
541 bool make_not_entrant = false; |
554 bool make_not_entrant = false; |
542 if (nm->is_osr_method()) { |
555 if (nm->is_osr_method()) { |
567 compile(mh, InvocationEntryBci, next_level, thread); |
580 compile(mh, InvocationEntryBci, next_level, thread); |
568 } |
581 } |
569 } |
582 } |
570 } else { |
583 } else { |
571 cur_level = comp_level(imh()); |
584 cur_level = comp_level(imh()); |
572 next_level = call_event(imh(), cur_level); |
585 next_level = call_event(imh(), cur_level, thread); |
573 if (!CompileBroker::compilation_is_in_queue(imh) && (next_level != cur_level)) { |
586 if (!CompileBroker::compilation_is_in_queue(imh) && (next_level != cur_level)) { |
574 compile(imh, InvocationEntryBci, next_level, thread); |
587 compile(imh, InvocationEntryBci, next_level, thread); |
575 } |
588 } |
576 } |
589 } |
577 } |
590 } |