914 }
915 return;
916 }
917
918 if (!CompilationModeFlag::disable_intermediate()) {
919 // Check if the method can be compiled. If it cannot be compiled with C1, continue profiling
920 // in the interpreter and then compile with C2 (the transition function will request that,
921 // see common() ). If the method cannot be compiled with C2 but still can with C1, compile it with
922 // pure C1.
923 if ((bci == InvocationEntryBci && !can_be_compiled(mh, level))) {
924 if (level == CompLevel_full_optimization && can_be_compiled(mh, CompLevel_simple)) {
925 compile(mh, bci, CompLevel_simple, THREAD);
926 }
927 return;
928 }
929 if ((bci != InvocationEntryBci && !can_be_osr_compiled(mh, level))) {
930 if (level == CompLevel_full_optimization && can_be_osr_compiled(mh, CompLevel_simple)) {
931 nmethod* osr_nm = mh->lookup_osr_nmethod_for(bci, CompLevel_simple, false);
932 if (osr_nm != nullptr && osr_nm->comp_level() > CompLevel_simple) {
933 // Invalidate the existing OSR nmethod so that a compile at CompLevel_simple is permitted.
934 osr_nm->make_not_entrant(nmethod::ChangeReason::OSR_invalidation_for_compiling_with_C1);
935 }
936 compile(mh, bci, CompLevel_simple, THREAD);
937 }
938 return;
939 }
940 }
941 if (bci != InvocationEntryBci && mh->is_not_osr_compilable(level)) {
942 return;
943 }
944 if (!CompileBroker::compilation_is_in_queue(mh)) {
945 if (PrintTieredEvents) {
946 print_event(COMPILE, mh(), mh(), bci, level);
947 }
948 int hot_count = (bci == InvocationEntryBci) ? mh->invocation_count() : mh->backedge_count();
949 update_rate(nanos_to_millis(os::javaTimeNanos()), mh);
950 CompileBroker::compile_method(mh, bci, level, hot_count, CompileTask::Reason_Tiered, THREAD);
951 }
952 }
953
954 // update_rate() is called from select_task() while holding a compile queue lock.
1512
1513 if (max_osr_level == CompLevel_full_optimization) {
1514 // The inlinee OSRed to full opt, we need to modify the enclosing method to avoid deopts
1515 bool make_not_entrant = false;
1516 if (nm->is_osr_method()) {
1517 // This is an osr method, just make it not entrant and recompile later if needed
1518 make_not_entrant = true;
1519 } else {
1520 if (next_level != CompLevel_full_optimization) {
1521 // next_level is not full opt, so we need to recompile the
1522 // enclosing method without the inlinee
1523 cur_level = CompLevel_none;
1524 make_not_entrant = true;
1525 }
1526 }
1527 if (make_not_entrant) {
1528 if (PrintTieredEvents) {
1529 int osr_bci = nm->is_osr_method() ? nm->osr_entry_bci() : InvocationEntryBci;
1530 print_event(MAKE_NOT_ENTRANT, mh(), mh(), osr_bci, level);
1531 }
1532 nm->make_not_entrant(nmethod::ChangeReason::OSR_invalidation_back_branch);
1533 }
1534 }
1535 // Fix up next_level if necessary to avoid deopts
1536 if (next_level == CompLevel_limited_profile && max_osr_level == CompLevel_full_profile) {
1537 next_level = CompLevel_full_profile;
1538 }
1539 if (cur_level != next_level) {
1540 if (!CompileBroker::compilation_is_in_queue(mh)) {
1541 compile(mh, InvocationEntryBci, next_level, THREAD);
1542 }
1543 }
1544 }
1545 } else {
1546 cur_level = comp_level(mh());
1547 next_level = call_event(mh, cur_level, THREAD);
1548 if (next_level != cur_level) {
1549 if (!CompileBroker::compilation_is_in_queue(mh)) {
1550 compile(mh, InvocationEntryBci, next_level, THREAD);
1551 }
1552 }
|
914 }
915 return;
916 }
917
918 if (!CompilationModeFlag::disable_intermediate()) {
919 // Check if the method can be compiled. If it cannot be compiled with C1, continue profiling
920 // in the interpreter and then compile with C2 (the transition function will request that,
921 // see common() ). If the method cannot be compiled with C2 but still can with C1, compile it with
922 // pure C1.
923 if ((bci == InvocationEntryBci && !can_be_compiled(mh, level))) {
924 if (level == CompLevel_full_optimization && can_be_compiled(mh, CompLevel_simple)) {
925 compile(mh, bci, CompLevel_simple, THREAD);
926 }
927 return;
928 }
929 if ((bci != InvocationEntryBci && !can_be_osr_compiled(mh, level))) {
930 if (level == CompLevel_full_optimization && can_be_osr_compiled(mh, CompLevel_simple)) {
931 nmethod* osr_nm = mh->lookup_osr_nmethod_for(bci, CompLevel_simple, false);
932 if (osr_nm != nullptr && osr_nm->comp_level() > CompLevel_simple) {
933 // Invalidate the existing OSR nmethod so that a compile at CompLevel_simple is permitted.
934 osr_nm->make_not_entrant(nmethod::InvalidationReason::OSR_INVALIDATION_FOR_COMPILING_WITH_C1);
935 }
936 compile(mh, bci, CompLevel_simple, THREAD);
937 }
938 return;
939 }
940 }
941 if (bci != InvocationEntryBci && mh->is_not_osr_compilable(level)) {
942 return;
943 }
944 if (!CompileBroker::compilation_is_in_queue(mh)) {
945 if (PrintTieredEvents) {
946 print_event(COMPILE, mh(), mh(), bci, level);
947 }
948 int hot_count = (bci == InvocationEntryBci) ? mh->invocation_count() : mh->backedge_count();
949 update_rate(nanos_to_millis(os::javaTimeNanos()), mh);
950 CompileBroker::compile_method(mh, bci, level, hot_count, CompileTask::Reason_Tiered, THREAD);
951 }
952 }
953
954 // update_rate() is called from select_task() while holding a compile queue lock.
1512
1513 if (max_osr_level == CompLevel_full_optimization) {
1514 // The inlinee OSRed to full opt, we need to modify the enclosing method to avoid deopts
1515 bool make_not_entrant = false;
1516 if (nm->is_osr_method()) {
1517 // This is an osr method, just make it not entrant and recompile later if needed
1518 make_not_entrant = true;
1519 } else {
1520 if (next_level != CompLevel_full_optimization) {
1521 // next_level is not full opt, so we need to recompile the
1522 // enclosing method without the inlinee
1523 cur_level = CompLevel_none;
1524 make_not_entrant = true;
1525 }
1526 }
1527 if (make_not_entrant) {
1528 if (PrintTieredEvents) {
1529 int osr_bci = nm->is_osr_method() ? nm->osr_entry_bci() : InvocationEntryBci;
1530 print_event(MAKE_NOT_ENTRANT, mh(), mh(), osr_bci, level);
1531 }
1532 nm->make_not_entrant(nmethod::InvalidationReason::OSR_INVALIDATION_BACK_BRANCH);
1533 }
1534 }
1535 // Fix up next_level if necessary to avoid deopts
1536 if (next_level == CompLevel_limited_profile && max_osr_level == CompLevel_full_profile) {
1537 next_level = CompLevel_full_profile;
1538 }
1539 if (cur_level != next_level) {
1540 if (!CompileBroker::compilation_is_in_queue(mh)) {
1541 compile(mh, InvocationEntryBci, next_level, THREAD);
1542 }
1543 }
1544 }
1545 } else {
1546 cur_level = comp_level(mh());
1547 next_level = call_event(mh, cur_level, THREAD);
1548 if (next_level != cur_level) {
1549 if (!CompileBroker::compilation_is_in_queue(mh)) {
1550 compile(mh, InvocationEntryBci, next_level, THREAD);
1551 }
1552 }
|