Skip to content

Commit c607d12

Browse files
committedApr 19, 2021
8249528: Remove obsolete comment in G1RootProcessor::process_java_roots
Reviewed-by: tschatzl, sangheki
1 parent fa58aae commit c607d12

File tree

5 files changed

+29
-23
lines changed

5 files changed

+29
-23
lines changed
 

‎src/hotspot/share/code/nmethod.hpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ class nmethod : public CompiledMethod {
7979
// STW two-phase nmethod root processing helpers.
8080
//
8181
// When determining liveness of a given nmethod to do code cache unloading,
82-
// some collectors need to to different things depending on whether the nmethods
82+
// some collectors need to do different things depending on whether the nmethods
8383
// need to absolutely be kept alive during root processing; "strong"ly reachable
8484
// nmethods are known to be kept alive at root processing, but the liveness of
8585
// "weak"ly reachable ones is to be determined later.

‎src/hotspot/share/gc/g1/g1CodeBlobClosure.hpp

-4
Original file line numberDiff line numberDiff line change
@@ -71,10 +71,6 @@ class G1CodeBlobClosure : public CodeBlobClosure {
7171
MarkingOopClosure _marking_oc;
7272

7373
bool _strong;
74-
75-
void do_code_blob_weak(CodeBlob* cb);
76-
void do_code_blob_strong(CodeBlob* cb);
77-
7874
public:
7975
G1CodeBlobClosure(uint worker_id, OopClosure* oc, bool strong) :
8076
_oc(oc), _marking_oc(worker_id), _strong(strong) { }

‎src/hotspot/share/gc/g1/g1OopClosures.hpp

-1
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,6 @@ class G1ParCopyHelper : public OopClosure {
141141
inline void mark_object(oop obj);
142142

143143
G1ParCopyHelper(G1CollectedHeap* g1h, G1ParScanThreadState* par_scan_state);
144-
~G1ParCopyHelper() { }
145144

146145
public:
147146
void set_scanned_cld(ClassLoaderData* cld) { _scanned_cld = cld; }

‎src/hotspot/share/gc/g1/g1RootClosures.hpp

+1-3
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,7 @@ class G1ParScanThreadState;
3333

3434
class G1RootClosures : public CHeapObj<mtGC> {
3535
public:
36-
virtual ~G1RootClosures() {}
37-
38-
// Closures to process raw oops in the root set.
36+
// Closures to process raw oops in the root set.
3937
virtual OopClosure* weak_oops() = 0;
4038
virtual OopClosure* strong_oops() = 0;
4139

‎src/hotspot/share/gc/g1/g1RootProcessor.cpp

+27-14
Original file line numberDiff line numberDiff line change
@@ -149,22 +149,35 @@ void G1RootProcessor::process_all_roots(OopClosure* oops,
149149
void G1RootProcessor::process_java_roots(G1RootClosures* closures,
150150
G1GCPhaseTimes* phase_times,
151151
uint worker_id) {
152-
// We need to make make sure that the "strong" nmethods are processed first
153-
// using the strong closure. Only after that we process the weakly reachable
154-
// nmethods.
155-
// We need to strictly separate the strong and weak nmethod processing because
156-
// any processing claims that nmethod, i.e. will not be iterated again.
157-
// Which means if an nmethod is processed first and claimed, the strong processing
158-
// will not happen, and the oops reachable by that nmethod will not be marked
159-
// properly.
152+
// In the concurrent start pause, when class unloading is enabled, G1
153+
// processes nmethods in two ways, as "strong" and "weak" nmethods.
160154
//
161-
// That is why we process strong nmethods first, synchronize all threads via a
162-
// barrier, and only then allow weak processing. To minimize the wait time at
163-
// that barrier we do the strong nmethod processing first, and immediately after-
164-
// wards indicate that that thread is done. Hopefully other root processing after
165-
// nmethod processing is enough so there is no need to wait.
155+
// 1) Strong nmethods are reachable from the thread stack frames. G1 applies
156+
// the G1RootClosures::strong_codeblobs() closure on them. The closure
157+
// iterates over all oops embedded inside each nmethod, and performs 3
158+
// operations:
159+
// a) evacuates; relocate objects outside of collection set
160+
// b) fixes up; remap oops to reflect new addresses
161+
// c) mark; mark object alive
162+
// This keeps these oops alive wrt. to the upcoming marking phase, and their
163+
// classes will not be unloaded.
166164
//
167-
// This is only required in the concurrent start pause with class unloading enabled.
165+
// 2) Weak nmethods are reachable only from the code root remembered set (see
166+
// G1CodeRootSet). G1 applies the G1RootClosures::weak_codeblobs() closure on
167+
// them. The closure iterates over all oops embedded inside each nmethod, and
168+
// performs 2 operations: a) and b).
169+
// Since these oops are *not* marked, their classes can potentially be
170+
// unloaded.
171+
//
172+
// G1 doesn't segregate strong/weak nmethods processing (finish processing
173+
// all strong nmethods before starting with any weak nmethods, or vice
174+
// versa), as that could lead to poor CPU utilization (a single slow thread
175+
// prevents all other thread from crossing the synchronization barrier).
176+
// Instead, G1 interleaves strong and weak nmethods processing via
177+
// per-nmethod synchronization. A nmethod is either *strongly* or *weakly*
178+
// claimed before processing. A weakly claimed nmethod could be strongly
179+
// claimed again for performing marking (the c) operation above); see
180+
// oops_do_process_weak and oops_do_process_strong in nmethod.hpp
168181
{
169182
G1GCParPhaseTimesTracker x(phase_times, G1GCPhaseTimes::ThreadRoots, worker_id);
170183
bool is_par = n_workers() > 1;

0 commit comments

Comments
 (0)
Please sign in to comment.