220 } else { 221 // method == inlinee if the event originated in the main method 222 method_back_branch_event(method, inlinee, bci, comp_level, nm, thread); 223 // Check if event led to a higher level OSR compilation 224 nmethod* osr_nm = inlinee->lookup_osr_nmethod_for(bci, comp_level, false); 225 if (osr_nm != NULL && osr_nm->comp_level() > comp_level) { 226 // Perform OSR with new nmethod 227 return osr_nm; 228 } 229 } 230 return NULL; 231 } 232 233 // Check if the method can be compiled, change level if necessary 234 void SimpleThresholdPolicy::compile(const methodHandle& mh, int bci, CompLevel level, JavaThread* thread) { 235 assert(level <= TieredStopAtLevel, "Invalid compilation level"); 236 if (level == CompLevel_none) { 237 return; 238 } 239 240 #if INCLUDE_JVMCI 241 // We can't compile with a JVMCI compiler until the module system is initialized past 242 // phase 3. The JVMCI API itself isn't available until phase 2 and ServiceLoader isn't 243 // usable until after phase 3. 244 if (level == CompLevel_full_optimization && EnableJVMCI && UseJVMCICompiler) { 245 if (SystemDictionary::java_system_loader() == NULL) { 246 return; 247 } 248 assert(Universe::is_module_initialized(), "must be"); 249 } 250 #endif 251 252 // Check if the method can be compiled. If it cannot be compiled with C1, continue profiling 253 // in the interpreter and then compile with C2 (the transition function will request that, 254 // see common() ). If the method cannot be compiled with C2 but still can with C1, compile it with 255 // pure C1. 256 if (!can_be_compiled(mh, level)) { 257 if (level == CompLevel_full_optimization && can_be_compiled(mh, CompLevel_simple)) { 258 compile(mh, bci, CompLevel_simple, thread); 259 } 260 return; 261 } 262 if (bci != InvocationEntryBci && mh->is_not_osr_compilable(level)) { 263 return; 264 } 265 if (!CompileBroker::compilation_is_in_queue(mh)) { 266 if (PrintTieredEvents) { 267 print_event(COMPILE, mh, mh, bci, level); 268 } 269 submit_compile(mh, bci, level, thread); 270 } 271 } | 220 } else { 221 // method == inlinee if the event originated in the main method 222 method_back_branch_event(method, inlinee, bci, comp_level, nm, thread); 223 // Check if event led to a higher level OSR compilation 224 nmethod* osr_nm = inlinee->lookup_osr_nmethod_for(bci, comp_level, false); 225 if (osr_nm != NULL && osr_nm->comp_level() > comp_level) { 226 // Perform OSR with new nmethod 227 return osr_nm; 228 } 229 } 230 return NULL; 231 } 232 233 // Check if the method can be compiled, change level if necessary 234 void SimpleThresholdPolicy::compile(const methodHandle& mh, int bci, CompLevel level, JavaThread* thread) { 235 assert(level <= TieredStopAtLevel, "Invalid compilation level"); 236 if (level == CompLevel_none) { 237 return; 238 } 239 240 // Check if the method can be compiled. If it cannot be compiled with C1, continue profiling 241 // in the interpreter and then compile with C2 (the transition function will request that, 242 // see common() ). If the method cannot be compiled with C2 but still can with C1, compile it with 243 // pure C1. 244 if (!can_be_compiled(mh, level)) { 245 if (level == CompLevel_full_optimization && can_be_compiled(mh, CompLevel_simple)) { 246 compile(mh, bci, CompLevel_simple, thread); 247 } 248 return; 249 } 250 if (bci != InvocationEntryBci && mh->is_not_osr_compilable(level)) { 251 return; 252 } 253 if (!CompileBroker::compilation_is_in_queue(mh)) { 254 if (PrintTieredEvents) { 255 print_event(COMPILE, mh, mh, bci, level); 256 } 257 submit_compile(mh, bci, level, thread); 258 } 259 } |