410 method_invocation_event(method, inlinee, comp_level, nm, thread); |
410 method_invocation_event(method, inlinee, comp_level, nm, thread); |
411 } else { |
411 } else { |
412 // method == inlinee if the event originated in the main method |
412 // method == inlinee if the event originated in the main method |
413 method_back_branch_event(method, inlinee, bci, comp_level, nm, thread); |
413 method_back_branch_event(method, inlinee, bci, comp_level, nm, thread); |
414 // Check if event led to a higher level OSR compilation |
414 // Check if event led to a higher level OSR compilation |
415 nmethod* osr_nm = inlinee->lookup_osr_nmethod_for(bci, comp_level, false); |
415 CompLevel expected_comp_level = comp_level; |
416 if (osr_nm != NULL && osr_nm->comp_level() > comp_level) { |
416 if (inlinee->is_not_osr_compilable(expected_comp_level)) { |
|
417 // It's not possble to reach the expected level so fall back to simple. |
|
418 expected_comp_level = CompLevel_simple; |
|
419 } |
|
420 nmethod* osr_nm = inlinee->lookup_osr_nmethod_for(bci, expected_comp_level, false); |
|
421 assert(osr_nm == NULL || osr_nm->comp_level() >= expected_comp_level, "lookup_osr_nmethod_for is broken"); |
|
422 if (osr_nm != NULL) { |
417 // Perform OSR with new nmethod |
423 // Perform OSR with new nmethod |
418 return osr_nm; |
424 return osr_nm; |
419 } |
425 } |
420 } |
426 } |
421 return NULL; |
427 return NULL; |
447 |
453 |
448 // Check if the method can be compiled. If it cannot be compiled with C1, continue profiling |
454 // Check if the method can be compiled. If it cannot be compiled with C1, continue profiling |
449 // in the interpreter and then compile with C2 (the transition function will request that, |
455 // in the interpreter and then compile with C2 (the transition function will request that, |
450 // see common() ). If the method cannot be compiled with C2 but still can with C1, compile it with |
456 // see common() ). If the method cannot be compiled with C2 but still can with C1, compile it with |
451 // pure C1. |
457 // pure C1. |
452 if (!can_be_compiled(mh, level)) { |
458 if ((bci == InvocationEntryBci && !can_be_compiled(mh, level))) { |
453 if (level == CompLevel_full_optimization && can_be_compiled(mh, CompLevel_simple)) { |
459 if (level == CompLevel_full_optimization && can_be_compiled(mh, CompLevel_simple)) { |
454 compile(mh, bci, CompLevel_simple, thread); |
460 compile(mh, bci, CompLevel_simple, thread); |
|
461 } |
|
462 return; |
|
463 } |
|
464 if ((bci != InvocationEntryBci && !can_be_osr_compiled(mh, level))) { |
|
465 if (level == CompLevel_full_optimization && can_be_osr_compiled(mh, CompLevel_simple)) { |
|
466 nmethod* osr_nm = mh->lookup_osr_nmethod_for(bci, CompLevel_simple, false); |
|
467 if (osr_nm != NULL && osr_nm->comp_level() > CompLevel_simple) { |
|
468 // Invalidate the existing OSR nmethod so that a compile at CompLevel_simple is permitted. |
|
469 osr_nm->make_not_entrant(); |
|
470 } |
|
471 compile(mh, bci, CompLevel_simple, thread); |
455 } |
472 } |
456 return; |
473 return; |
457 } |
474 } |
458 if (bci != InvocationEntryBci && mh->is_not_osr_compilable(level)) { |
475 if (bci != InvocationEntryBci && mh->is_not_osr_compilable(level)) { |
459 return; |
476 return; |