Skip to content

Commit 8f7faa6

Browse files
committed
8300447: Parallel: Refactor PSPromotionManager::drain_stacks_depth
Reviewed-by: tschatzl, kbarrett
1 parent eba87a0 commit 8f7faa6

File tree

1 file changed

+8
-11
lines changed

1 file changed

+8
-11
lines changed

src/hotspot/share/gc/parallel/psPromotionManager.cpp

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -227,7 +227,8 @@ void PSPromotionManager::restore_preserved_marks() {
227227
}
228228

229229
void PSPromotionManager::drain_stacks_depth(bool totally_drain) {
230-
totally_drain = totally_drain || (_target_stack_size == 0);
230+
const uint threshold = totally_drain ? 0
231+
: _target_stack_size;
231232

232233
PSScannerTasksQueue* const tq = claimed_stack_depth();
233234
do {
@@ -236,19 +237,15 @@ void PSPromotionManager::drain_stacks_depth(bool totally_drain) {
236237
// Drain overflow stack first, so other threads can steal from
237238
// claimed stack while we work.
238239
while (tq->pop_overflow(task)) {
239-
process_popped_location_depth(task);
240-
}
241-
242-
if (totally_drain) {
243-
while (tq->pop_local(task)) {
244-
process_popped_location_depth(task);
245-
}
246-
} else {
247-
while (tq->size() > _target_stack_size && tq->pop_local(task)) {
240+
if (!tq->try_push_to_taskqueue(task)) {
248241
process_popped_location_depth(task);
249242
}
250243
}
251-
} while ((totally_drain && !tq->taskqueue_empty()) || !tq->overflow_empty());
244+
245+
while (tq->pop_local(task, threshold)) {
246+
process_popped_location_depth(task);
247+
}
248+
} while (!tq->overflow_empty());
252249

253250
assert(!totally_drain || tq->taskqueue_empty(), "Sanity");
254251
assert(totally_drain || tq->size() <= _target_stack_size, "Sanity");

0 commit comments

Comments
 (0)