Skip to content

Commit e680503

Browse files
author
Thomas Schatzl
committed
8273185: Rename the term "atomic" in ReferenceProcessor
Reviewed-by: ayang, shade
1 parent ba31eee commit e680503

4 files changed

Lines changed: 34 additions & 35 deletions

File tree

src/hotspot/share/gc/g1/g1CollectedHeap.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1833,7 +1833,7 @@ void G1CollectedHeap::ref_processing_init() {
18331833
// thread counts must be considered for discovery.
18341834
(ParallelGCThreads > 1) || (ConcGCThreads > 1), // mt discovery
18351835
MAX2(ParallelGCThreads, ConcGCThreads), // degree of mt discovery
1836-
false, // Reference discovery is not atomic
1836+
true, // Reference discovery is concurrent
18371837
&_is_alive_closure_cm); // is alive closure
18381838

18391839
// STW ref processor
@@ -1842,7 +1842,7 @@ void G1CollectedHeap::ref_processing_init() {
18421842
ParallelGCThreads, // degree of mt processing
18431843
(ParallelGCThreads > 1), // mt discovery
18441844
ParallelGCThreads, // degree of mt discovery
1845-
true, // Reference discovery is atomic
1845+
false, // Reference discovery is not concurrent
18461846
&_is_alive_closure_stw); // is alive closure
18471847
}
18481848

src/hotspot/share/gc/parallel/psScavenge.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -801,7 +801,7 @@ void PSScavenge::initialize() {
801801
ParallelGCThreads, // mt processing degree
802802
true, // mt discovery
803803
ParallelGCThreads, // mt discovery degree
804-
true, // atomic_discovery
804+
false, // concurrent_discovery
805805
NULL); // header provides liveness info
806806

807807
// Cache the cardtable

src/hotspot/share/gc/shared/referenceProcessor.cpp

