Skip to content

Commit 66f7387

Browse files
committed
8299074: nmethod marked for deoptimization is not deoptimized
Reviewed-by: eosterlund, rehn, kvn
1 parent 1f438a8 commit 66f7387

File tree

1 file changed

+18
-10
lines changed

1 file changed

+18
-10
lines changed

src/hotspot/share/code/dependencyContext.cpp

Lines changed: 18 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -68,16 +68,22 @@ int DependencyContext::mark_dependent_nmethods(DepChange& changes) {
6868
int found = 0;
6969
for (nmethodBucket* b = dependencies_not_unloading(); b != NULL; b = b->next_not_unloading()) {
7070
nmethod* nm = b->get_nmethod();
71-
if (b->count() > 0 && !nm->is_marked_for_deoptimization() && nm->check_dependency_on(changes)) {
72-
if (TraceDependencies) {
73-
ResourceMark rm;
74-
tty->print_cr("Marked for deoptimization");
75-
changes.print();
76-
nm->print();
77-
nm->print_dependencies();
71+
if (b->count() > 0) {
72+
if (nm->is_marked_for_deoptimization()) {
73+
// Also count already (concurrently) marked nmethods to make sure
74+
// deoptimization is triggered before execution in this thread continues.
75+
found++;
76+
} else if (nm->check_dependency_on(changes)) {
77+
if (TraceDependencies) {
78+
ResourceMark rm;
79+
tty->print_cr("Marked for deoptimization");
80+
changes.print();
81+
nm->print();
82+
nm->print_dependencies();
83+
}
84+
changes.mark_for_deoptimization(nm);
85+
found++;
7886
}
79-
changes.mark_for_deoptimization(nm);
80-
found++;
8187
}
8288
}
8389
return found;
@@ -189,7 +195,9 @@ int DependencyContext::remove_and_mark_for_deoptimization_all_dependents() {
189195
int marked = 0;
190196
while (b != NULL) {
191197
nmethod* nm = b->get_nmethod();
192-
if (b->count() > 0 && !nm->is_marked_for_deoptimization()) {
198+
if (b->count() > 0) {
199+
// Also count already (concurrently) marked nmethods to make sure
200+
// deoptimization is triggered before execution in this thread continues.
193201
nm->mark_for_deoptimization();
194202
marked++;
195203
}

0 commit comments

Comments
 (0)