Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
8275298: Remove unnecessary weak_oops_do call in adjust weak roots phase
Reviewed-by: tschatzl, sjohanss
  • Loading branch information
albertnetymk committed Oct 18, 2021
1 parent fb8e5cf commit 4d383b9
Show file tree
Hide file tree
Showing 9 changed files with 7 additions and 33 deletions.
3 changes: 0 additions & 3 deletions src/hotspot/share/gc/g1/g1ConcurrentMark.cpp
Expand Up @@ -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()) {
Expand Down
11 changes: 4 additions & 7 deletions src/hotspot/share/gc/g1/g1FullGCAdjustTask.cpp
Expand Up @@ -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) {
Expand All @@ -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);
Expand Down
1 change: 0 additions & 1 deletion src/hotspot/share/gc/g1/g1FullGCAdjustTask.hpp
Expand Up @@ -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;
Expand Down
2 changes: 0 additions & 2 deletions src/hotspot/share/gc/g1/g1YoungCollector.cpp
Expand Up @@ -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);
}

Expand Down
14 changes: 0 additions & 14 deletions src/hotspot/share/gc/parallel/psParallelCompact.cpp
Expand Up @@ -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();
Expand Down Expand Up @@ -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
};
Expand Down Expand Up @@ -2204,16 +2200,6 @@ class PSAdjustTask final : public WorkerTask {
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();
}
};
Expand Down
2 changes: 0 additions & 2 deletions src/hotspot/share/gc/parallel/psScavenge.cpp
Expand Up @@ -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) {
Expand Down
2 changes: 0 additions & 2 deletions src/hotspot/share/gc/shared/genCollectedHeap.cpp
Expand Up @@ -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() {
Expand Down
3 changes: 3 additions & 0 deletions src/hotspot/share/gc/shared/referenceProcessor.cpp
Expand Up @@ -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;
}

Expand Down
2 changes: 0 additions & 2 deletions src/hotspot/share/gc/shared/referenceProcessor.hpp
Expand Up @@ -420,8 +420,6 @@ class ReferenceProcessor : public ReferenceDiscoverer {
// 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);

Expand Down

1 comment on commit 4d383b9

@openjdk-notifier
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.