@@ -67,9 +67,6 @@ void ReferenceProcessor::init_statics() {
67
67
} else {
68
68
_default_soft_ref_policy = new LRUCurrentHeapPolicy ();
69
69
}
70
- guarantee (RefDiscoveryPolicy == ReferenceBasedDiscovery ||
71
- RefDiscoveryPolicy == ReferentBasedDiscovery,
72
- " Unrecognized RefDiscoveryPolicy" );
73
70
}
74
71
75
72
void ReferenceProcessor::enable_discovery () {
@@ -921,32 +918,16 @@ bool ReferenceProcessor::is_subject_to_discovery(oop const obj) const {
921
918
return _is_subject_to_discovery->do_object_b (obj);
922
919
}
923
920
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.
950
931
bool ReferenceProcessor::discover_reference (oop obj, ReferenceType rt) {
951
932
// Make sure we are discovering refs (rather than processing discovered refs).
952
933
if (!_discovering_refs || !RegisterReferences) {
@@ -958,8 +939,7 @@ bool ReferenceProcessor::discover_reference(oop obj, ReferenceType rt) {
958
939
return false ;
959
940
}
960
941
961
- if (RefDiscoveryPolicy == ReferenceBasedDiscovery &&
962
- !is_subject_to_discovery (obj)) {
942
+ if (!is_subject_to_discovery (obj)) {
963
943
// Reference is not in the originating generation;
964
944
// don't treat it specially (i.e. we want to scan it as a normal
965
945
// object with strong references).
@@ -997,36 +977,12 @@ bool ReferenceProcessor::discover_reference(oop obj, ReferenceType rt) {
997
977
// The reference has already been discovered...
998
978
log_develop_trace (gc, ref)(" Already discovered reference (" PTR_FORMAT " : %s)" ,
999
979
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
- }
1015
980
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 ;
1030
986
}
1031
987
1032
988
// Get the right type of discovered queue head.
1 commit comments
openjdk-notifier[bot] commentedon May 8, 2023
Review
Issues