src/hotspot/share/gc/shenandoah/shenandoahHeap.cpp
changeset 58283 cdce40c3286f
parent 58268 bc696d87d032
child 58494 54c1ba464b78
child 58543 a7a606f6311c
equal deleted inserted replaced
58282:03fce7b04b42 58283:cdce40c3286f
   807     //
   807     //
   808     // It might happen that one of the threads requesting allocation would unblock
   808     // It might happen that one of the threads requesting allocation would unblock
   809     // way later after GC happened, only to fail the second allocation, because
   809     // way later after GC happened, only to fail the second allocation, because
   810     // other threads have already depleted the free storage. In this case, a better
   810     // other threads have already depleted the free storage. In this case, a better
   811     // strategy is to try again, as long as GC makes progress.
   811     // strategy is to try again, as long as GC makes progress.
   812 
   812     //
   813     if (result == NULL) {
   813     // Then, we need to make sure the allocation was retried after at least one
   814       do {
   814     // Full GC, which means we want to try more than ShenandoahFullGCThreshold times.
   815         control_thread()->handle_alloc_failure(req.size());
   815 
   816         result = allocate_memory_under_lock(req, in_new_region);
   816     size_t tries = 0;
   817       } while (result == NULL && _progress_last_gc.is_set());
   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     }
       
   823 
       
   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);
   818     }
   828     }
   819 
   829 
   820   } else {
   830   } else {
   821     assert(req.is_gc_alloc(), "Can only accept GC allocs here");
   831     assert(req.is_gc_alloc(), "Can only accept GC allocs here");
   822     result = allocate_memory_under_lock(req, in_new_region);
   832     result = allocate_memory_under_lock(req, in_new_region);