--- old/src/hotspot/share/gc/g1/heapRegionManager.hpp 2018-10-05 11:10:34.958862100 -0700 +++ new/src/hotspot/share/gc/g1/heapRegionManager.hpp 2018-10-05 11:10:34.092875700 -0700 @@ -71,16 +71,19 @@ friend class VMStructs; friend class HeapRegionClaimer; + protected: G1HeapRegionTable _regions; - G1RegionToSpaceMapper* _heap_mapper; + private: G1RegionToSpaceMapper* _prev_bitmap_mapper; G1RegionToSpaceMapper* _next_bitmap_mapper; G1RegionToSpaceMapper* _bot_mapper; G1RegionToSpaceMapper* _cardtable_mapper; G1RegionToSpaceMapper* _card_counts_mapper; + protected: FreeRegionList _free_list; + private: // Each bit in this bitmap indicates that the corresponding region is available // for allocation. @@ -95,11 +98,12 @@ HeapWord* heap_bottom() const { return _regions.bottom_address_mapped(); } HeapWord* heap_end() const {return _regions.end_address_mapped(); } + protected: void make_regions_available(uint index, uint num_regions = 1, WorkGang* pretouch_gang = NULL); - + void uncommit_regions(uint index, size_t num_regions = 1); + private: // 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,14 +121,17 @@ // 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; - // Allocate a new HeapRegion for the given index. - HeapRegion* new_heap_region(uint hrm_index); #ifdef ASSERT public: bool is_free(HeapRegion* hr) const; -#endif + bool is_available(uint region) const; +#else // Returns whether the given region is available for allocation. +protected: bool is_available(uint region) const; +#endif + // Allocate a new HeapRegion for the given index. + HeapRegion* new_heap_region(uint hrm_index); public: // Empty constructor, we'll initialize it with the initialize() method. @@ -141,7 +148,7 @@ // 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. @@ -163,7 +170,7 @@ _free_list.add_ordered(list); } - HeapRegion* allocate_free_region(bool is_old) { + virtual HeapRegion* allocate_free_region(bool is_old) { HeapRegion* hr = _free_list.remove_region(is_old); if (hr != NULL) { @@ -197,6 +204,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; @@ -206,26 +216,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 @@ -240,13 +250,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;