< prev index next >
src/hotspot/share/gc/g1/heapRegionManager.hpp
Print this page
rev 51649 : version 1
rev 51650 : added comments
rev 52017 : All changes for G1 GC moved from 'combined' repo folder
rev 52487 : Worked on comments from Sangheon, Stefan
rev 52488 : Merge
rev 52489 : minor changes
rev 52497 : To compile without precompiled headers
*** 24,33 ****
--- 24,34 ----
#ifndef SHARE_VM_GC_G1_HEAPREGIONMANAGER_HPP
#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 "services/memoryUsage.hpp"
class HeapRegion;
*** 69,89 ****
class HeapRegionManager: public CHeapObj<mtGC> {
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;
// The number of regions committed in the heap.
--- 70,85 ----
*** 93,107 ****
uint _allocated_heapregions_length;
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);
// Find a contiguous set of empty or uncommitted regions of length num and return
--- 89,100 ----
*** 115,146 ****
uint find_unavailable_from_idx(uint start_idx, uint* res_idx) const;
// Finds the next sequence of empty regions starting from start_idx, going backwards in
// 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
public:
// 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);
// 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); }
// Return the HeapRegion at the given index. Assume that the index
// is valid.
inline HeapRegion* at(uint index) const;
--- 108,153 ----
uint find_unavailable_from_idx(uint start_idx, uint* res_idx) const;
// Finds the next sequence of empty regions starting from start_idx, going backwards in
// 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;
+ 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
public:
bool is_free(HeapRegion* hr) const;
#endif
public:
// Empty constructor, we'll initialize it with the initialize() method.
HeapRegionManager();
+ static HeapRegionManager* create_manager(G1CollectedHeap* heap, CollectorPolicy* policy);
+
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.
! virtual HeapRegion* get_dummy_region() { return new_heap_region(0); }
// Return the HeapRegion at the given index. Assume that the index
// is valid.
inline HeapRegion* at(uint index) const;
*** 165,175 ****
// Insert the given region list into the global free region list.
void insert_list_into_free_list(FreeRegionList* list) {
_free_list.add_ordered(list);
}
! HeapRegion* allocate_free_region(bool is_old) {
HeapRegion* hr = _free_list.remove_region(is_old);
if (hr != NULL) {
assert(hr->next() == NULL, "Single region should not have next");
assert(is_available(hr->hrm_index()), "Must be committed");
--- 172,182 ----
// Insert the given region list into the global free region list.
void insert_list_into_free_list(FreeRegionList* list) {
_free_list.add_ordered(list);
}
! virtual HeapRegion* allocate_free_region(bool is_old) {
HeapRegion* hr = _free_list.remove_region(is_old);
if (hr != NULL) {
assert(hr->next() == NULL, "Single region should not have next");
assert(is_available(hr->hrm_index()), "Must be committed");
*** 200,237 ****
uint length() const { return _num_committed; }
// Return the maximum number of regions in the heap.
uint max_length() const { return (uint)_regions.length(); }
MemoryUsage get_auxiliary_data_memory_usage() const;
MemRegion reserved() const { return MemRegion(heap_bottom(), heap_end()); }
// Expand the sequence to reflect that the heap has grown. Either create new
// 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);
// 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);
// 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); }
// 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); }
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);
// Allocate the regions that contain the address range specified, committing the
// regions if necessary. Return false if any of the regions is already committed
// and not free, and return the number of regions newly committed in commit_count.
bool allocate_containing_regions(MemRegion range, size_t* commit_count, WorkGang* pretouch_workers);
--- 207,247 ----
uint length() const { return _num_committed; }
// 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()); }
// Expand the sequence to reflect that the heap has grown. Either create new
// 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.
! 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.
! 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.
! 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.
! 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.
! 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
// and not free, and return the number of regions newly committed in commit_count.
bool allocate_containing_regions(MemRegion range, size_t* commit_count, WorkGang* pretouch_workers);
*** 242,258 ****
void par_iterate(HeapRegionClosure* blk, HeapRegionClaimer* hrclaimer, const uint start_index) const;
// 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);
// 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();
// Do some sanity checking.
void verify_optional() PRODUCT_RETURN;
};
--- 252,268 ----
void par_iterate(HeapRegionClosure* blk, HeapRegionClaimer* hrclaimer, const uint start_index) const;
// Uncommit up to num_regions_to_remove regions that are completely free.
// Return the actual number of uncommitted regions.
! 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);
! virtual void verify();
// Do some sanity checking.
void verify_optional() PRODUCT_RETURN;
};
< prev index next >