Skip to content


8299956: [BACKOUT] 8297487: G1 Remark: no need to keep alive oop cons…
Browse files Browse the repository at this point in the history
…tants of nmethods on stack

Reviewed-by: chagedorn, tschatzl
  • Loading branch information
TobiHartmann committed Jan 11, 2023
1 parent 5a9490a commit d15285f
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 3 deletions.
13 changes: 13 additions & 0 deletions src/hotspot/share/gc/g1/g1ConcurrentMark.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1779,17 +1779,30 @@ class G1CMSATBBufferClosure : public SATBBufferClosure {

class G1RemarkThreadsClosure : public ThreadClosure {
G1SATBMarkQueueSet& _qset;
G1CMOopClosure _cm_cl;
MarkingCodeBlobClosure _code_cl;
uintx _claim_token;

G1RemarkThreadsClosure(G1CollectedHeap* g1h, G1CMTask* task) :
_cm_cl(g1h, task),
_code_cl(&_cm_cl, !CodeBlobToOopClosure::FixRelocations, true /* keepalive nmethods */),
_claim_token(Threads::thread_claim_token()) {}

void do_thread(Thread* thread) {
if (thread->claim_threads_do(true, _claim_token)) {
// Transfer any partial buffer to the qset for completed buffer processing.
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.
Expand Down
5 changes: 2 additions & 3 deletions src/hotspot/share/gc/shared/barrierSet.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -57,9 +57,8 @@ static BarrierSetNMethod* select_barrier_set_nmethod(BarrierSetNMethod* barrier_
// The GC needs nmethod entry barriers to do concurrent GC
return barrier_set_nmethod;
} else {
// The GC needs nmethod entry barriers for code cache unloading (recently
// used heuristics) and, if it's a SATB GC, to keep alive constant objects
// of nmethods because they are weakly referenced.
// The GC needs nmethod entry barriers to deal with continuations
// and code cache unloading
return new BarrierSetNMethod();
Expand Down

1 comment on commit d15285f

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.