8275298: Remove unnecessary weak_oops_do call in adjust weak roots phase

Reviewed-by: tschatzl, sjohanss
This commit is contained in:
Albert Mingkun Yang 2021-10-18 16:02:22 +00:00
parent fb8e5cf4ec
commit 4d383b9fcd
9 changed files with 7 additions and 33 deletions

@ -1645,9 +1645,6 @@ void G1ConcurrentMark::weak_refs_work() {
"Mark stack should be empty (unless it has overflown)");
assert(rp->num_queues() == active_workers, "why not");
rp->verify_no_references_recorded();
assert(!rp->discovery_enabled(), "Post condition");
}
if (has_overflown()) {

@ -81,7 +81,6 @@ class G1AdjustRegionClosure : public HeapRegionClosure {
G1FullGCAdjustTask::G1FullGCAdjustTask(G1FullCollector* collector) :
G1FullGCTask("G1 Adjust", collector),
_root_processor(G1CollectedHeap::heap(), collector->workers()),
_references_done(false),
_weak_proc_task(collector->workers()),
_hrclaimer(collector->workers()),
_adjust(collector) {
@ -97,14 +96,12 @@ void G1FullGCAdjustTask::work(uint worker_id) {
G1FullGCMarker* marker = collector()->marker(worker_id);
marker->preserved_stack()->adjust_during_full_gc();
// Adjust the weak roots.
if (!Atomic::cmpxchg(&_references_done, false, true)) {
G1CollectedHeap::heap()->ref_processor_stw()->weak_oops_do(&_adjust);
{
// Adjust the weak roots.
AlwaysTrueClosure always_alive;
_weak_proc_task.work(worker_id, &always_alive, &_adjust);
}
AlwaysTrueClosure always_alive;
_weak_proc_task.work(worker_id, &always_alive, &_adjust);
CLDToOopClosure adjust_cld(&_adjust, ClassLoaderData::_claim_strong);
CodeBlobToOopClosure adjust_code(&_adjust, CodeBlobToOopClosure::FixRelocations);
_root_processor.process_all_roots(&_adjust, &adjust_cld, &adjust_code);

@ -36,7 +36,6 @@ class G1CollectedHeap;
class G1FullGCAdjustTask : public G1FullGCTask {
G1RootProcessor _root_processor;
volatile bool _references_done;
WeakProcessor::Task _weak_proc_task;
HeapRegionClaimer _hrclaimer;
G1AdjustClosure _adjust;

@ -984,8 +984,6 @@ void G1YoungCollector::process_discovered_references(G1ParScanThreadStateSet* pe
_g1h->make_pending_list_reachable();
rp->verify_no_references_recorded();
phase_times()->record_ref_proc_time((Ticks::now() - start).seconds() * MILLIUNITS);
}

@ -1923,8 +1923,6 @@ bool PSParallelCompact::invoke_no_policy(bool maximum_heap_compaction) {
old_gen->object_space()->check_mangled_unused_area_complete();
}
NOT_PRODUCT(ref_processor()->verify_no_references_recorded());
collection_exit.update();
heap->print_heap_after_gc();
@ -2161,8 +2159,6 @@ class PSAdjustTask final : public WorkerTask {
enum PSAdjustSubTask {
PSAdjustSubTask_code_cache,
PSAdjustSubTask_old_ref_process,
PSAdjustSubTask_young_ref_process,
PSAdjustSubTask_num_elements
};
@ -2204,16 +2200,6 @@ public:
CodeBlobToOopClosure adjust_code(&adjust, CodeBlobToOopClosure::FixRelocations);
CodeCache::blobs_do(&adjust_code);
}
if (_sub_tasks.try_claim_task(PSAdjustSubTask_old_ref_process)) {
PSParallelCompact::ref_processor()->weak_oops_do(&adjust);
}
if (_sub_tasks.try_claim_task(PSAdjustSubTask_young_ref_process)) {
// Roots were visited so references into the young gen in roots
// may have been scanned. Process them also.
// Should the reference processor have a span that excludes
// young gen objects?
PSScavenge::reference_processor()->weak_oops_do(&adjust);
}
_sub_tasks.all_tasks_claimed();
}
};

@ -654,8 +654,6 @@ bool PSScavenge::invoke_no_policy() {
DerivedPointerTable::update_pointers();
#endif
NOT_PRODUCT(reference_processor()->verify_no_references_recorded());
// Re-verify object start arrays
if (VerifyObjectStartArray &&
VerifyAfterGC) {

@ -798,8 +798,6 @@ void GenCollectedHeap::full_process_roots(bool is_adjust_phase,
void GenCollectedHeap::gen_process_weak_roots(OopClosure* root_closure) {
WeakProcessor::oops_do(root_closure);
_young_gen->ref_processor()->weak_oops_do(root_closure);
_old_gen->ref_processor()->weak_oops_do(root_closure);
}
bool GenCollectedHeap::no_allocs_since_save_marks() {

@ -216,6 +216,9 @@ ReferenceProcessorStats ReferenceProcessor::process_discovered_references(RefPro
phase_times.set_total_time_ms((os::elapsedTime() - start_time) * 1000);
// Elements on discovered lists were pushed to the pending list.
verify_no_references_recorded();
return stats;
}

@ -420,8 +420,6 @@ public:
// iterate over oops
void weak_oops_do(OopClosure* f); // weak roots
void verify_list(DiscoveredList& ref_list);
// Discover a Reference object, using appropriate discovery criteria
virtual bool discover_reference(oop obj, ReferenceType rt);