< prev index next >

src/hotspot/share/compiler/compilationPolicy.cpp

Print this page

 907     }
 908     return;
 909   }
 910 
 911   if (!CompilationModeFlag::disable_intermediate()) {
 912     // Check if the method can be compiled. If it cannot be compiled with C1, continue profiling
 913     // in the interpreter and then compile with C2 (the transition function will request that,
 914     // see common() ). If the method cannot be compiled with C2 but still can with C1, compile it with
 915     // pure C1.
 916     if ((bci == InvocationEntryBci && !can_be_compiled(mh, level))) {
 917       if (level == CompLevel_full_optimization && can_be_compiled(mh, CompLevel_simple)) {
 918         compile(mh, bci, CompLevel_simple, THREAD);
 919       }
 920       return;
 921     }
 922     if ((bci != InvocationEntryBci && !can_be_osr_compiled(mh, level))) {
 923       if (level == CompLevel_full_optimization && can_be_osr_compiled(mh, CompLevel_simple)) {
 924         nmethod* osr_nm = mh->lookup_osr_nmethod_for(bci, CompLevel_simple, false);
 925         if (osr_nm != nullptr && osr_nm->comp_level() > CompLevel_simple) {
 926           // Invalidate the existing OSR nmethod so that a compile at CompLevel_simple is permitted.
 927           osr_nm->make_not_entrant("OSR invalidation for compiling with C1");
 928         }
 929         compile(mh, bci, CompLevel_simple, THREAD);
 930       }
 931       return;
 932     }
 933   }
 934   if (bci != InvocationEntryBci && mh->is_not_osr_compilable(level)) {
 935     return;
 936   }
 937   if (!CompileBroker::compilation_is_in_queue(mh)) {
 938     if (PrintTieredEvents) {
 939       print_event(COMPILE, mh(), mh(), bci, level);
 940     }
 941     int hot_count = (bci == InvocationEntryBci) ? mh->invocation_count() : mh->backedge_count();
 942     update_rate(nanos_to_millis(os::javaTimeNanos()), mh);
 943     CompileBroker::compile_method(mh, bci, level, hot_count, CompileTask::Reason_Tiered, THREAD);
 944   }
 945 }
 946 
 947 // update_rate() is called from select_task() while holding a compile queue lock.

