--- a/src/hotspot/share/gc/g1/heapRegionManager.hpp Fri Dec 21 18:26:55 2018 +0000
+++ b/src/hotspot/share/gc/g1/heapRegionManager.hpp Fri Dec 21 08:18:59 2018 -0800
@@ -26,8 +26,10 @@
#define SHARE_VM_GC_G1_HEAPREGIONMANAGER_HPP
#include "gc/g1/g1BiasedArray.hpp"
+#include "gc/g1/g1CollectorPolicy.hpp"
#include "gc/g1/g1RegionToSpaceMapper.hpp"
#include "gc/g1/heapRegionSet.hpp"
+#include "gc/shared/collectorPolicy.hpp"
#include "services/memoryUsage.hpp"
class HeapRegion;
@@ -71,17 +73,10 @@
friend class VMStructs;
friend class HeapRegionClaimer;
- G1HeapRegionTable _regions;
-
- G1RegionToSpaceMapper* _heap_mapper;
- G1RegionToSpaceMapper* _prev_bitmap_mapper;
- G1RegionToSpaceMapper* _next_bitmap_mapper;
G1RegionToSpaceMapper* _bot_mapper;
G1RegionToSpaceMapper* _cardtable_mapper;
G1RegionToSpaceMapper* _card_counts_mapper;
- FreeRegionList _free_list;
-
// Each bit in this bitmap indicates that the corresponding region is available
// for allocation.
CHeapBitMap _available_map;
@@ -95,11 +90,8 @@
HeapWord* heap_bottom() const { return _regions.bottom_address_mapped(); }
HeapWord* heap_end() const {return _regions.end_address_mapped(); }
- void make_regions_available(uint index, uint num_regions = 1, WorkGang* pretouch_gang = NULL);
-
// Pass down commit calls to the VirtualSpace.
void commit_regions(uint index, size_t num_regions = 1, WorkGang* pretouch_gang = NULL);
- void uncommit_regions(uint index, size_t num_regions = 1);
// Notify other data structures about change in the heap layout.
void update_committed_space(HeapWord* old_end, HeapWord* new_end);
@@ -117,6 +109,16 @@
// the heap. Returns the length of the sequence found. If this value is zero, no
// sequence could be found, otherwise res_idx contains the start index of this range.
uint find_empty_from_idx_reverse(uint start_idx, uint* res_idx) const;
+
+protected:
+ G1HeapRegionTable _regions;
+ G1RegionToSpaceMapper* _heap_mapper;
+ G1RegionToSpaceMapper* _prev_bitmap_mapper;
+ G1RegionToSpaceMapper* _next_bitmap_mapper;
+ FreeRegionList _free_list;
+
+ void make_regions_available(uint index, uint num_regions = 1, WorkGang* pretouch_gang = NULL);
+ void uncommit_regions(uint index, size_t num_regions = 1);
// Allocate a new HeapRegion for the given index.
HeapRegion* new_heap_region(uint hrm_index);
#ifdef ASSERT
@@ -127,18 +129,25 @@
// Empty constructor, we'll initialize it with the initialize() method.
HeapRegionManager();
- void initialize(G1RegionToSpaceMapper* heap_storage,
- G1RegionToSpaceMapper* prev_bitmap,
- G1RegionToSpaceMapper* next_bitmap,
- G1RegionToSpaceMapper* bot,
- G1RegionToSpaceMapper* cardtable,
- G1RegionToSpaceMapper* card_counts);
+ static HeapRegionManager* create_manager(G1CollectedHeap* heap, G1CollectorPolicy* policy);
+
+ virtual void initialize(G1RegionToSpaceMapper* heap_storage,
+ G1RegionToSpaceMapper* prev_bitmap,
+ G1RegionToSpaceMapper* next_bitmap,
+ G1RegionToSpaceMapper* bot,
+ G1RegionToSpaceMapper* cardtable,
+ G1RegionToSpaceMapper* card_counts);
+
+ // Prepare heap regions before and after full collection.
+ // Nothing to be done in this class.
+ virtual void prepare_for_full_collection_start() {}
+ virtual void prepare_for_full_collection_end() {}
// Return the "dummy" region used for G1AllocRegion. This is currently a hardwired
// new HeapRegion that owns HeapRegion at index 0. Since at the moment we commit
// the heap from the lowest address, this region (and its associated data
// structures) are available and we do not need to check further.
- HeapRegion* get_dummy_region() { return new_heap_region(0); }
+ virtual HeapRegion* get_dummy_region() { return new_heap_region(0); }
// Return the HeapRegion at the given index. Assume that the index
// is valid.
@@ -167,8 +176,8 @@
_free_list.add_ordered(list);
}
- HeapRegion* allocate_free_region(bool is_old) {
- HeapRegion* hr = _free_list.remove_region(is_old);
+ virtual HeapRegion* allocate_free_region(HeapRegionType type) {
+ HeapRegion* hr = _free_list.remove_region(!type.is_young());
if (hr != NULL) {
assert(hr->next() == NULL, "Single region should not have next");
@@ -202,6 +211,9 @@
// Return the maximum number of regions in the heap.
uint max_length() const { return (uint)_regions.length(); }
+ // Return maximum number of regions that heap can expand to.
+ virtual uint max_expandable_length() const { return (uint)_regions.length(); }
+
MemoryUsage get_auxiliary_data_memory_usage() const;
MemRegion reserved() const { return MemRegion(heap_bottom(), heap_end()); }
@@ -210,26 +222,26 @@
// HeapRegions, or re-use existing ones. Returns the number of regions the
// sequence was expanded by. If a HeapRegion allocation fails, the resulting
// number of regions might be smaller than what's desired.
- uint expand_by(uint num_regions, WorkGang* pretouch_workers);
+ virtual uint expand_by(uint num_regions, WorkGang* pretouch_workers);
// Makes sure that the regions from start to start+num_regions-1 are available
// for allocation. Returns the number of regions that were committed to achieve
// this.
- uint expand_at(uint start, uint num_regions, WorkGang* pretouch_workers);
+ virtual uint expand_at(uint start, uint num_regions, WorkGang* pretouch_workers);
// Find a contiguous set of empty regions of length num. Returns the start index of
// that set, or G1_NO_HRM_INDEX.
- uint find_contiguous_only_empty(size_t num) { return find_contiguous(num, true); }
+ virtual uint find_contiguous_only_empty(size_t num) { return find_contiguous(num, true); }
// Find a contiguous set of empty or unavailable regions of length num. Returns the
// start index of that set, or G1_NO_HRM_INDEX.
- uint find_contiguous_empty_or_unavailable(size_t num) { return find_contiguous(num, false); }
+ virtual uint find_contiguous_empty_or_unavailable(size_t num) { return find_contiguous(num, false); }
HeapRegion* next_region_in_heap(const HeapRegion* r) const;
// Find the highest free or uncommitted region in the reserved heap,
// and if uncommitted, commit it. If none are available, return G1_NO_HRM_INDEX.
// Set the 'expanded' boolean true if a new region was committed.
- uint find_highest_free(bool* expanded);
+ virtual uint find_highest_free(bool* expanded);
// Allocate the regions that contain the address range specified, committing the
// regions if necessary. Return false if any of the regions is already committed
@@ -244,13 +256,13 @@
// Uncommit up to num_regions_to_remove regions that are completely free.
// Return the actual number of uncommitted regions.
- uint shrink_by(uint num_regions_to_remove);
+ virtual uint shrink_by(uint num_regions_to_remove);
// Uncommit a number of regions starting at the specified index, which must be available,
// empty, and free.
void shrink_at(uint index, size_t num_regions);
- void verify();
+ virtual void verify();
// Do some sanity checking.
void verify_optional() PRODUCT_RETURN;