Skip to content

Commit 23ae4b9

Browse files
committed
8231395: Backout JDK-8231249
Reviewed-by: tschatzl
1 parent 23ec926 commit 23ae4b9

File tree

1 file changed

+15
-5
lines changed

1 file changed

+15
-5
lines changed

src/hotspot/share/gc/shenandoah/shenandoahHeap.cpp

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -809,12 +809,22 @@ HeapWord* ShenandoahHeap::allocate_memory(ShenandoahAllocRequest& req) {
809809
// way later after GC happened, only to fail the second allocation, because
810810
// other threads have already depleted the free storage. In this case, a better
811811
// strategy is to try again, as long as GC makes progress.
812+
//
813+
// Then, we need to make sure the allocation was retried after at least one
814+
// Full GC, which means we want to try more than ShenandoahFullGCThreshold times.
815+
816+
size_t tries = 0;
817+
818+
while (result == NULL && _progress_last_gc.is_set()) {
819+
tries++;
820+
control_thread()->handle_alloc_failure(req.size());
821+
result = allocate_memory_under_lock(req, in_new_region);
822+
}
812823

813-
if (result == NULL) {
814-
do {
815-
control_thread()->handle_alloc_failure(req.size());
816-
result = allocate_memory_under_lock(req, in_new_region);
817-
} while (result == NULL && _progress_last_gc.is_set());
824+
while (result == NULL && tries <= ShenandoahFullGCThreshold) {
825+
tries++;
826+
control_thread()->handle_alloc_failure(req.size());
827+
result = allocate_memory_under_lock(req, in_new_region);
818828
}
819829

820830
} else {

0 commit comments

Comments
 (0)