src/share/vm/runtime/simpleThresholdPolicy.cpp
Index Unified diffs Context diffs Sdiffs Patch New Old Previous File Next File hotspot Sdiff src/share/vm/runtime

src/share/vm/runtime/simpleThresholdPolicy.cpp

Print this page




 179     }
 180     MethodData* mdo = sd->method()->method_data();
 181     if (mdo != NULL) {
 182       mdo->reset_start_counters();
 183     }
 184     if (sd->is_top()) break;
 185   }
 186 }
 187 
 188 nmethod* SimpleThresholdPolicy::event(methodHandle method, methodHandle inlinee,
 189                                       int branch_bci, int bci, CompLevel comp_level, nmethod* nm, JavaThread* thread) {
 190   if (comp_level == CompLevel_none &&
 191       JvmtiExport::can_post_interpreter_events() &&
 192       thread->is_interp_only_mode()) {
 193     return NULL;
 194   }
 195   if (CompileTheWorld || ReplayCompiles) {
 196     // Don't trigger other compiles in testing mode
 197     return NULL;
 198   }
 199   nmethod *osr_nm = NULL;
 200 
 201   handle_counter_overflow(method());
 202   if (method() != inlinee()) {
 203     handle_counter_overflow(inlinee());
 204   }
 205 
 206   if (PrintTieredEvents) {
 207     print_event(bci == InvocationEntryBci ? CALL : LOOP, method, inlinee, bci, comp_level);
 208   }
 209 
 210   if (bci == InvocationEntryBci) {
 211     method_invocation_event(method, inlinee, comp_level, nm, thread);
 212   } else {
 213     method_back_branch_event(method, inlinee, bci, comp_level, nm, thread);
 214     // method == inlinee if the event originated in the main method
 215     int highest_level = inlinee->highest_osr_comp_level();
 216     if (highest_level > comp_level) {
 217       osr_nm = inlinee->lookup_osr_nmethod_for(bci, highest_level, false);



 218     }
 219   }
 220   return osr_nm;
 221 }
 222 
 223 // Check if the method can be compiled, change level if necessary
 224 void SimpleThresholdPolicy::compile(methodHandle mh, int bci, CompLevel level, JavaThread* thread) {
 225   assert(level <= TieredStopAtLevel, "Invalid compilation level");
 226   if (level == CompLevel_none) {
 227     return;
 228   }
 229   // Check if the method can be compiled. If it cannot be compiled with C1, continue profiling
 230   // in the interpreter and then compile with C2 (the transition function will request that,
 231   // see common() ). If the method cannot be compiled with C2 but still can with C1, compile it with
 232   // pure C1.
 233   if (!can_be_compiled(mh, level)) {
 234     if (level == CompLevel_full_optimization && can_be_compiled(mh, CompLevel_simple)) {
 235         compile(mh, bci, CompLevel_simple, thread);
 236     }
 237     return;
 238   }
 239   if (bci != InvocationEntryBci && mh->is_not_osr_compilable(level)) {
 240     return;




 179     }
 180     MethodData* mdo = sd->method()->method_data();
 181     if (mdo != NULL) {
 182       mdo->reset_start_counters();
 183     }
 184     if (sd->is_top()) break;
 185   }
 186 }
 187 
 188 nmethod* SimpleThresholdPolicy::event(methodHandle method, methodHandle inlinee,
 189                                       int branch_bci, int bci, CompLevel comp_level, nmethod* nm, JavaThread* thread) {
 190   if (comp_level == CompLevel_none &&
 191       JvmtiExport::can_post_interpreter_events() &&
 192       thread->is_interp_only_mode()) {
 193     return NULL;
 194   }
 195   if (CompileTheWorld || ReplayCompiles) {
 196     // Don't trigger other compiles in testing mode
 197     return NULL;
 198   }

 199 
 200   handle_counter_overflow(method());
 201   if (method() != inlinee()) {
 202     handle_counter_overflow(inlinee());
 203   }
 204 
 205   if (PrintTieredEvents) {
 206     print_event(bci == InvocationEntryBci ? CALL : LOOP, method, inlinee, bci, comp_level);
 207   }
 208 
 209   if (bci == InvocationEntryBci) {
 210     method_invocation_event(method, inlinee, comp_level, nm, thread);
 211   } else {

 212     // method == inlinee if the event originated in the main method
 213     method_back_branch_event(method, inlinee, bci, comp_level, nm, thread);
 214     // Check if event led to a higher level OSR compilation
 215     nmethod* osr_nm = inlinee->lookup_osr_nmethod_for(bci, comp_level, false);
 216     if (osr_nm != NULL && osr_nm->comp_level() > comp_level) {
 217       // Perform OSR with new nmethod
 218       return osr_nm;
 219     }
 220   }
 221   return NULL;
 222 }
 223 
 224 // Check if the method can be compiled, change level if necessary
 225 void SimpleThresholdPolicy::compile(methodHandle mh, int bci, CompLevel level, JavaThread* thread) {
 226   assert(level <= TieredStopAtLevel, "Invalid compilation level");
 227   if (level == CompLevel_none) {
 228     return;
 229   }
 230   // Check if the method can be compiled. If it cannot be compiled with C1, continue profiling
 231   // in the interpreter and then compile with C2 (the transition function will request that,
 232   // see common() ). If the method cannot be compiled with C2 but still can with C1, compile it with
 233   // pure C1.
 234   if (!can_be_compiled(mh, level)) {
 235     if (level == CompLevel_full_optimization && can_be_compiled(mh, CompLevel_simple)) {
 236         compile(mh, bci, CompLevel_simple, thread);
 237     }
 238     return;
 239   }
 240   if (bci != InvocationEntryBci && mh->is_not_osr_compilable(level)) {
 241     return;


src/share/vm/runtime/simpleThresholdPolicy.cpp
Index Unified diffs Context diffs Sdiffs Patch New Old Previous File Next File