Skip to content

Commit 565ec85

Browse files
committed
8270282: Semantically rename reference processing subphases
Reviewed-by: kbarrett, tschatzl
1 parent 07e9052 commit 565ec85

File tree

4 files changed

+84
-85
lines changed

4 files changed

+84
-85
lines changed

src/hotspot/share/gc/shared/referenceProcessor.cpp

Lines changed: 48 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -199,17 +199,17 @@ ReferenceProcessorStats ReferenceProcessor::process_discovered_references(RefPro
199199
update_soft_ref_master_clock();
200200

201201
{
202-
RefProcTotalPhaseTimesTracker tt(RefPhase2, &phase_times);
202+
RefProcTotalPhaseTimesTracker tt(SoftWeakFinalRefsPhase, &phase_times);
203203
process_soft_weak_final_refs(proxy_task, phase_times);
204204
}
205205

206206
{
207-
RefProcTotalPhaseTimesTracker tt(RefPhase3, &phase_times);
207+
RefProcTotalPhaseTimesTracker tt(KeepAliveFinalRefsPhase, &phase_times);
208208
process_final_keep_alive(proxy_task, phase_times);
209209
}
210210

211211
{
212-
RefProcTotalPhaseTimesTracker tt(RefPhase4, &phase_times);
212+
RefProcTotalPhaseTimesTracker tt(PhantomRefsPhase, &phase_times);
213213
process_phantom_refs(proxy_task, phase_times);
214214
}
215215

@@ -452,8 +452,8 @@ size_t ReferenceProcessor::total_reference_count(ReferenceType type) const {
452452
}
453453

454454

455-
class RefProcPhase2Task: public RefProcTask {
456-
void run_phase2(uint worker_id,
455+
class RefProcSoftWeakFinalPhaseTask: public RefProcTask {
456+
void run_phase(uint worker_id,
457457
DiscoveredList list[],
458458
BoolObjectClosure* is_alive,
459459
OopClosure* keep_alive,
@@ -467,8 +467,8 @@ class RefProcPhase2Task: public RefProcTask {
467467
}
468468

469469
public:
470-
RefProcPhase2Task(ReferenceProcessor& ref_processor,
471-
ReferenceProcessorPhaseTimes* phase_times)
470+
RefProcSoftWeakFinalPhaseTask(ReferenceProcessor& ref_processor,
471+
ReferenceProcessorPhaseTimes* phase_times)
472472
: RefProcTask(ref_processor,
473473
phase_times) {}
474474

@@ -477,29 +477,29 @@ class RefProcPhase2Task: public RefProcTask {
477477
OopClosure* keep_alive,
478478
VoidClosure* complete_gc) override {
479479
ResourceMark rm;
480-
RefProcWorkerTimeTracker t(_phase_times->phase2_worker_time_sec(), tracker_id(worker_id));
480+
RefProcWorkerTimeTracker t(_phase_times->soft_weak_final_refs_phase_worker_time_sec(), tracker_id(worker_id));
481481
{
482-
RefProcSubPhasesWorkerTimeTracker tt(ReferenceProcessor::SoftRefSubPhase2, _phase_times, tracker_id(worker_id));
483-
run_phase2(worker_id, _ref_processor._discoveredSoftRefs, is_alive, keep_alive, true /* do_enqueue_and_clear */, REF_SOFT);
482+
RefProcSubPhasesWorkerTimeTracker tt(ReferenceProcessor::ProcessSoftRefSubPhase, _phase_times, tracker_id(worker_id));
483+
run_phase(worker_id, _ref_processor._discoveredSoftRefs, is_alive, keep_alive, true /* do_enqueue_and_clear */, REF_SOFT);
484484
}
485485
{
486-
RefProcSubPhasesWorkerTimeTracker tt(ReferenceProcessor::WeakRefSubPhase2, _phase_times, tracker_id(worker_id));
487-
run_phase2(worker_id, _ref_processor._discoveredWeakRefs, is_alive, keep_alive, true /* do_enqueue_and_clear */, REF_WEAK);
486+
RefProcSubPhasesWorkerTimeTracker tt(ReferenceProcessor::ProcessWeakRefSubPhase, _phase_times, tracker_id(worker_id));
487+
run_phase(worker_id, _ref_processor._discoveredWeakRefs, is_alive, keep_alive, true /* do_enqueue_and_clear */, REF_WEAK);
488488
}
489489
{
490-
RefProcSubPhasesWorkerTimeTracker tt(ReferenceProcessor::FinalRefSubPhase2, _phase_times, tracker_id(worker_id));
491-
run_phase2(worker_id, _ref_processor._discoveredFinalRefs, is_alive, keep_alive, false /* do_enqueue_and_clear */, REF_FINAL);
490+
RefProcSubPhasesWorkerTimeTracker tt(ReferenceProcessor::ProcessFinalRefSubPhase, _phase_times, tracker_id(worker_id));
491+
run_phase(worker_id, _ref_processor._discoveredFinalRefs, is_alive, keep_alive, false /* do_enqueue_and_clear */, REF_FINAL);
492492
}
493493
// Close the reachable set; needed for collectors which keep_alive_closure do
494494
// not immediately complete their work.
495495
complete_gc->do_void();
496496
}
497497
};
498498

499-
class RefProcPhase3Task: public RefProcTask {
499+
class RefProcKeepAliveFinalPhaseTask: public RefProcTask {
500500
public:
501-
RefProcPhase3Task(ReferenceProcessor& ref_processor,
502-
ReferenceProcessorPhaseTimes* phase_times)
501+
RefProcKeepAliveFinalPhaseTask(ReferenceProcessor& ref_processor,
502+
ReferenceProcessorPhaseTimes* phase_times)
503503
: RefProcTask(ref_processor,
504504
phase_times) {}
505505

@@ -508,15 +508,15 @@ class RefProcPhase3Task: public RefProcTask {
508508
OopClosure* keep_alive,
509509
VoidClosure* complete_gc) override {
510510
ResourceMark rm;
511-
RefProcSubPhasesWorkerTimeTracker tt(ReferenceProcessor::FinalRefSubPhase3, _phase_times, tracker_id(worker_id));
511+
RefProcSubPhasesWorkerTimeTracker tt(ReferenceProcessor::KeepAliveFinalRefsSubPhase, _phase_times, tracker_id(worker_id));
512512
_ref_processor.process_final_keep_alive_work(_ref_processor._discoveredFinalRefs[worker_id], keep_alive, complete_gc);
513513
}
514514
};
515515

516-
class RefProcPhase4Task: public RefProcTask {
516+
class RefProcPhantomPhaseTask: public RefProcTask {
517517
public:
518-
RefProcPhase4Task(ReferenceProcessor& ref_processor,
519-
ReferenceProcessorPhaseTimes* phase_times)
518+
RefProcPhantomPhaseTask(ReferenceProcessor& ref_processor,
519+
ReferenceProcessorPhaseTimes* phase_times)
520520
: RefProcTask(ref_processor,
521521
phase_times) {}
522522

@@ -525,7 +525,7 @@ class RefProcPhase4Task: public RefProcTask {
525525
OopClosure* keep_alive,
526526
VoidClosure* complete_gc) override {
527527
ResourceMark rm;
528-
RefProcSubPhasesWorkerTimeTracker tt(ReferenceProcessor::PhantomRefSubPhase4, _phase_times, tracker_id(worker_id));
528+
RefProcSubPhasesWorkerTimeTracker tt(ReferenceProcessor::ProcessPhantomRefsSubPhase, _phase_times, tracker_id(worker_id));
529529
size_t const removed = _ref_processor.process_phantom_refs_work(_ref_processor._discoveredPhantomRefs[worker_id],
530530
is_alive,
531531
keep_alive,
@@ -720,31 +720,31 @@ void ReferenceProcessor::process_soft_weak_final_refs(RefProcProxyTask& proxy_ta
720720
phase_times.set_processing_is_mt(processing_is_mt());
721721

722722
if (num_total_refs == 0) {
723-
log_debug(gc, ref)("Skipped phase 2 of Reference Processing: no references");
723+
log_debug(gc, ref)("Skipped SoftWeakFinalRefsPhase of Reference Processing: no references");
724724
return;
725725
}
726726

727-
RefProcMTDegreeAdjuster a(this, RefPhase2, num_total_refs);
727+
RefProcMTDegreeAdjuster a(this, SoftWeakFinalRefsPhase, num_total_refs);
728728

729729
if (processing_is_mt()) {
730-
RefProcBalanceQueuesTimeTracker tt(RefPhase2, &phase_times);
730+
RefProcBalanceQueuesTimeTracker tt(SoftWeakFinalRefsPhase, &phase_times);
731731
maybe_balance_queues(_discoveredSoftRefs);
732732
maybe_balance_queues(_discoveredWeakRefs);
733733
maybe_balance_queues(_discoveredFinalRefs);
734734
}
735735

736-
RefProcPhaseTimeTracker tt(RefPhase2, &phase_times);
736+
RefProcPhaseTimeTracker tt(SoftWeakFinalRefsPhase, &phase_times);
737737

738-
log_reflist("Phase 2 Soft before", _discoveredSoftRefs, _max_num_queues);
739-
log_reflist("Phase 2 Weak before", _discoveredWeakRefs, _max_num_queues);
740-
log_reflist("Phase 2 Final before", _discoveredFinalRefs, _max_num_queues);
738+
log_reflist("SoftWeakFinalRefsPhase Soft before", _discoveredSoftRefs, _max_num_queues);
739+
log_reflist("SoftWeakFinalRefsPhase Weak before", _discoveredWeakRefs, _max_num_queues);
740+
log_reflist("SoftWeakFinalRefsPhase Final before", _discoveredFinalRefs, _max_num_queues);
741741

742-
RefProcPhase2Task phase2(*this, &phase_times);
743-
run_task(phase2, proxy_task, false);
742+
RefProcSoftWeakFinalPhaseTask phase_task(*this, &phase_times);
743+
run_task(phase_task, proxy_task, false);
744744

745745
verify_total_count_zero(_discoveredSoftRefs, "SoftReference");
746746
verify_total_count_zero(_discoveredWeakRefs, "WeakReference");
747-
log_reflist("Phase 2 Final after", _discoveredFinalRefs, _max_num_queues);
747+
log_reflist("SoftWeakFinalRefsPhase Final after", _discoveredFinalRefs, _max_num_queues);
748748
}
749749

750750
void ReferenceProcessor::process_final_keep_alive(RefProcProxyTask& proxy_task,
@@ -754,22 +754,21 @@ void ReferenceProcessor::process_final_keep_alive(RefProcProxyTask& proxy_task,
754754
phase_times.set_processing_is_mt(processing_is_mt());
755755

756756
if (num_final_refs == 0) {
757-
log_debug(gc, ref)("Skipped phase 3 of Reference Processing: no references");
757+
log_debug(gc, ref)("Skipped KeepAliveFinalRefsPhase of Reference Processing: no references");
758758
return;
759759
}
760760

761-
RefProcMTDegreeAdjuster a(this, RefPhase3, num_final_refs);
761+
RefProcMTDegreeAdjuster a(this, KeepAliveFinalRefsPhase, num_final_refs);
762762

763763
if (processing_is_mt()) {
764-
RefProcBalanceQueuesTimeTracker tt(RefPhase3, &phase_times);
764+
RefProcBalanceQueuesTimeTracker tt(KeepAliveFinalRefsPhase, &phase_times);
765765
maybe_balance_queues(_discoveredFinalRefs);
766766
}
767767

768-
// Phase 3:
769-
// . Traverse referents of final references and keep them and followers alive.
770-
RefProcPhaseTimeTracker tt(RefPhase3, &phase_times);
771-
RefProcPhase3Task phase3(*this, &phase_times);
772-
run_task(phase3, proxy_task, true);
768+
// Traverse referents of final references and keep them and followers alive.
769+
RefProcPhaseTimeTracker tt(KeepAliveFinalRefsPhase, &phase_times);
770+
RefProcKeepAliveFinalPhaseTask phase_task(*this, &phase_times);
771+
run_task(phase_task, proxy_task, true);
773772

774773
verify_total_count_zero(_discoveredFinalRefs, "FinalReference");
775774
}
@@ -782,24 +781,24 @@ void ReferenceProcessor::process_phantom_refs(RefProcProxyTask& proxy_task,
782781
phase_times.set_processing_is_mt(processing_is_mt());
783782

784783
if (num_phantom_refs == 0) {
785-
log_debug(gc, ref)("Skipped phase 4 of Reference Processing: no references");
784+
log_debug(gc, ref)("Skipped PhantomRefsPhase of Reference Processing: no references");
786785
return;
787786
}
788787

789-
RefProcMTDegreeAdjuster a(this, RefPhase4, num_phantom_refs);
788+
RefProcMTDegreeAdjuster a(this, PhantomRefsPhase, num_phantom_refs);
790789

791790
if (processing_is_mt()) {
792-
RefProcBalanceQueuesTimeTracker tt(RefPhase4, &phase_times);
791+
RefProcBalanceQueuesTimeTracker tt(PhantomRefsPhase, &phase_times);
793792
maybe_balance_queues(_discoveredPhantomRefs);
794793
}
795794

796-
// Phase 4: Walk phantom references appropriately.
797-
RefProcPhaseTimeTracker tt(RefPhase4, &phase_times);
795+
// Walk phantom references appropriately.
796+
RefProcPhaseTimeTracker tt(PhantomRefsPhase, &phase_times);
798797

799-
log_reflist("Phase 4 Phantom before", _discoveredPhantomRefs, _max_num_queues);
798+
log_reflist("PhantomRefsPhase Phantom before", _discoveredPhantomRefs, _max_num_queues);
800799

801-
RefProcPhase4Task phase4(*this, &phase_times);
802-
run_task(phase4, proxy_task, false);
800+
RefProcPhantomPhaseTask phase_task(*this, &phase_times);
801+
run_task(phase_task, proxy_task, false);
803802

804803
verify_total_count_zero(_discoveredPhantomRefs, "PhantomReference");
805804
}
@@ -1190,7 +1189,7 @@ uint RefProcMTDegreeAdjuster::ergo_proc_thread_count(size_t ref_count,
11901189

11911190
bool RefProcMTDegreeAdjuster::use_max_threads(RefProcPhases phase) const {
11921191
// Even a small number of references in this phase could produce large amounts of work.
1193-
return phase == ReferenceProcessor::RefPhase3;
1192+
return phase == ReferenceProcessor::KeepAliveFinalRefsPhase;
11941193
}
11951194

11961195
RefProcMTDegreeAdjuster::RefProcMTDegreeAdjuster(ReferenceProcessor* rp,

src/hotspot/share/gc/shared/referenceProcessor.hpp

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -160,26 +160,26 @@ class DiscoveredListIterator {
160160
// straightforward manner in a general, non-generational, non-contiguous generation
161161
// (or heap) setting.
162162
class ReferenceProcessor : public ReferenceDiscoverer {
163-
friend class RefProcPhase2Task;
164-
friend class RefProcPhase3Task;
165-
friend class RefProcPhase4Task;
163+
friend class RefProcSoftWeakFinalPhaseTask;
164+
friend class RefProcKeepAliveFinalPhaseTask;
165+
friend class RefProcPhantomPhaseTask;
166166
public:
167167
// Names of sub-phases of reference processing. Indicates the type of the reference
168168
// processed and the associated phase number at the end.
169169
enum RefProcSubPhases {
170-
SoftRefSubPhase2,
171-
WeakRefSubPhase2,
172-
FinalRefSubPhase2,
173-
FinalRefSubPhase3,
174-
PhantomRefSubPhase4,
170+
ProcessSoftRefSubPhase,
171+
ProcessWeakRefSubPhase,
172+
ProcessFinalRefSubPhase,
173+
KeepAliveFinalRefsSubPhase,
174+
ProcessPhantomRefsSubPhase,
175175
RefSubPhaseMax
176176
};
177177

178178
// Main phases of reference processing.
179179
enum RefProcPhases {
180-
RefPhase2,
181-
RefPhase3,
182-
RefPhase4,
180+
SoftWeakFinalRefsPhase,
181+
KeepAliveFinalRefsPhase,
182+
PhantomRefsPhase,
183183
RefPhaseMax
184184
};
185185

@@ -234,16 +234,16 @@ class ReferenceProcessor : public ReferenceDiscoverer {
234234

235235
void run_task(RefProcTask& task, RefProcProxyTask& proxy_task, bool marks_oops_alive);
236236

237-
// Phase 2: Drop Soft/Weak/Final references with a NULL or live referent, and clear
237+
// Drop Soft/Weak/Final references with a NULL or live referent, and clear
238238
// and enqueue non-Final references.
239239
void process_soft_weak_final_refs(RefProcProxyTask& proxy_task,
240240
ReferenceProcessorPhaseTimes& phase_times);
241241

242-
// Phase 3: Keep alive followers of Final references, and enqueue.
242+
// Keep alive followers of Final references, and enqueue.
243243
void process_final_keep_alive(RefProcProxyTask& proxy_task,
244244
ReferenceProcessorPhaseTimes& phase_times);
245245

246-
// Phase 4: Drop and keep alive live Phantom references, or clear and enqueue if dead.
246+
// Drop and keep alive live Phantom references, or clear and enqueue if dead.
247247
void process_phantom_refs(RefProcProxyTask& proxy_task,
248248
ReferenceProcessorPhaseTimes& phase_times);
249249

src/hotspot/share/gc/shared/referenceProcessorPhaseTimes.cpp

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -36,11 +36,11 @@
3636
#define ASSERT_REF_TYPE(ref_type) assert((ref_type) >= REF_SOFT && (ref_type) <= REF_PHANTOM, \
3737
"Invariant (%d)", (int)ref_type)
3838

39-
#define ASSERT_PHASE(phase) assert((phase) >= ReferenceProcessor::RefPhase2 && \
39+
#define ASSERT_PHASE(phase) assert((phase) >= ReferenceProcessor::SoftWeakFinalRefsPhase && \
4040
(phase) < ReferenceProcessor::RefPhaseMax, \
4141
"Invariant (%d)", (int)phase);
4242

43-
#define ASSERT_SUB_PHASE(phase) assert((phase) >= ReferenceProcessor::SoftRefSubPhase2 && \
43+
#define ASSERT_SUB_PHASE(phase) assert((phase) >= ReferenceProcessor::ProcessSoftRefSubPhase && \
4444
(phase) < ReferenceProcessor::RefSubPhaseMax, \
4545
"Invariant (%d)", (int)phase);
4646

@@ -52,7 +52,7 @@ static const char* SubPhasesParWorkTitle[ReferenceProcessor::RefSubPhaseMax] = {
5252
"PhantomRef (ms):"
5353
};
5454

55-
static const char* Phase2ParWorkTitle = "Total (ms):";
55+
static const char* SoftWeakFinalRefsPhaseParWorkTitle = "Total (ms):";
5656

5757
static const char* SubPhasesSerWorkTitle[ReferenceProcessor::RefSubPhaseMax] = {
5858
"SoftRef:",
@@ -62,7 +62,7 @@ static const char* SubPhasesSerWorkTitle[ReferenceProcessor::RefSubPhaseMax] = {
6262
"PhantomRef:"
6363
};
6464

65-
static const char* Phase2SerWorkTitle = "Total:";
65+
static const char* SoftWeakFinalRefsPhaseSerWorkTitle = "Total:";
6666

6767
static const char* Indents[6] = {"", " ", " ", " ", " ", " "};
6868

@@ -172,7 +172,7 @@ ReferenceProcessorPhaseTimes::ReferenceProcessorPhaseTimes(GCTimer* gc_timer, ui
172172
for (uint i = 0; i < ReferenceProcessor::RefSubPhaseMax; i++) {
173173
_sub_phases_worker_time_sec[i] = new WorkerDataArray<double>(NULL, SubPhasesParWorkTitle[i], max_gc_threads);
174174
}
175-
_phase2_worker_time_sec = new WorkerDataArray<double>(NULL, Phase2ParWorkTitle, max_gc_threads);
175+
_soft_weak_final_refs_phase_worker_time_sec = new WorkerDataArray<double>(NULL, SoftWeakFinalRefsPhaseParWorkTitle, max_gc_threads);
176176

177177
reset();
178178
}
@@ -208,7 +208,7 @@ void ReferenceProcessorPhaseTimes::reset() {
208208
_balance_queues_time_ms[i] = uninitialized();
209209
}
210210

211-
_phase2_worker_time_sec->reset();
211+
_soft_weak_final_refs_phase_worker_time_sec->reset();
212212

213213
for (int i = 0; i < number_of_subclasses_of_ref; i++) {
214214
_ref_cleared[i] = 0;
@@ -224,7 +224,7 @@ ReferenceProcessorPhaseTimes::~ReferenceProcessorPhaseTimes() {
224224
for (int i = 0; i < ReferenceProcessor::RefSubPhaseMax; i++) {
225225
delete _sub_phases_worker_time_sec[i];
226226
}
227-
delete _phase2_worker_time_sec;
227+
delete _soft_weak_final_refs_phase_worker_time_sec;
228228
}
229229

230230
double ReferenceProcessorPhaseTimes::sub_phase_total_time_ms(ReferenceProcessor::RefProcSubPhases sub_phase) const {
@@ -272,9 +272,9 @@ void ReferenceProcessorPhaseTimes::print_all_references(uint base_indent, bool p
272272
}
273273

274274
uint next_indent = base_indent + 1;
275-
print_phase(ReferenceProcessor::RefPhase2, next_indent);
276-
print_phase(ReferenceProcessor::RefPhase3, next_indent);
277-
print_phase(ReferenceProcessor::RefPhase4, next_indent);
275+
print_phase(ReferenceProcessor::SoftWeakFinalRefsPhase, next_indent);
276+
print_phase(ReferenceProcessor::KeepAliveFinalRefsPhase, next_indent);
277+
print_phase(ReferenceProcessor::PhantomRefsPhase, next_indent);
278278

279279
print_reference(REF_SOFT, next_indent);
280280
print_reference(REF_WEAK, next_indent);
@@ -325,22 +325,22 @@ void ReferenceProcessorPhaseTimes::print_phase(ReferenceProcessor::RefProcPhases
325325
}
326326

327327
switch (phase) {
328-
case ReferenceProcessor::RefPhase2:
329-
print_sub_phase(&ls, ReferenceProcessor::SoftRefSubPhase2, indent + 1);
330-
print_sub_phase(&ls, ReferenceProcessor::WeakRefSubPhase2, indent + 1);
331-
print_sub_phase(&ls, ReferenceProcessor::FinalRefSubPhase2, indent + 1);
328+
case ReferenceProcessor::SoftWeakFinalRefsPhase:
329+
print_sub_phase(&ls, ReferenceProcessor::ProcessSoftRefSubPhase, indent + 1);
330+
print_sub_phase(&ls, ReferenceProcessor::ProcessWeakRefSubPhase, indent + 1);
331+
print_sub_phase(&ls, ReferenceProcessor::ProcessFinalRefSubPhase, indent + 1);
332332
break;
333-
case ReferenceProcessor::RefPhase3:
334-
print_sub_phase(&ls, ReferenceProcessor::FinalRefSubPhase3, indent + 1);
333+
case ReferenceProcessor::KeepAliveFinalRefsPhase:
334+
print_sub_phase(&ls, ReferenceProcessor::KeepAliveFinalRefsSubPhase, indent + 1);
335335
break;
336-
case ReferenceProcessor::RefPhase4:
337-
print_sub_phase(&ls, ReferenceProcessor::PhantomRefSubPhase4, indent + 1);
336+
case ReferenceProcessor::PhantomRefsPhase:
337+
print_sub_phase(&ls, ReferenceProcessor::ProcessPhantomRefsSubPhase, indent + 1);
338338
break;
339339
default:
340340
ShouldNotReachHere();
341341
}
342-
if (phase == ReferenceProcessor::RefPhase2) {
343-
print_worker_time(&ls, _phase2_worker_time_sec, Phase2SerWorkTitle, indent + 1);
342+
if (phase == ReferenceProcessor::SoftWeakFinalRefsPhase) {
343+
print_worker_time(&ls, _soft_weak_final_refs_phase_worker_time_sec, SoftWeakFinalRefsPhaseSerWorkTitle, indent + 1);
344344
}
345345
}
346346
}

0 commit comments

Comments
 (0)