8299074: nmethod marked for deoptimization is not deoptimized

Reviewed-by: eosterlund, rehn, kvn
This commit is contained in:
Tobias Hartmann 2023-01-18 08:15:19 +00:00
parent 1f438a8a70
commit 66f7387b5f

View File

@ -68,16 +68,22 @@ int DependencyContext::mark_dependent_nmethods(DepChange& changes) {
int found = 0; int found = 0;
for (nmethodBucket* b = dependencies_not_unloading(); b != NULL; b = b->next_not_unloading()) { for (nmethodBucket* b = dependencies_not_unloading(); b != NULL; b = b->next_not_unloading()) {
nmethod* nm = b->get_nmethod(); nmethod* nm = b->get_nmethod();
if (b->count() > 0 && !nm->is_marked_for_deoptimization() && nm->check_dependency_on(changes)) { if (b->count() > 0) {
if (TraceDependencies) { if (nm->is_marked_for_deoptimization()) {
ResourceMark rm; // Also count already (concurrently) marked nmethods to make sure
tty->print_cr("Marked for deoptimization"); // deoptimization is triggered before execution in this thread continues.
changes.print(); found++;
nm->print(); } else if (nm->check_dependency_on(changes)) {
nm->print_dependencies(); if (TraceDependencies) {
ResourceMark rm;
tty->print_cr("Marked for deoptimization");
changes.print();
nm->print();
nm->print_dependencies();
}
changes.mark_for_deoptimization(nm);
found++;
} }
changes.mark_for_deoptimization(nm);
found++;
} }
} }
return found; return found;
@ -189,7 +195,9 @@ int DependencyContext::remove_and_mark_for_deoptimization_all_dependents() {
int marked = 0; int marked = 0;
while (b != NULL) { while (b != NULL) {
nmethod* nm = b->get_nmethod(); nmethod* nm = b->get_nmethod();
if (b->count() > 0 && !nm->is_marked_for_deoptimization()) { if (b->count() > 0) {
// Also count already (concurrently) marked nmethods to make sure
// deoptimization is triggered before execution in this thread continues.
nm->mark_for_deoptimization(); nm->mark_for_deoptimization();
marked++; marked++;
} }