Lines changed: 25 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ ReferenceProcessor::ReferenceProcessor(BoolObjectClosure* is_subject_to_discover
8888
uint mt_processing_degree,
8989
bool mt_discovery,
9090
uint mt_discovery_degree,
91-
bool atomic_discovery,
91+
bool concurrent_discovery,
9292
BoolObjectClosure* is_alive_non_header) :
9393
_is_subject_to_discovery(is_subject_to_discovery),
9494
_discovering_refs(false),
@@ -97,11 +97,11 @@ ReferenceProcessor::ReferenceProcessor(BoolObjectClosure* is_subject_to_discover
9797
{
9898
assert(is_subject_to_discovery != NULL, "must be set");
9999

100-
_discovery_is_atomic = atomic_discovery;
101-
_discovery_is_mt = mt_discovery;
102-
_num_queues = MAX2(1U, mt_processing_degree);
103-
_max_num_queues = MAX2(_num_queues, mt_discovery_degree);
104-
_discovered_refs = NEW_C_HEAP_ARRAY(DiscoveredList,
100+
_discovery_is_concurrent = concurrent_discovery;
101+
_discovery_is_mt = mt_discovery;
102+
_num_queues = MAX2(1U, mt_processing_degree);
103+
_max_num_queues = MAX2(_num_queues, mt_discovery_degree);
104+
_discovered_refs = NEW_C_HEAP_ARRAY(DiscoveredList,
105105
_max_num_queues * number_of_subclasses_of_ref(), mtGC);
106106

107107
_discoveredSoftRefs = &_discovered_refs[0];
@@ -310,10 +310,10 @@ size_t ReferenceProcessor::process_discovered_list_work(DiscoveredList& refs_
310310
bool do_enqueue_and_clear) {
311311
DiscoveredListIterator iter(refs_list, keep_alive, is_alive);
312312
while (iter.has_next()) {
313-
iter.load_ptrs(DEBUG_ONLY(!discovery_is_atomic() /* allow_null_referent */));
313+
iter.load_ptrs(DEBUG_ONLY(discovery_is_concurrent() /* allow_null_referent */));
314314
if (iter.referent() == NULL) {
315315
// Reference has been cleared since discovery; only possible if
316-
// discovery is not atomic (checked by load_ptrs). Remove
316+
// discovery is concurrent (checked by load_ptrs). Remove
317317
// reference from list.
318318
log_dropped_ref(iter, "cleared");
319319
iter.remove();
@@ -866,7 +866,7 @@ inline bool ReferenceProcessor::set_discovered_link_st(HeapWord* discovered_addr
866866
oop next_discovered) {
867867
assert(!discovery_is_mt(), "must be");
868868

869-
if (discovery_is_atomic()) {
869+
if (discovery_is_stw()) {
870870
// Do a raw store here: the field will be visited later when processing
871871
// the discovered references.
872872
RawAccess<>::oop_store(discovered_addr, next_discovered);
@@ -883,7 +883,7 @@ inline bool ReferenceProcessor::set_discovered_link_mt(HeapWord* discovered_addr
883883

884884
// We must make sure this object is only enqueued once. Try to CAS into the discovered_addr.
885885
oop retest;
886-
if (discovery_is_atomic()) {
886+
if (discovery_is_stw()) {
887887
// Try a raw store here, still making sure that we enqueue only once: the field
888888
// will be visited later when processing the discovered references.
889889
retest = RawAccess<>::oop_atomic_cmpxchg(discovered_addr, oop(NULL), next_discovered);
@@ -894,16 +894,15 @@ inline bool ReferenceProcessor::set_discovered_link_mt(HeapWord* discovered_addr
894894
}
895895

896896
#ifndef PRODUCT
897-
// Non-atomic (i.e. concurrent) discovery might allow us
898-
// to observe j.l.References with NULL referents, being those
899-
// cleared concurrently by mutators during (or after) discovery.
897+
// Concurrent discovery might allow us to observe j.l.References with NULL
898+
// referents, being those cleared concurrently by mutators during (or after) discovery.
900899
void ReferenceProcessor::verify_referent(oop obj) {
901-
bool da = discovery_is_atomic();
900+
bool concurrent = discovery_is_concurrent();
902901
oop referent = java_lang_ref_Reference::unknown_referent_no_keepalive(obj);
903-
assert(da ? oopDesc::is_oop(referent) : oopDesc::is_oop_or_null(referent),
902+
assert(concurrent ? oopDesc::is_oop_or_null(referent) : oopDesc::is_oop(referent),
904903
"Bad referent " INTPTR_FORMAT " found in Reference "
905-
INTPTR_FORMAT " during %satomic discovery ",
906-
p2i(referent), p2i(obj), da ? "" : "non-");
904+
INTPTR_FORMAT " during %sconcurrent discovery ",
905+
p2i(referent), p2i(obj), concurrent ? "" : "non-");
907906
}
908907
#endif
909908

@@ -913,7 +912,7 @@ bool ReferenceProcessor::is_subject_to_discovery(oop const obj) const {
913912

914913
// We mention two of several possible choices here:
915914
// #0: if the reference object is not in the "originating generation"
916-
// (or part of the heap being collected, indicated by our "span"
915+
// (or part of the heap being collected, indicated by our "span")
917916
// we don't treat it specially (i.e. we scan it as we would
918917
// a normal oop, treating its references as strong references).
919918
// This means that references can't be discovered unless their
@@ -925,18 +924,18 @@ bool ReferenceProcessor::is_subject_to_discovery(oop const obj) const {
925924
// the referent is in the generation (span) being currently collected
926925
// then we can discover the reference object, provided
927926
// the object has not already been discovered by
928-
// a different concurrently running collector (as may be the
929-
// case, for instance, if the reference object is in CMS and
930-
// the referent in DefNewGeneration), and provided the processing
927+
// a different concurrently running discoverer (as may be the
928+
// case, for instance, if the reference object is in G1 old gen and
929+
// the referent in G1 young gen), and provided the processing
931930
// of this reference object by the current collector will
932-
// appear atomic to every other collector in the system.
933-
// (Thus, for instance, a concurrent collector may not
931+
// appear atomically to every other discoverer in the system.
932+
// (Thus, for instance, a concurrent discoverer may not
934933
// discover references in other generations even if the
935934
// referent is in its own generation). This policy may,
936935
// in certain cases, enqueue references somewhat sooner than
937936
// might Policy #0 above, but at marginally increased cost
938937
// and complexity in processing these references.
939-
// We call this choice the "RefeferentBasedDiscovery" policy.
938+
// We call this choice the "ReferentBasedDiscovery" policy.
940939
bool ReferenceProcessor::discover_reference(oop obj, ReferenceType rt) {
941940
// Make sure we are discovering refs (rather than processing discovered refs).
942941
if (!_discovering_refs || !RegisterReferences) {
@@ -1007,9 +1006,9 @@ bool ReferenceProcessor::discover_reference(oop obj, ReferenceType rt) {
10071006
verify_referent(obj);
10081007
// Discover if and only if EITHER:
10091008
// .. reference is in our span, OR
1010-
// .. we are an atomic collector and referent is in our span
1009+
// .. we are a stw discoverer and referent is in our span
10111010
if (is_subject_to_discovery(obj) ||
1012-
(discovery_is_atomic() &&
1011+
(discovery_is_stw() &&
10131012
is_subject_to_discovery(java_lang_ref_Reference::unknown_referent_no_keepalive(obj)))) {
10141013
} else {
10151014
return false;

src/hotspot/share/gc/shared/referenceProcessor.hpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -195,8 +195,7 @@ class ReferenceProcessor : public ReferenceDiscoverer {
195195
// (and further processing).
196196

197197
bool _discovering_refs; // true when discovery enabled
198-
bool _discovery_is_atomic; // if discovery is atomic wrt
199-
// other collectors in configuration
198+
bool _discovery_is_concurrent; // if discovery is concurrent to the mutator
200199
bool _discovery_is_mt; // true if reference discovery is MT.
201200

202201
uint _next_id; // round-robin mod _num_queues counter in
@@ -251,7 +250,7 @@ class ReferenceProcessor : public ReferenceDiscoverer {
251250
// removed elements.
252251

253252
// Traverse the list and remove any Refs whose referents are alive,
254-
// or NULL if discovery is not atomic. Enqueue and clear the reference for
253+
// or NULL if discovery is concurrent. Enqueue and clear the reference for
255254
// others if do_enqueue_and_clear is set.
256255
size_t process_discovered_list_work(DiscoveredList& refs_list,
257256
BoolObjectClosure* is_alive,
@@ -352,7 +351,7 @@ class ReferenceProcessor : public ReferenceDiscoverer {
352351
ReferenceProcessor(BoolObjectClosure* is_subject_to_discovery,
353352
uint mt_processing_degree = 1,
354353
bool mt_discovery = false, uint mt_discovery_degree = 1,
355-
bool atomic_discovery = true,
354+
bool concurrent_discovery = false,
356355
BoolObjectClosure* is_alive_non_header = NULL);
357356

358357
// RefDiscoveryPolicy values
@@ -381,8 +380,9 @@ class ReferenceProcessor : public ReferenceDiscoverer {
381380
void disable_discovery() { _discovering_refs = false; }
382381
bool discovery_enabled() { return _discovering_refs; }
383382

384-
// whether discovery is atomic wrt other collectors
385-
bool discovery_is_atomic() const { return _discovery_is_atomic; }
383+
// whether discovery is concurrent to the mutator, or done in an stw pause.
384+
bool discovery_is_concurrent() const { return _discovery_is_concurrent; }
385+
bool discovery_is_stw() const { return !discovery_is_concurrent(); }
386386

387387
// whether discovery is done by multiple threads same-old-timeously
388388
bool discovery_is_mt() const { return _discovery_is_mt; }

0 commit comments

Comments
 (0)