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

8269596: Snapshot soft ref policy before marking/copying #4624

Closed
wants to merge 3 commits into from
Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
@@ -2990,8 +2990,7 @@ void G1CollectedHeap::do_collection_pause_at_safepoint_helper(double target_paus
// Please see comment in g1CollectedHeap.hpp and
// G1CollectedHeap::ref_processing_init() to see how
// reference processing currently works in G1.
_ref_processor_stw->enable_discovery();
_ref_processor_stw->setup_policy(false);
_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
@@ -716,9 +716,7 @@ void G1ConcurrentMark::pre_concurrent_start(GCCause::Cause cause) {
void G1ConcurrentMark::post_concurrent_mark_start() {
// Start Concurrent Marking weak-reference discovery.
ReferenceProcessor* rp = _g1h->ref_processor_cm();
// enable ("weak") refs discovery
rp->enable_discovery();
rp->setup_policy(false); // snapshot the soft ref policy to be used in this cycle
rp->start_discovery(false /* always_clear */);

SATBMarkQueueSet& satb_mq_set = G1BarrierSet::satb_mark_queue_set();
// This is the start of the marking cycle, we're expected all
@@ -182,8 +182,7 @@ void G1FullCollector::prepare_collection() {
PrepareRegionsClosure cl(this);
_heap->heap_region_iterate(&cl);

reference_processor()->enable_discovery();
reference_processor()->setup_policy(scope()->should_clear_soft_refs());
reference_processor()->start_discovery(scope()->should_clear_soft_refs());

// Clear and activate derived pointer collection.
clear_and_activate_derived_pointers();
@@ -1786,10 +1786,7 @@ bool PSParallelCompact::invoke_no_policy(bool maximum_heap_compaction) {
DerivedPointerTable::clear();
#endif

ref_processor()->enable_discovery();
ref_processor()->setup_policy(maximum_heap_compaction);

bool marked_for_unloading = false;
ref_processor()->start_discovery(maximum_heap_compaction);

marking_start.update();
marking_phase(vmthread_cm, maximum_heap_compaction, &_gc_tracer);
@@ -448,8 +448,7 @@ bool PSScavenge::invoke_no_policy() {
DerivedPointerTable::clear();
#endif

reference_processor()->enable_discovery();
reference_processor()->setup_policy(false);
reference_processor()->start_discovery(false /* always_clear */);

const PreGenGCValues pre_gc_values = heap->get_pre_gc_values();

@@ -478,12 +478,10 @@ void GenCollectedHeap::collect_generation(Generation* gen, bool full, size_t siz
// enqueue_discovered_references if the generation returns
// without doing any work.
ReferenceProcessor* rp = gen->ref_processor();
rp->enable_discovery();
rp->setup_policy(clear_soft_refs);
rp->start_discovery(clear_soft_refs);

gen->collect(full, clear_soft_refs, size, is_tlab);

rp->disable_discovery();
rp->verify_no_references_recorded();
}

@@ -285,18 +285,22 @@ class ReferenceProcessor : public ReferenceDiscoverer {
OopClosure* keep_alive,
VoidClosure* complete_gc);


void setup_policy(bool always_clear) {
_current_soft_ref_policy = always_clear ?
_always_clear_soft_ref_policy : _default_soft_ref_policy;
_current_soft_ref_policy->setup(); // snapshot the policy threshold
}
public:
static int number_of_subclasses_of_ref() { return (REF_PHANTOM - REF_OTHER); }

uint num_queues() const { return _num_queues; }
uint max_num_queues() const { return _max_num_queues; }
void set_active_mt_degree(uint v);

ReferencePolicy* setup_policy(bool always_clear) {
_current_soft_ref_policy = always_clear ?
_always_clear_soft_ref_policy : _default_soft_ref_policy;
_current_soft_ref_policy->setup(); // snapshot the policy threshold
return _current_soft_ref_policy;
void start_discovery(bool always_clear) {
enable_discovery();
setup_policy(always_clear);
}

// "Preclean" all the discovered reference lists by removing references that