Skip to content

Commit 89b7d07

Browse files
committedMay 8, 2023
8307100: Remove ReferentBasedDiscovery reference discovery policy
Reviewed-by: kbarrett, dholmes, tschatzl
1 parent f6ea897 commit 89b7d07

File tree

6 files changed

+19
-85
lines changed

6 files changed

+19
-85
lines changed
 

‎src/hotspot/share/gc/g1/g1ConcurrentMark.inline.hpp

+2-7
Original file line numberDiff line numberDiff line change
@@ -59,14 +59,9 @@ inline bool G1CMIsAliveClosure::do_object_b(oop obj) {
5959
}
6060

6161
inline bool G1CMSubjectToDiscoveryClosure::do_object_b(oop obj) {
62-
// Re-check whether the passed object is null. With ReferentBasedDiscovery the
63-
// mutator may have changed the referent's value (i.e. cleared it) between the
64-
// time the referent was determined to be potentially alive and calling this
65-
// method.
66-
if (obj == nullptr) {
67-
return false;
68-
}
62+
assert(obj != nullptr, "precondition");
6963
assert(_g1h->is_in_reserved(obj), "Trying to discover obj " PTR_FORMAT " not in heap", p2i(obj));
64+
7065
return _g1h->heap_region_containing(obj)->is_old_or_humongous();
7166
}
7267

‎src/hotspot/share/gc/shared/gc_globals.hpp

-6
Original file line numberDiff line numberDiff line change
@@ -216,12 +216,6 @@
216216
constraint(MarkStackSizeConstraintFunc,AfterErgo) \
217217
range(1, (max_jint - 1)) \
218218
\
219-
product(intx, RefDiscoveryPolicy, 0, \
220-
"Select type of reference discovery policy: " \
221-
"reference-based(0) or referent-based(1)") \
222-
range(ReferenceProcessor::DiscoveryPolicyMin, \
223-
ReferenceProcessor::DiscoveryPolicyMax) \
224-
\
225219
product(bool, ParallelRefProcEnabled, false, \
226220
"Enable parallel reference processing whenever possible") \
227221
\

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

+16-60
Original file line numberDiff line numberDiff line change
@@ -67,9 +67,6 @@ void ReferenceProcessor::init_statics() {
6767
} else {
6868
_default_soft_ref_policy = new LRUCurrentHeapPolicy();
6969
}
70-
guarantee(RefDiscoveryPolicy == ReferenceBasedDiscovery ||
71-
RefDiscoveryPolicy == ReferentBasedDiscovery,
72-
"Unrecognized RefDiscoveryPolicy");
7370
}
7471

