diff -r a9f729b641a3 -r 1dc9bf9d016b src/hotspot/share/oops/instanceKlass.cpp --- a/src/hotspot/share/oops/instanceKlass.cpp Tue May 07 07:44:15 2019 +0200 +++ b/src/hotspot/share/oops/instanceKlass.cpp Tue May 07 09:17:03 2019 +0200 @@ -2965,6 +2965,13 @@ // On-stack replacement stuff void InstanceKlass::add_osr_nmethod(nmethod* n) { +#ifndef PRODUCT + if (TieredCompilation) { + nmethod * prev = lookup_osr_nmethod(n->method(), n->osr_entry_bci(), n->comp_level(), true); + assert(prev == NULL || !prev->is_in_use(), + "redundunt OSR recompilation detected. memory leak in CodeCache!"); + } +#endif // only one compilation can be active { // This is a short non-blocking critical region, so the no safepoint check is ok. @@ -3083,7 +3090,9 @@ } osr = osr->osr_link(); } - if (best != NULL && best->comp_level() >= comp_level && match_level == false) { + + assert(match_level == false || best == NULL, "shouldn't pick up anything if match_level is set"); + if (best != NULL && best->comp_level() >= comp_level) { return best; } return NULL;