Skip to content
Permalink
Browse files
8253118: Avoid unnecessary deopts when OSR nmethods of the same level…
… are present.

Reviewed-by: kvn
  • Loading branch information
Igor Veresov committed Oct 2, 2020
1 parent 3c4e824 commit b9505df3b4bab876995443237f17af7b544e2145
Showing with 9 additions and 6 deletions.
  1. +9 −6 src/hotspot/share/compiler/tieredThresholdPolicy.cpp
@@ -507,16 +507,19 @@ nmethod* TieredThresholdPolicy::event(const methodHandle& method, const methodHa
// method == inlinee if the event originated in the main method
method_back_branch_event(method, inlinee, bci, comp_level, nm, THREAD);
// Check if event led to a higher level OSR compilation
CompLevel expected_comp_level = comp_level;
CompLevel expected_comp_level = MIN2(CompLevel_full_optimization, static_cast<CompLevel>(comp_level + 1));
if (!CompilationModeFlag::disable_intermediate() && inlinee->is_not_osr_compilable(expected_comp_level)) {
// It's not possble to reach the expected level so fall back to simple.
expected_comp_level = CompLevel_simple;
}
nmethod* osr_nm = inlinee->lookup_osr_nmethod_for(bci, expected_comp_level, false);
assert(osr_nm == NULL || osr_nm->comp_level() >= expected_comp_level, "lookup_osr_nmethod_for is broken");
if (osr_nm != NULL) {
// Perform OSR with new nmethod
return osr_nm;
CompLevel max_osr_level = static_cast<CompLevel>(inlinee->highest_osr_comp_level());
if (max_osr_level >= expected_comp_level) { // fast check to avoid locking in a typical scenario
nmethod* osr_nm = inlinee->lookup_osr_nmethod_for(bci, expected_comp_level, false);
assert(osr_nm == NULL || osr_nm->comp_level() >= expected_comp_level, "lookup_osr_nmethod_for is broken");
if (osr_nm != NULL && osr_nm->comp_level() != comp_level) {
// Perform OSR with new nmethod
return osr_nm;
}
}
}
return NULL;

1 comment on commit b9505df

@bridgekeeper

This comment has been minimized.

Copy link

@bridgekeeper bridgekeeper bot commented on b9505df Oct 2, 2020

Please sign in to comment.