From 2009dc2b737b3468ba6c78d4bf2f5a0bba20ec43 Mon Sep 17 00:00:00 2001 From: Richard Reingruber Date: Mon, 20 Feb 2023 06:47:57 +0000 Subject: [PATCH] 8302462: [REDO] 8297487: G1 Remark: no need to keep alive oop constants of nmethods on stack Reviewed-by: tschatzl, ayang --- src/hotspot/share/gc/g1/g1ConcurrentMark.cpp | 15 +-------------- src/hotspot/share/gc/shared/barrierSetNMethod.cpp | 2 ++ 2 files changed, 3 insertions(+), 14 deletions(-) diff --git a/src/hotspot/share/gc/g1/g1ConcurrentMark.cpp b/src/hotspot/share/gc/g1/g1ConcurrentMark.cpp index b712cb43288..cd8d37bacbb 100644 --- a/src/hotspot/share/gc/g1/g1ConcurrentMark.cpp +++ b/src/hotspot/share/gc/g1/g1ConcurrentMark.cpp @@ -1777,27 +1777,14 @@ public: class G1RemarkThreadsClosure : public ThreadClosure { G1SATBMarkQueueSet& _qset; - G1CMOopClosure _cm_cl; - MarkingCodeBlobClosure _code_cl; public: G1RemarkThreadsClosure(G1CollectedHeap* g1h, G1CMTask* task) : - _qset(G1BarrierSet::satb_mark_queue_set()), - _cm_cl(g1h, task), - _code_cl(&_cm_cl, !CodeBlobToOopClosure::FixRelocations, true /* keepalive nmethods */) {} + _qset(G1BarrierSet::satb_mark_queue_set()) {} void do_thread(Thread* thread) { // Transfer any partial buffer to the qset for completed buffer processing. _qset.flush_queue(G1ThreadLocalData::satb_mark_queue(thread)); - if (thread->is_Java_thread()) { - // In theory it should not be necessary to explicitly walk the nmethods to find roots for concurrent marking - // however the liveness of oops reachable from nmethods have very complex lifecycles: - // * Alive if on the stack of an executing method - // * Weakly reachable otherwise - // Some objects reachable from nmethods, such as the class loader (or klass_holder) of the receiver should be - // live by the SATB invariant but other oops recorded in nmethods may behave differently. - JavaThread::cast(thread)->nmethods_do(&_code_cl); - } } }; diff --git a/src/hotspot/share/gc/shared/barrierSetNMethod.cpp b/src/hotspot/share/gc/shared/barrierSetNMethod.cpp index e2faf30405d..793ae9fc6e9 100644 --- a/src/hotspot/share/gc/shared/barrierSetNMethod.cpp +++ b/src/hotspot/share/gc/shared/barrierSetNMethod.cpp @@ -99,6 +99,8 @@ bool BarrierSetNMethod::nmethod_entry_barrier(nmethod* nm) { // If the nmethod is the only thing pointing to the oops, and we are using a // SATB GC, then it is important that this code marks them live. + // Also, with concurrent GC, it is possible that frames in continuation stack + // chunks are not visited if they are allocated after concurrent GC started. OopKeepAliveClosure cl; nm->oops_do(&cl);