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

8277916: Gather non-strong reference count logic in a single place #6588

Closed
wants to merge 1 commit 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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
25 changes: 13 additions & 12 deletions src/hotspot/share/gc/shared/referenceProcessor.cpp
Expand Up @@ -191,10 +191,10 @@ ReferenceProcessorStats ReferenceProcessor::process_discovered_references(RefPro
// Stop treating discovered references specially.
disable_discovery();

ReferenceProcessorStats stats(total_count(_discoveredSoftRefs),
total_count(_discoveredWeakRefs),
total_count(_discoveredFinalRefs),
total_count(_discoveredPhantomRefs));
phase_times.set_ref_discovered(REF_SOFT, total_count(_discoveredSoftRefs));
phase_times.set_ref_discovered(REF_WEAK, total_count(_discoveredWeakRefs));
phase_times.set_ref_discovered(REF_FINAL, total_count(_discoveredFinalRefs));
phase_times.set_ref_discovered(REF_PHANTOM, total_count(_discoveredPhantomRefs));

update_soft_ref_master_clock();

Expand All @@ -220,6 +220,10 @@ ReferenceProcessorStats ReferenceProcessor::process_discovered_references(RefPro
// Elements on discovered lists were pushed to the pending list.
verify_no_references_recorded();

ReferenceProcessorStats stats(phase_times.ref_discovered(REF_SOFT),
phase_times.ref_discovered(REF_WEAK),
phase_times.ref_discovered(REF_FINAL),
phase_times.ref_discovered(REF_PHANTOM));
return stats;
}

Expand Down Expand Up @@ -725,12 +729,10 @@ void ReferenceProcessor::run_task(RefProcTask& task, RefProcProxyTask& proxy_tas
void ReferenceProcessor::process_soft_weak_final_refs(RefProcProxyTask& proxy_task,
ReferenceProcessorPhaseTimes& phase_times) {

size_t const num_soft_refs = total_count(_discoveredSoftRefs);
size_t const num_weak_refs = total_count(_discoveredWeakRefs);
size_t const num_final_refs = total_count(_discoveredFinalRefs);
size_t const num_soft_refs = phase_times.ref_discovered(REF_SOFT);
size_t const num_weak_refs = phase_times.ref_discovered(REF_WEAK);
size_t const num_final_refs = phase_times.ref_discovered(REF_FINAL);
size_t const num_total_refs = num_soft_refs + num_weak_refs + num_final_refs;
phase_times.set_ref_discovered(REF_WEAK, num_weak_refs);
phase_times.set_ref_discovered(REF_FINAL, num_final_refs);

if (num_total_refs == 0) {
log_debug(gc, ref)("Skipped SoftWeakFinalRefsPhase of Reference Processing: no references");
Expand Down Expand Up @@ -763,7 +765,7 @@ void ReferenceProcessor::process_soft_weak_final_refs(RefProcProxyTask& proxy_ta
void ReferenceProcessor::process_final_keep_alive(RefProcProxyTask& proxy_task,
ReferenceProcessorPhaseTimes& phase_times) {

size_t const num_final_refs = total_count(_discoveredFinalRefs);
size_t const num_final_refs = phase_times.ref_discovered(REF_FINAL);

if (num_final_refs == 0) {
log_debug(gc, ref)("Skipped KeepAliveFinalRefsPhase of Reference Processing: no references");
Expand All @@ -788,8 +790,7 @@ void ReferenceProcessor::process_final_keep_alive(RefProcProxyTask& proxy_task,
void ReferenceProcessor::process_phantom_refs(RefProcProxyTask& proxy_task,
ReferenceProcessorPhaseTimes& phase_times) {

size_t const num_phantom_refs = total_count(_discoveredPhantomRefs);
phase_times.set_ref_discovered(REF_PHANTOM, num_phantom_refs);
size_t const num_phantom_refs = phase_times.ref_discovered(REF_PHANTOM);

if (num_phantom_refs == 0) {
log_debug(gc, ref)("Skipped PhantomRefsPhase of Reference Processing: no references");
Expand Down
5 changes: 5 additions & 0 deletions src/hotspot/share/gc/shared/referenceProcessorPhaseTimes.cpp
Expand Up @@ -236,6 +236,11 @@ void ReferenceProcessorPhaseTimes::set_ref_discovered(ReferenceType ref_type, si
_ref_discovered[ref_type_2_index(ref_type)] = count;
}

size_t ReferenceProcessorPhaseTimes::ref_discovered(ReferenceType ref_type) {
ASSERT_REF_TYPE(ref_type);
return _ref_discovered[ref_type_2_index(ref_type)];
}

double ReferenceProcessorPhaseTimes::balance_queues_time_ms(ReferenceProcessor::RefProcPhases phase) const {
ASSERT_PHASE(phase);
return _balance_queues_time_ms[phase];
Expand Down
Expand Up @@ -85,6 +85,7 @@ class ReferenceProcessorPhaseTimes : public CHeapObj<mtGC> {

void add_ref_cleared(ReferenceType ref_type, size_t count);
void set_ref_discovered(ReferenceType ref_type, size_t count);
size_t ref_discovered(ReferenceType ref_type);

void set_balance_queues_time_ms(ReferenceProcessor::RefProcPhases phase, double time_ms);

Expand Down