Skip to content

Commit a96012f

Browse files
committed
8269803: G1: remove unnecessary NoRefDiscovery
Reviewed-by: tschatzl, kbarrett
1 parent 4e18ec2 commit a96012f

File tree

3 files changed

+18
-67
lines changed

3 files changed

+18
-67
lines changed

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

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3019,12 +3019,6 @@ void G1CollectedHeap::do_collection_pause_at_safepoint_helper(double target_paus
30193019
// reference processing currently works in G1.
30203020
_ref_processor_stw->start_discovery(false /* always_clear */);
30213021

3022-
// We want to temporarily turn off discovery by the
3023-
// CM ref processor, if necessary, and turn it back on
3024-
// on again later if we do. Using a scoped
3025-
// NoRefDiscovery object will do this.
3026-
NoRefDiscovery no_cm_discovery(_ref_processor_cm);
3027-
30283022
policy()->record_collection_pause_start(sample_start_time_sec);
30293023

30303024
// Forget the current allocation region (we might even choose it to be part

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

Lines changed: 18 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -923,52 +923,30 @@ class G1CollectedHeap : public CollectedHeap {
923923

924924
// ("Weak") Reference processing support.
925925
//
926-
// G1 has 2 instances of the reference processor class. One
927-
// (_ref_processor_cm) handles reference object discovery
928-
// and subsequent processing during concurrent marking cycles.
926+
// G1 has 2 instances of the reference processor class.
929927
//
930-
// The other (_ref_processor_stw) handles reference object
931-
// discovery and processing during full GCs and incremental
932-
// evacuation pauses.
928+
// One (_ref_processor_cm) handles reference object discovery and subsequent
929+
// processing during concurrent marking cycles. Discovery is enabled/disabled
930+
// at the start/end of a concurrent marking cycle.
933931
//
934-
// During an incremental pause, reference discovery will be
935-
// temporarily disabled for _ref_processor_cm and will be
936-
// enabled for _ref_processor_stw. At the end of the evacuation
937-
// pause references discovered by _ref_processor_stw will be
938-
// processed and discovery will be disabled. The previous
939-
// setting for reference object discovery for _ref_processor_cm
940-
// will be re-instated.
932+
// The other (_ref_processor_stw) handles reference object discovery and
933+
// processing during incremental evacuation pauses and full GC pauses.
941934
//
942-
// At the start of marking:
943-
// * Discovery by the CM ref processor is verified to be inactive
944-
// and it's discovered lists are empty.
945-
// * Discovery by the CM ref processor is then enabled.
935+
// ## Incremental evacuation pauses
946936
//
947-
// At the end of marking:
948-
// * Any references on the CM ref processor's discovered
949-
// lists are processed (possibly MT).
937+
// STW ref processor discovery is enabled/disabled at the start/end of an
938+
// incremental evacuation pause. No particular handling of the CM ref
939+
// processor is needed, apart from treating the discovered references as
940+
// roots; CM discovery does not need to be temporarily disabled as all
941+
// marking threads are paused during incremental evacuation pauses.
950942
//
951-
// At the start of full GC we:
952-
// * Disable discovery by the CM ref processor and
953-
// empty CM ref processor's discovered lists
954-
// (without processing any entries).
955-
// * Verify that the STW ref processor is inactive and it's
956-
// discovered lists are empty.
957-
// * Temporarily set STW ref processor discovery as single threaded.
958-
// * Temporarily clear the STW ref processor's _is_alive_non_header
959-
// field.
960-
// * Finally enable discovery by the STW ref processor.
943+
// ## Full GC pauses
961944
//
962-
// The STW ref processor is used to record any discovered
963-
// references during the full GC.
964-
//
965-
// At the end of a full GC we:
966-
// * Enqueue any reference objects discovered by the STW ref processor
967-
// that have non-live referents. This has the side-effect of
968-
// making the STW ref processor inactive by disabling discovery.
969-
// * Verify that the CM ref processor is still inactive
970-
// and no references have been placed on it's discovered
971-
// lists (also checked as a precondition during concurrent start).
945+
// We abort any ongoing concurrent marking cycle, disable CM discovery, and
946+
// temporarily substitute a new closure for the STW ref processor's
947+
// _is_alive_non_header field (old value is restored after the full GC). Then
948+
// STW ref processor discovery is enabled, and marking & compaction
949+
// commences.
972950

973951
// The (stw) reference processor...
974952
ReferenceProcessor* _ref_processor_stw;

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

Lines changed: 0 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -456,27 +456,6 @@ class SpanSubjectToDiscoveryClosure : public BoolObjectClosure {
456456
}
457457
};
458458

459-
// A utility class to disable reference discovery in
460-
// the scope which contains it, for given ReferenceProcessor.
461-
class NoRefDiscovery: StackObj {
462-
private:
463-
ReferenceProcessor* _rp;
464-
bool _was_discovering_refs;
465-
public:
466-
NoRefDiscovery(ReferenceProcessor* rp) : _rp(rp) {
467-
_was_discovering_refs = _rp->discovery_enabled();
468-
if (_was_discovering_refs) {
469-
_rp->disable_discovery();
470-
}
471-
}
472-
473-
~NoRefDiscovery() {
474-
if (_was_discovering_refs) {
475-
_rp->enable_discovery(false /*check_no_refs*/);
476-
}
477-
}
478-
};
479-
480459
// A utility class to temporarily mutate the subject discovery closure of the
481460
// given ReferenceProcessor in the scope that contains it.
482461
class ReferenceProcessorSubjectToDiscoveryMutator : StackObj {

0 commit comments

Comments
 (0)