< prev index next >
src/hotspot/share/gc/shenandoah/shenandoahHeap.cpp
Print this page
rev 58162 : 8239926: Shenandoah: Shenandoah needs to mark nmethod's metadata
@@ -1445,10 +1445,19 @@
}
if (ShenandoahPacing) {
pacer()->setup_for_mark();
}
+
+ // Arm nmethods for concurrent marking.
+ // When a nmethod is about to be executed, we need to make sure that all its
+ // metadata are marked.
+ // The alternative is to remark thread roots at final mark pause, but it can
+ // be potential latency killer.
+ if (ShenandoahConcurrentRoots::should_do_concurrent_class_unloading()) {
+ ShenandoahCodeRoots::arm_nmethods();
+ }
}
void ShenandoahHeap::op_mark() {
concurrent_mark()->mark_from_roots();
}
@@ -1482,10 +1491,15 @@
// It is critical that we
// evacuate roots right after finishing marking, so that we don't
// get unmarked objects in the roots.
if (!cancelled_gc()) {
+ // If can not concurrently mark nmethod's metadata, we need to remark thread roots
+ if (!ShenandoahConcurrentRoots::can_do_concurrent_class_unloading()) {
+ concurrent_mark()->remark_thread_roots();
+ }
+
concurrent_mark()->finish_mark_from_roots(/* full_gc = */ false);
// Marking is completed, deactivate SATB barrier
set_concurrent_mark_in_progress(false);
mark_complete_marking_context();
@@ -1980,10 +1994,15 @@
op_final_updaterefs();
if (cancelled_gc()) {
op_degenerated_fail();
return;
}
+ } else if (ShenandoahConcurrentRoots::can_do_concurrent_class_unloading()) {
+ // Disarm nmethods that armed for concurrent mark.
+ // On normal code path (non-empty Cset), it depends on update_roots() to
+ // disarm nmethods in degenerated GC.
+ ShenandoahCodeRoots::disarm_nmethods();
}
op_cleanup();
break;
< prev index next >