457 |
457 |
458 // Try satisfy blocked allocations |
458 // Try satisfy blocked allocations |
459 satisfy_alloc_queue(); |
459 satisfy_alloc_queue(); |
460 } |
460 } |
461 |
461 |
|
462 bool ZPageAllocator::is_alloc_stalled() const { |
|
463 assert(SafepointSynchronize::is_at_safepoint(), "Should be at safepoint"); |
|
464 return !_queue.is_empty(); |
|
465 } |
|
466 |
462 void ZPageAllocator::check_out_of_memory() { |
467 void ZPageAllocator::check_out_of_memory() { |
463 ZLocker locker(&_lock); |
468 ZLocker locker(&_lock); |
464 |
469 |
465 ZPageAllocRequest* const first = _queue.first(); |
470 // Fail allocation requests that were enqueued before the |
466 if (first == NULL) { |
|
467 // Allocation queue is empty |
|
468 return; |
|
469 } |
|
470 |
|
471 // Fail the allocation request if it was enqueued before the |
|
472 // last GC cycle started, otherwise start a new GC cycle. |
471 // last GC cycle started, otherwise start a new GC cycle. |
473 if (first->total_collections() < ZCollectedHeap::heap()->total_collections()) { |
472 for (ZPageAllocRequest* request = _queue.first(); request != NULL; request = _queue.first()) { |
474 // Out of memory, fail all enqueued requests |
473 if (request->total_collections() == ZCollectedHeap::heap()->total_collections()) { |
475 for (ZPageAllocRequest* request = _queue.remove_first(); request != NULL; request = _queue.remove_first()) { |
474 // Start a new GC cycle, keep allocation requests enqueued |
476 request->satisfy(NULL); |
475 request->satisfy(gc_marker); |
|
476 return; |
477 } |
477 } |
478 } else { |
478 |
479 // Start another GC cycle, keep all enqueued requests |
479 // Out of memory, fail allocation request |
480 first->satisfy(gc_marker); |
480 _queue.remove_first(); |
481 } |
481 request->satisfy(NULL); |
482 } |
482 } |
|
483 } |