8231395: Backout JDK-8231249
authorshade
Tue, 24 Sep 2019 09:38:14 +0200
changeset 58283 cdce40c3286f
parent 58282 03fce7b04b42
child 58284 59f7c242ccb8
8231395: Backout JDK-8231249 Reviewed-by: tschatzl
src/hotspot/share/gc/shenandoah/shenandoahHeap.cpp
--- a/src/hotspot/share/gc/shenandoah/shenandoahHeap.cpp	Tue Sep 24 03:28:42 2019 -0400
+++ b/src/hotspot/share/gc/shenandoah/shenandoahHeap.cpp	Tue Sep 24 09:38:14 2019 +0200
@@ -809,12 +809,22 @@
     // way later after GC happened, only to fail the second allocation, because
     // other threads have already depleted the free storage. In this case, a better
     // strategy is to try again, as long as GC makes progress.
-
-    if (result == NULL) {
-      do {
-        control_thread()->handle_alloc_failure(req.size());
-        result = allocate_memory_under_lock(req, in_new_region);
-      } while (result == NULL && _progress_last_gc.is_set());
+    //
+    // Then, we need to make sure the allocation was retried after at least one
+    // Full GC, which means we want to try more than ShenandoahFullGCThreshold times.
+
+    size_t tries = 0;
+
+    while (result == NULL && _progress_last_gc.is_set()) {
+      tries++;
+      control_thread()->handle_alloc_failure(req.size());
+      result = allocate_memory_under_lock(req, in_new_region);
+    }
+
+    while (result == NULL && tries <= ShenandoahFullGCThreshold) {
+      tries++;
+      control_thread()->handle_alloc_failure(req.size());
+      result = allocate_memory_under_lock(req, in_new_region);
     }
 
   } else {