--- a/src/hotspot/share/gc/z/zPageAllocator.cpp Fri Jun 15 13:31:20 2018 +0200
+++ b/src/hotspot/share/gc/z/zPageAllocator.cpp Fri Jun 15 13:31:27 2018 +0200
@@ -459,24 +459,25 @@
satisfy_alloc_queue();
}
+bool ZPageAllocator::is_alloc_stalled() const {
+ assert(SafepointSynchronize::is_at_safepoint(), "Should be at safepoint");
+ return !_queue.is_empty();
+}
+
void ZPageAllocator::check_out_of_memory() {
ZLocker locker(&_lock);
- ZPageAllocRequest* const first = _queue.first();
- if (first == NULL) {
- // Allocation queue is empty
- return;
- }
-
- // Fail the allocation request if it was enqueued before the
+ // Fail allocation requests that were enqueued before the
// last GC cycle started, otherwise start a new GC cycle.
- if (first->total_collections() < ZCollectedHeap::heap()->total_collections()) {
- // Out of memory, fail all enqueued requests
- for (ZPageAllocRequest* request = _queue.remove_first(); request != NULL; request = _queue.remove_first()) {
- request->satisfy(NULL);
+ for (ZPageAllocRequest* request = _queue.first(); request != NULL; request = _queue.first()) {
+ if (request->total_collections() == ZCollectedHeap::heap()->total_collections()) {
+ // Start a new GC cycle, keep allocation requests enqueued
+ request->satisfy(gc_marker);
+ return;
}
- } else {
- // Start another GC cycle, keep all enqueued requests
- first->satisfy(gc_marker);
+
+ // Out of memory, fail allocation request
+ _queue.remove_first();
+ request->satisfy(NULL);
}
}