424 } |
421 } |
425 return next_level; |
422 return next_level; |
426 } |
423 } |
427 |
424 |
428 // Update the rate and submit compile |
425 // Update the rate and submit compile |
429 void AdvancedThresholdPolicy::submit_compile(methodHandle mh, int bci, CompLevel level, TRAPS) { |
426 void AdvancedThresholdPolicy::submit_compile(methodHandle mh, int bci, CompLevel level, JavaThread* thread) { |
430 int hot_count = (bci == InvocationEntryBci) ? mh->invocation_count() : mh->backedge_count(); |
427 int hot_count = (bci == InvocationEntryBci) ? mh->invocation_count() : mh->backedge_count(); |
431 update_rate(os::javaTimeMillis(), mh()); |
428 update_rate(os::javaTimeMillis(), mh()); |
432 CompileBroker::compile_method(mh, bci, level, mh, hot_count, "tiered", THREAD); |
429 CompileBroker::compile_method(mh, bci, level, mh, hot_count, "tiered", thread); |
433 } |
430 } |
434 |
431 |
435 // Handle the invocation event. |
432 // Handle the invocation event. |
436 void AdvancedThresholdPolicy::method_invocation_event(methodHandle mh, methodHandle imh, |
433 void AdvancedThresholdPolicy::method_invocation_event(methodHandle mh, methodHandle imh, |
437 CompLevel level, nmethod* nm, TRAPS) { |
434 CompLevel level, nmethod* nm, JavaThread* thread) { |
438 if (should_create_mdo(mh(), level)) { |
435 if (should_create_mdo(mh(), level)) { |
439 create_mdo(mh, THREAD); |
436 create_mdo(mh, thread); |
440 } |
437 } |
441 if (is_compilation_enabled() && !CompileBroker::compilation_is_in_queue(mh, InvocationEntryBci)) { |
438 if (is_compilation_enabled() && !CompileBroker::compilation_is_in_queue(mh, InvocationEntryBci)) { |
442 CompLevel next_level = call_event(mh(), level); |
439 CompLevel next_level = call_event(mh(), level); |
443 if (next_level != level) { |
440 if (next_level != level) { |
444 compile(mh, InvocationEntryBci, next_level, THREAD); |
441 compile(mh, InvocationEntryBci, next_level, thread); |
445 } |
442 } |
446 } |
443 } |
447 } |
444 } |
448 |
445 |
449 // Handle the back branch event. Notice that we can compile the method |
446 // Handle the back branch event. Notice that we can compile the method |
450 // with a regular entry from here. |
447 // with a regular entry from here. |
451 void AdvancedThresholdPolicy::method_back_branch_event(methodHandle mh, methodHandle imh, |
448 void AdvancedThresholdPolicy::method_back_branch_event(methodHandle mh, methodHandle imh, |
452 int bci, CompLevel level, nmethod* nm, TRAPS) { |
449 int bci, CompLevel level, nmethod* nm, JavaThread* thread) { |
453 if (should_create_mdo(mh(), level)) { |
450 if (should_create_mdo(mh(), level)) { |
454 create_mdo(mh, THREAD); |
451 create_mdo(mh, thread); |
455 } |
452 } |
456 // Check if MDO should be created for the inlined method |
453 // Check if MDO should be created for the inlined method |
457 if (should_create_mdo(imh(), level)) { |
454 if (should_create_mdo(imh(), level)) { |
458 create_mdo(imh, THREAD); |
455 create_mdo(imh, thread); |
459 } |
456 } |
460 |
457 |
461 if (is_compilation_enabled()) { |
458 if (is_compilation_enabled()) { |
462 CompLevel next_osr_level = loop_event(imh(), level); |
459 CompLevel next_osr_level = loop_event(imh(), level); |
463 CompLevel max_osr_level = (CompLevel)imh->highest_osr_comp_level(); |
460 CompLevel max_osr_level = (CompLevel)imh->highest_osr_comp_level(); |
464 // At the very least compile the OSR version |
461 // At the very least compile the OSR version |
465 if (!CompileBroker::compilation_is_in_queue(imh, bci) && next_osr_level != level) { |
462 if (!CompileBroker::compilation_is_in_queue(imh, bci) && next_osr_level != level) { |
466 compile(imh, bci, next_osr_level, THREAD); |
463 compile(imh, bci, next_osr_level, thread); |
467 } |
464 } |
468 |
465 |
469 // Use loop event as an opportunity to also check if there's been |
466 // Use loop event as an opportunity to also check if there's been |
470 // enough calls. |
467 // enough calls. |
471 CompLevel cur_level, next_level; |
468 CompLevel cur_level, next_level; |
500 // Fix up next_level if necessary to avoid deopts |
497 // Fix up next_level if necessary to avoid deopts |
501 if (next_level == CompLevel_limited_profile && max_osr_level == CompLevel_full_profile) { |
498 if (next_level == CompLevel_limited_profile && max_osr_level == CompLevel_full_profile) { |
502 next_level = CompLevel_full_profile; |
499 next_level = CompLevel_full_profile; |
503 } |
500 } |
504 if (cur_level != next_level) { |
501 if (cur_level != next_level) { |
505 compile(mh, InvocationEntryBci, next_level, THREAD); |
502 compile(mh, InvocationEntryBci, next_level, thread); |
506 } |
503 } |
507 } |
504 } |
508 } else { |
505 } else { |
509 cur_level = comp_level(imh()); |
506 cur_level = comp_level(imh()); |
510 next_level = call_event(imh(), cur_level); |
507 next_level = call_event(imh(), cur_level); |
511 if (!CompileBroker::compilation_is_in_queue(imh, bci) && next_level != cur_level) { |
508 if (!CompileBroker::compilation_is_in_queue(imh, bci) && next_level != cur_level) { |
512 compile(imh, InvocationEntryBci, next_level, THREAD); |
509 compile(imh, InvocationEntryBci, next_level, thread); |
513 } |
510 } |
514 } |
511 } |
515 } |
512 } |
516 } |
513 } |
517 |
514 |