Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

8269803: G1: remove unnecessary NoRefDiscovery #4664

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 0 additions & 6 deletions src/hotspot/share/gc/g1/g1CollectedHeap.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2992,12 +2992,6 @@ void G1CollectedHeap::do_collection_pause_at_safepoint_helper(double target_paus
// reference processing currently works in G1.
_ref_processor_stw->start_discovery(false /* always_clear */);

// We want to temporarily turn off discovery by the
// CM ref processor, if necessary, and turn it back on
// on again later if we do. Using a scoped
// NoRefDiscovery object will do this.
NoRefDiscovery no_cm_discovery(_ref_processor_cm);

policy()->record_collection_pause_start(sample_start_time_sec);

// Forget the current allocation region (we might even choose it to be part
Expand Down
58 changes: 18 additions & 40 deletions src/hotspot/share/gc/g1/g1CollectedHeap.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -928,52 +928,30 @@ class G1CollectedHeap : public CollectedHeap {

// ("Weak") Reference processing support.
//
// G1 has 2 instances of the reference processor class. One
// (_ref_processor_cm) handles reference object discovery
// and subsequent processing during concurrent marking cycles.
// G1 has 2 instances of the reference processor class.
//
// The other (_ref_processor_stw) handles reference object
// discovery and processing during full GCs and incremental
// evacuation pauses.
// One (_ref_processor_cm) handles reference object discovery and subsequent
// processing during concurrent marking cycles. Discovery is enabled/disabled
// at the start/end of a concurrent marking cycle.
//
// During an incremental pause, reference discovery will be
// temporarily disabled for _ref_processor_cm and will be
// enabled for _ref_processor_stw. At the end of the evacuation
// pause references discovered by _ref_processor_stw will be
// processed and discovery will be disabled. The previous
// setting for reference object discovery for _ref_processor_cm
// will be re-instated.
// The other (_ref_processor_stw) handles reference object discovery and
// processing during incremental evacuation pauses and full GC pauses.
//
// At the start of marking:
// * Discovery by the CM ref processor is verified to be inactive
// and it's discovered lists are empty.
// * Discovery by the CM ref processor is then enabled.
// ## Incremental evacuation pauses
//
// At the end of marking:
// * Any references on the CM ref processor's discovered
// lists are processed (possibly MT).
// STW ref processor discovery is enabled/disabled at the start/end of an
// incremental evacuation pause. No particular handling of the CM ref
// processor is needed, apart from treating the discovered references as
// roots; CM discovery does not need to be temporarily disabled as all
// marking threads are paused during incremental evacuation pauses.
//
// At the start of full GC we:
// * Disable discovery by the CM ref processor and
// empty CM ref processor's discovered lists
// (without processing any entries).
// * Verify that the STW ref processor is inactive and it's
// discovered lists are empty.
// * Temporarily set STW ref processor discovery as single threaded.
// * Temporarily clear the STW ref processor's _is_alive_non_header
// field.
// * Finally enable discovery by the STW ref processor.
// ## Full GC pauses
//
// The STW ref processor is used to record any discovered
// references during the full GC.
//
// At the end of a full GC we:
// * Enqueue any reference objects discovered by the STW ref processor
// that have non-live referents. This has the side-effect of
// making the STW ref processor inactive by disabling discovery.
// * Verify that the CM ref processor is still inactive
// and no references have been placed on it's discovered
// lists (also checked as a precondition during concurrent start).
// We abort any ongoing concurrent marking cycle, disable CM discovery, and
// temporarily substitute a new closure for the STW ref processor's
// _is_alive_non_header field (old value is restored after the full GC). Then
// STW ref processor discovery is enabled, and marking & compaction
// commences.

// The (stw) reference processor...
ReferenceProcessor* _ref_processor_stw;
Expand Down
21 changes: 0 additions & 21 deletions src/hotspot/share/gc/shared/referenceProcessor.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -456,27 +456,6 @@ class SpanSubjectToDiscoveryClosure : public BoolObjectClosure {
}
};

// A utility class to disable reference discovery in
// the scope which contains it, for given ReferenceProcessor.
class NoRefDiscovery: StackObj {
private:
ReferenceProcessor* _rp;
bool _was_discovering_refs;
public:
NoRefDiscovery(ReferenceProcessor* rp) : _rp(rp) {
_was_discovering_refs = _rp->discovery_enabled();
if (_was_discovering_refs) {
_rp->disable_discovery();
}
}

~NoRefDiscovery() {
if (_was_discovering_refs) {
_rp->enable_discovery(false /*check_no_refs*/);
}
}
};

// A utility class to temporarily mutate the subject discovery closure of the
// given ReferenceProcessor in the scope that contains it.
class ReferenceProcessorSubjectToDiscoveryMutator : StackObj {
Expand Down