< prev index next >
src/hotspot/share/gc/g1/g1CollectedHeap.hpp
Print this page
rev 48467 : 8137099: G1 needs to "upgrade" GC within the safepoint if it can't allocate during that safepoint to avoid OoME
Summary: During a minor GC, if memory allocation fails, start a full GC within the same VM operation in the same safepoint. This avoids a race where the GC locker can prevent the full GC from occurring, and a premature OoME.
Reviewed-by:
Contributed-by: thomas.schatzl@oracle.com, axel.siebenborn@sap.com
rev 48469 : imported patch 8137099-sjohanns-messages
rev 48470 : [mq]: 8137099-erikd-review
rev 48471 : [mq]: 8137099-erikd-review2
@@ -1,7 +1,7 @@
/*
- * Copyright (c) 2001, 2017, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2001, 2018, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
@@ -123,11 +123,10 @@
class G1CollectedHeap : public CollectedHeap {
friend class G1FreeCollectionSetTask;
friend class VM_CollectForMetadataAllocation;
friend class VM_G1CollectForAllocation;
friend class VM_G1CollectFull;
- friend class VM_G1IncCollectionPause;
friend class VMStructs;
friend class MutatorAllocRegion;
friend class G1FullCollector;
friend class G1GCAllocRegion;
friend class G1HeapVerifier;
@@ -452,39 +451,24 @@
virtual HeapWord* allocate_new_tlab(size_t word_size);
virtual HeapWord* mem_allocate(size_t word_size,
bool* gc_overhead_limit_was_exceeded);
- // The following three methods take a gc_count_before_ret
- // parameter which is used to return the GC count if the method
- // returns NULL. Given that we are required to read the GC count
- // while holding the Heap_lock, and these paths will take the
- // Heap_lock at some point, it's easier to get them to read the GC
- // count while holding the Heap_lock before they return NULL instead
- // of the caller (namely: mem_allocate()) having to also take the
- // Heap_lock just to read the GC count.
-
// First-level mutator allocation attempt: try to allocate out of
// the mutator alloc region without taking the Heap_lock. This
// should only be used for non-humongous allocations.
- inline HeapWord* attempt_allocation(size_t word_size,
- uint* gc_count_before_ret,
- uint* gclocker_retry_count_ret);
+ inline HeapWord* attempt_allocation(size_t word_size);
// Second-level mutator allocation attempt: take the Heap_lock and
// retry the allocation attempt, potentially scheduling a GC
// pause. This should only be used for non-humongous allocations.
HeapWord* attempt_allocation_slow(size_t word_size,
- AllocationContext_t context,
- uint* gc_count_before_ret,
- uint* gclocker_retry_count_ret);
+ AllocationContext_t context);
// Takes the Heap_lock and attempts a humongous allocation. It can
// potentially schedule a GC pause.
- HeapWord* attempt_allocation_humongous(size_t word_size,
- uint* gc_count_before_ret,
- uint* gclocker_retry_count_ret);
+ HeapWord* attempt_allocation_humongous(size_t word_size);
// Allocation attempt that should be called during safepoints (e.g.,
// at the end of a successful GC). expect_null_mutator_alloc_region
// specifies whether the mutator alloc region is expected to be NULL
// or not.
@@ -1076,10 +1060,15 @@
virtual bool is_maximal_no_gc() const {
return _hrm.available() == 0;
}
+ // Returns whether there are any regions left in the heap for allocation.
+ bool has_regions_left_for_allocation() const {
+ return !is_maximal_no_gc() || num_free_regions() != 0;
+ }
+
// The current number of regions in the heap.
uint num_regions() const { return _hrm.length(); }
// The max number of regions in the heap.
uint max_regions() const { return _hrm.max_length(); }
< prev index next >