Skip to content
Permalink
Browse files
8277916: Gather non-strong reference count logic in a single place
Reviewed-by: sjohanss, mli
  • Loading branch information
albertnetymk committed Dec 3, 2021
1 parent 53df9ff commit e4774e68e3bdb186269e909247bbd1b9f8e4f4be
@@ -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();

@@ -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;
}

@@ -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");
@@ -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");
@@ -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");
@@ -233,6 +233,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];
@@ -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);

1 comment on commit e4774e6

@openjdk-notifier
Copy link

@openjdk-notifier openjdk-notifier bot commented on e4774e6 Dec 3, 2021

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.