@@ -218,6 +218,12 @@ ReferenceProcessorStats ReferenceProcessor::process_discovered_references(RefPro
218
218
return stats;
219
219
}
220
220
221
+ void BarrierEnqueueDiscoveredFieldClosure::enqueue (oop reference, oop value) {
222
+ HeapAccess<AS_NO_KEEPALIVE>::oop_store_at (reference,
223
+ java_lang_ref_Reference::discovered_offset (),
224
+ value);
225
+ }
226
+
221
227
void DiscoveredListIterator::load_ptrs (DEBUG_ONLY(bool allow_null_referent)) {
222
228
_current_discovered_addr = java_lang_ref_Reference::discovered_addr_raw (_current_discovered);
223
229
oop discovered = java_lang_ref_Reference::discovered (_current_discovered);
@@ -271,18 +277,16 @@ void DiscoveredListIterator::clear_referent() {
271
277
}
272
278
273
279
void DiscoveredListIterator::enqueue () {
274
- HeapAccess<AS_NO_KEEPALIVE>::oop_store_at (_current_discovered,
275
- java_lang_ref_Reference::discovered_offset (),
276
- _next_discovered);
280
+ _enqueue->enqueue (_current_discovered, _next_discovered);
277
281
}
278
282
279
283
void DiscoveredListIterator::complete_enqueue () {
280
- if (_prev_discovered != NULL ) {
284
+ if (_prev_discovered != nullptr ) {
281
285
// This is the last object.
282
286
// Swap refs_list into pending list and set obj's
283
287
// discovered to what we read from the pending list.
284
288
oop old = Universe::swap_reference_pending_list (_refs_list.head ());
285
- HeapAccess<AS_NO_KEEPALIVE>:: oop_store_at (_prev_discovered, java_lang_ref_Reference::discovered_offset () , old);
289
+ _enqueue-> enqueue (_prev_discovered, old);
286
290
}
287
291
}
288
292
@@ -307,8 +311,9 @@ inline void log_enqueued_ref(const DiscoveredListIterator& iter, const char* rea
307
311
size_t ReferenceProcessor::process_discovered_list_work (DiscoveredList& refs_list,
308
312
BoolObjectClosure* is_alive,
309
313
OopClosure* keep_alive,
314
+ EnqueueDiscoveredFieldClosure* enqueue,
310
315
bool do_enqueue_and_clear) {
311
- DiscoveredListIterator iter (refs_list, keep_alive, is_alive);
316
+ DiscoveredListIterator iter (refs_list, keep_alive, is_alive, enqueue );
312
317
while (iter.has_next ()) {
313
318
iter.load_ptrs (DEBUG_ONLY (discovery_is_concurrent () /* allow_null_referent */ ));
314
319
if (iter.referent () == NULL ) {
@@ -350,8 +355,9 @@ size_t ReferenceProcessor::process_discovered_list_work(DiscoveredList& refs_
350
355
}
351
356
352
357
size_t ReferenceProcessor::process_final_keep_alive_work (DiscoveredList& refs_list,
353
- OopClosure* keep_alive) {
354
- DiscoveredListIterator iter (refs_list, keep_alive, NULL );
358
+ OopClosure* keep_alive,
359
+ EnqueueDiscoveredFieldClosure* enqueue) {
360
+ DiscoveredListIterator iter (refs_list, keep_alive, NULL , enqueue);
355
361
while (iter.has_next ()) {
356
362
iter.load_ptrs (DEBUG_ONLY (false /* allow_null_referent */ ));
357
363
// keep the referent and followers around
@@ -421,7 +427,8 @@ size_t ReferenceProcessor::total_reference_count(ReferenceType type) const {
421
427
void RefProcTask::process_discovered_list (uint worker_id,
422
428
ReferenceType ref_type,
423
429
BoolObjectClosure* is_alive,
424
- OopClosure* keep_alive) {
430
+ OopClosure* keep_alive,
431
+ EnqueueDiscoveredFieldClosure* enqueue) {
425
432
ReferenceProcessor::RefProcSubPhases subphase;
426
433
DiscoveredList* dl;
427
434
switch (ref_type) {
@@ -453,6 +460,7 @@ void RefProcTask::process_discovered_list(uint worker_id,
453
460
size_t const removed = _ref_processor.process_discovered_list_work (dl[worker_id],
454
461
is_alive,
455
462
keep_alive,
463
+ enqueue,
456
464
do_enqueue_and_clear);
457
465
_phase_times->add_ref_cleared (ref_type, removed);
458
466
}
@@ -468,14 +476,15 @@ class RefProcSoftWeakFinalPhaseTask: public RefProcTask {
468
476
void rp_work (uint worker_id,
469
477
BoolObjectClosure* is_alive,
470
478
OopClosure* keep_alive,
479
+ EnqueueDiscoveredFieldClosure* enqueue,
471
480
VoidClosure* complete_gc) override {
472
481
RefProcWorkerTimeTracker t (_phase_times->soft_weak_final_refs_phase_worker_time_sec (), tracker_id (worker_id));
473
482
474
- process_discovered_list (worker_id, REF_SOFT, is_alive, keep_alive);
483
+ process_discovered_list (worker_id, REF_SOFT, is_alive, keep_alive, enqueue );
475
484
476
- process_discovered_list (worker_id, REF_WEAK, is_alive, keep_alive);
485
+ process_discovered_list (worker_id, REF_WEAK, is_alive, keep_alive, enqueue );
477
486
478
- process_discovered_list (worker_id, REF_FINAL, is_alive, keep_alive);
487
+ process_discovered_list (worker_id, REF_FINAL, is_alive, keep_alive, enqueue );
479
488
480
489
// Close the reachable set; needed for collectors which keep_alive_closure do
481
490
// not immediately complete their work.
@@ -493,9 +502,10 @@ class RefProcKeepAliveFinalPhaseTask: public RefProcTask {
493
502
void rp_work (uint worker_id,
494
503
BoolObjectClosure* is_alive,
495
504
OopClosure* keep_alive,
505
+ EnqueueDiscoveredFieldClosure* enqueue,
496
506
VoidClosure* complete_gc) override {
497
507
RefProcSubPhasesWorkerTimeTracker tt (ReferenceProcessor::KeepAliveFinalRefsSubPhase, _phase_times, tracker_id (worker_id));
498
- _ref_processor.process_final_keep_alive_work (_ref_processor._discoveredFinalRefs [worker_id], keep_alive);
508
+ _ref_processor.process_final_keep_alive_work (_ref_processor._discoveredFinalRefs [worker_id], keep_alive, enqueue );
499
509
// Close the reachable set
500
510
complete_gc->do_void ();
501
511
}
@@ -511,8 +521,9 @@ class RefProcPhantomPhaseTask: public RefProcTask {
511
521
void rp_work (uint worker_id,
512
522
BoolObjectClosure* is_alive,
513
523
OopClosure* keep_alive,
524
+ EnqueueDiscoveredFieldClosure* enqueue,
514
525
VoidClosure* complete_gc) override {
515
- process_discovered_list (worker_id, REF_PHANTOM, is_alive, keep_alive);
526
+ process_discovered_list (worker_id, REF_PHANTOM, is_alive, keep_alive, enqueue );
516
527
517
528
// Close the reachable set; needed for collectors which keep_alive_closure do
518
529
// not immediately complete their work.
@@ -1039,6 +1050,7 @@ bool ReferenceProcessor::has_discovered_references() {
1039
1050
1040
1051
void ReferenceProcessor::preclean_discovered_references (BoolObjectClosure* is_alive,
1041
1052
OopClosure* keep_alive,
1053
+ EnqueueDiscoveredFieldClosure* enqueue,
1042
1054
VoidClosure* complete_gc,
1043
1055
YieldClosure* yield,
1044
1056
GCTimer* gc_timer) {
@@ -1053,7 +1065,7 @@ void ReferenceProcessor::preclean_discovered_references(BoolObjectClosure* is_al
1053
1065
return ;
1054
1066
}
1055
1067
if (preclean_discovered_reflist (_discoveredSoftRefs[i], is_alive,
1056
- keep_alive, complete_gc, yield)) {
1068
+ keep_alive, enqueue, complete_gc, yield)) {
1057
1069
log_reflist (" SoftRef abort: " , _discoveredSoftRefs, _max_num_queues);
1058
1070
return ;
1059
1071
}
@@ -1070,7 +1082,7 @@ void ReferenceProcessor::preclean_discovered_references(BoolObjectClosure* is_al
1070
1082
return ;
1071
1083
}
1072
1084
if (preclean_discovered_reflist (_discoveredWeakRefs[i], is_alive,
1073
- keep_alive, complete_gc, yield)) {
1085
+ keep_alive, enqueue, complete_gc, yield)) {
1074
1086
log_reflist (" WeakRef abort: " , _discoveredWeakRefs, _max_num_queues);
1075
1087
return ;
1076
1088
}
@@ -1087,7 +1099,7 @@ void ReferenceProcessor::preclean_discovered_references(BoolObjectClosure* is_al
1087
1099
return ;
1088
1100
}
1089
1101
if (preclean_discovered_reflist (_discoveredFinalRefs[i], is_alive,
1090
- keep_alive, complete_gc, yield)) {
1102
+ keep_alive, enqueue, complete_gc, yield)) {
1091
1103
log_reflist (" FinalRef abort: " , _discoveredFinalRefs, _max_num_queues);
1092
1104
return ;
1093
1105
}
@@ -1104,7 +1116,7 @@ void ReferenceProcessor::preclean_discovered_references(BoolObjectClosure* is_al
1104
1116
return ;
1105
1117
}
1106
1118
if (preclean_discovered_reflist (_discoveredPhantomRefs[i], is_alive,
1107
- keep_alive, complete_gc, yield)) {
1119
+ keep_alive, enqueue, complete_gc, yield)) {
1108
1120
log_reflist (" PhantomRef abort: " , _discoveredPhantomRefs, _max_num_queues);
1109
1121
return ;
1110
1122
}
@@ -1124,9 +1136,10 @@ void ReferenceProcessor::preclean_discovered_references(BoolObjectClosure* is_al
1124
1136
bool ReferenceProcessor::preclean_discovered_reflist (DiscoveredList& refs_list,
1125
1137
BoolObjectClosure* is_alive,
1126
1138
OopClosure* keep_alive,
1139
+ EnqueueDiscoveredFieldClosure* enqueue,
1127
1140
VoidClosure* complete_gc,
1128
1141
YieldClosure* yield) {
1129
- DiscoveredListIterator iter (refs_list, keep_alive, is_alive);
1142
+ DiscoveredListIterator iter (refs_list, keep_alive, is_alive, enqueue );
1130
1143
while (iter.has_next ()) {
1131
1144
if (yield->should_return_fine_grain ()) {
1132
1145
return true ;
0 commit comments