7572
void ReferenceProcessor::enable_discovery() {
@@ -921,32 +918,16 @@ bool ReferenceProcessor::is_subject_to_discovery(oop const obj) const {
921918
return _is_subject_to_discovery->do_object_b(obj);
922919
}
923920

924-
// We mention two of several possible choices here:
925-
// #0: if the reference object is not in the "originating generation"
926-
// (or part of the heap being collected, indicated by our "span")
927-
// we don't treat it specially (i.e. we scan it as we would
928-
// a normal oop, treating its references as strong references).
929-
// This means that references can't be discovered unless their
930-
// referent is also in the same span. This is the simplest,
931-
// most "local" and most conservative approach, albeit one
932-
// that may cause weak references to be enqueued least promptly.
933-
// We call this choice the "ReferenceBasedDiscovery" policy.
934-
// #1: the reference object may be in any generation (span), but if
935-
// the referent is in the generation (span) being currently collected
936-
// then we can discover the reference object, provided
937-
// the object has not already been discovered by
938-
// a different concurrently running discoverer (as may be the
939-
// case, for instance, if the reference object is in G1 old gen and
940-
// the referent in G1 young gen), and provided the processing
941-
// of this reference object by the current collector will
942-
// appear atomically to every other discoverer in the system.
943-
// (Thus, for instance, a concurrent discoverer may not
944-
// discover references in other generations even if the
945-
// referent is in its own generation). This policy may,
946-
// in certain cases, enqueue references somewhat sooner than
947-
// might Policy #0 above, but at marginally increased cost
948-
// and complexity in processing these references.
949-
// We call this choice the "ReferentBasedDiscovery" policy.
921+
// Reference discovery policy:
922+
// if the reference object is not in the "originating generation"
923+
// (or part of the heap being collected, indicated by our "span")
924+
// we don't treat it specially (i.e. we scan it as we would
925+
// a normal oop, treating its references as strong references).
926+
// This means that references can't be discovered unless their
927+
// referent is also in the same span. This is the simplest,
928+
// most "local" and most conservative approach, albeit one
929+
// that may cause weak references to be enqueued least promptly.
930+
// We call this choice the "ReferenceBasedDiscovery" policy.
950931
bool ReferenceProcessor::discover_reference(oop obj, ReferenceType rt) {
951932
// Make sure we are discovering refs (rather than processing discovered refs).
952933
if (!_discovering_refs || !RegisterReferences) {
@@ -958,8 +939,7 @@ bool ReferenceProcessor::discover_reference(oop obj, ReferenceType rt) {
958939
return false;
959940
}
960941

961-
if (RefDiscoveryPolicy == ReferenceBasedDiscovery &&
962-
!is_subject_to_discovery(obj)) {
942+
if (!is_subject_to_discovery(obj)) {
963943
// Reference is not in the originating generation;
964944
// don't treat it specially (i.e. we want to scan it as a normal
965945
// object with strong references).
@@ -997,36 +977,12 @@ bool ReferenceProcessor::discover_reference(oop obj, ReferenceType rt) {
997977
// The reference has already been discovered...
998978
log_develop_trace(gc, ref)("Already discovered reference (" PTR_FORMAT ": %s)",
999979
p2i(obj), obj->klass()->internal_name());
1000-
if (RefDiscoveryPolicy == ReferentBasedDiscovery) {
1001-
// assumes that an object is not processed twice;
1002-
// if it's been already discovered it must be on another
1003-
// generation's discovered list; so we won't discover it.
1004-
return false;
1005-
} else {
1006-
assert(RefDiscoveryPolicy == ReferenceBasedDiscovery,
1007-
"Unrecognized policy");
1008-
// Check assumption that an object is not potentially
1009-
// discovered twice except by concurrent collectors that potentially
1010-
// trace the same Reference object twice.
1011-
assert(UseG1GC, "Only possible with a concurrent marking collector");
1012-
return true;
1013-
}
1014-
}
1015980

1016-
if (RefDiscoveryPolicy == ReferentBasedDiscovery) {
1017-
verify_referent(obj);
1018-
// Discover if and only if EITHER:
1019-
// .. reference is in our span, OR
1020-
// .. we are a stw discoverer and referent is in our span
1021-
if (is_subject_to_discovery(obj) ||
1022-
(discovery_is_stw() &&
1023-
is_subject_to_discovery(java_lang_ref_Reference::unknown_referent_no_keepalive(obj)))) {
1024-
} else {
1025-
return false;
1026-
}
1027-
} else {
1028-
assert(RefDiscoveryPolicy == ReferenceBasedDiscovery &&
1029-
is_subject_to_discovery(obj), "code inconsistency");
981+
// Check assumption that an object is not potentially
982+
// discovered twice except by concurrent collectors that potentially
983+
// trace the same Reference object twice.
984+
assert(UseG1GC, "Only possible with a concurrent marking collector");
985+
return true;
1030986
}
1031987

1032988
// Get the right type of discovered queue head.

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

-8
Original file line numberDiff line numberDiff line change
@@ -378,14 +378,6 @@ class ReferenceProcessor : public ReferenceDiscoverer {
378378
bool concurrent_discovery = false,
379379
BoolObjectClosure* is_alive_non_header = nullptr);
380380

381-
// RefDiscoveryPolicy values
382-
enum DiscoveryPolicy {
383-
ReferenceBasedDiscovery = 0,
384-
ReferentBasedDiscovery = 1,
385-
DiscoveryPolicyMin = ReferenceBasedDiscovery,
386-
DiscoveryPolicyMax = ReferentBasedDiscovery
387-
};
388-
389381
static void init_statics();
390382

391383
// get and set "is_alive_non_header" field

‎src/hotspot/share/runtime/arguments.cpp

+1
Original file line numberDiff line numberDiff line change
@@ -523,6 +523,7 @@ static SpecialFlag const special_jvm_flags[] = {
523523
{ "G1UsePreventiveGC", JDK_Version::undefined(), JDK_Version::jdk(21), JDK_Version::jdk(22) },
524524
{ "G1ConcRSLogCacheSize", JDK_Version::undefined(), JDK_Version::jdk(21), JDK_Version::undefined() },
525525
{ "G1ConcRSHotCardLimit", JDK_Version::undefined(), JDK_Version::jdk(21), JDK_Version::undefined() },
526+
{ "RefDiscoveryPolicy", JDK_Version::undefined(), JDK_Version::jdk(21), JDK_Version::undefined() },
526527
{ "MetaspaceReclaimPolicy", JDK_Version::undefined(), JDK_Version::jdk(21), JDK_Version::undefined() },
527528

528529
#ifdef ASSERT

‎test/hotspot/gtest/runtime/test_globals.cpp

-4
Original file line numberDiff line numberDiff line change
@@ -50,10 +50,6 @@ TEST_VM(FlagGuard, int_flag) {
5050
TEST_FLAG(ParGCArrayScanChunk, int, 1337);
5151
}
5252

53-
TEST_VM(FlagGuard, intx_flag) {
54-
TEST_FLAG(RefDiscoveryPolicy, intx, 1337);
55-
}
56-
5753
TEST_VM(FlagGuard, uint_flag) {
5854
TEST_FLAG(ConcGCThreads, uint, 1337);
5955
}

1 commit comments

Comments
 (1)

openjdk-notifier[bot] commented on May 8, 2023

@openjdk-notifier[bot]
Please sign in to comment.