1499 
1500         if (max_osr_level == CompLevel_full_optimization) {
1501           // The inlinee OSRed to full opt, we need to modify the enclosing method to avoid deopts
1502           bool make_not_entrant = false;
1503           if (nm->is_osr_method()) {
1504             // This is an osr method, just make it not entrant and recompile later if needed
1505             make_not_entrant = true;
1506           } else {
1507             if (next_level != CompLevel_full_optimization) {
1508               // next_level is not full opt, so we need to recompile the
1509               // enclosing method without the inlinee
1510               cur_level = CompLevel_none;
1511               make_not_entrant = true;
1512             }
1513           }
1514           if (make_not_entrant) {
1515             if (PrintTieredEvents) {
1516               int osr_bci = nm->is_osr_method() ? nm->osr_entry_bci() : InvocationEntryBci;
1517               print_event(MAKE_NOT_ENTRANT, mh(), mh(), osr_bci, level);
1518             }
1519             nm->make_not_entrant("OSR invalidation, back branch");
1520           }
1521         }
1522         // Fix up next_level if necessary to avoid deopts
1523         if (next_level == CompLevel_limited_profile && max_osr_level == CompLevel_full_profile) {
1524           next_level = CompLevel_full_profile;
1525         }
1526         if (cur_level != next_level) {
1527           if (!CompileBroker::compilation_is_in_queue(mh)) {
1528             compile(mh, InvocationEntryBci, next_level, THREAD);
1529           }
1530         }
1531       }
1532     } else {
1533       cur_level = comp_level(mh());
1534       next_level = call_event(mh, cur_level, THREAD);
1535       if (next_level != cur_level) {
1536         if (!CompileBroker::compilation_is_in_queue(mh)) {
1537           compile(mh, InvocationEntryBci, next_level, THREAD);
1538         }
1539       }

 907     }
 908     return;
 909   }
 910 
 911   if (!CompilationModeFlag::disable_intermediate()) {
 912     // Check if the method can be compiled. If it cannot be compiled with C1, continue profiling
 913     // in the interpreter and then compile with C2 (the transition function will request that,
 914     // see common() ). If the method cannot be compiled with C2 but still can with C1, compile it with
 915     // pure C1.
 916     if ((bci == InvocationEntryBci && !can_be_compiled(mh, level))) {
 917       if (level == CompLevel_full_optimization && can_be_compiled(mh, CompLevel_simple)) {
 918         compile(mh, bci, CompLevel_simple, THREAD);
 919       }
 920       return;
 921     }
 922     if ((bci != InvocationEntryBci && !can_be_osr_compiled(mh, level))) {
 923       if (level == CompLevel_full_optimization && can_be_osr_compiled(mh, CompLevel_simple)) {
 924         nmethod* osr_nm = mh->lookup_osr_nmethod_for(bci, CompLevel_simple, false);
 925         if (osr_nm != nullptr && osr_nm->comp_level() > CompLevel_simple) {
 926           // Invalidate the existing OSR nmethod so that a compile at CompLevel_simple is permitted.
 927           osr_nm->make_not_entrant(nmethod::InvalidationReason::OSR_INVALIDATION_FOR_COMPILING_WITH_C1);
 928         }
 929         compile(mh, bci, CompLevel_simple, THREAD);
 930       }
 931       return;
 932     }
 933   }
 934   if (bci != InvocationEntryBci && mh->is_not_osr_compilable(level)) {
 935     return;
 936   }
 937   if (!CompileBroker::compilation_is_in_queue(mh)) {
 938     if (PrintTieredEvents) {
 939       print_event(COMPILE, mh(), mh(), bci, level);
 940     }
 941     int hot_count = (bci == InvocationEntryBci) ? mh->invocation_count() : mh->backedge_count();
 942     update_rate(nanos_to_millis(os::javaTimeNanos()), mh);
 943     CompileBroker::compile_method(mh, bci, level, hot_count, CompileTask::Reason_Tiered, THREAD);
 944   }
 945 }
 946 
 947 // update_rate() is called from select_task() while holding a compile queue lock.

1499 
1500         if (max_osr_level == CompLevel_full_optimization) {
1501           // The inlinee OSRed to full opt, we need to modify the enclosing method to avoid deopts
1502           bool make_not_entrant = false;
1503           if (nm->is_osr_method()) {
1504             // This is an osr method, just make it not entrant and recompile later if needed
1505             make_not_entrant = true;
1506           } else {
1507             if (next_level != CompLevel_full_optimization) {
1508               // next_level is not full opt, so we need to recompile the
1509               // enclosing method without the inlinee
1510               cur_level = CompLevel_none;
1511               make_not_entrant = true;
1512             }
1513           }
1514           if (make_not_entrant) {
1515             if (PrintTieredEvents) {
1516               int osr_bci = nm->is_osr_method() ? nm->osr_entry_bci() : InvocationEntryBci;
1517               print_event(MAKE_NOT_ENTRANT, mh(), mh(), osr_bci, level);
1518             }
1519             nm->make_not_entrant(nmethod::InvalidationReason::OSR_INVALIDATION_BACK_BRANCH);
1520           }
1521         }
1522         // Fix up next_level if necessary to avoid deopts
1523         if (next_level == CompLevel_limited_profile && max_osr_level == CompLevel_full_profile) {
1524           next_level = CompLevel_full_profile;
1525         }
1526         if (cur_level != next_level) {
1527           if (!CompileBroker::compilation_is_in_queue(mh)) {
1528             compile(mh, InvocationEntryBci, next_level, THREAD);
1529           }
1530         }
1531       }
1532     } else {
1533       cur_level = comp_level(mh());
1534       next_level = call_event(mh, cur_level, THREAD);
1535       if (next_level != cur_level) {
1536         if (!CompileBroker::compilation_is_in_queue(mh)) {
1537           compile(mh, InvocationEntryBci, next_level, THREAD);
1538         }
1539       }
< prev index next >