1.1 --- a/src/share/vm/gc_implementation/g1/heapRegionSeq.hpp Tue Sep 24 10:14:02 2013 +0200 1.2 +++ b/src/share/vm/gc_implementation/g1/heapRegionSeq.hpp Wed Sep 25 13:25:24 2013 +0200 1.3 @@ -25,10 +25,17 @@ 1.4 #ifndef SHARE_VM_GC_IMPLEMENTATION_G1_HEAPREGIONSEQ_HPP 1.5 #define SHARE_VM_GC_IMPLEMENTATION_G1_HEAPREGIONSEQ_HPP 1.6 1.7 +#include "gc_implementation/g1/g1BiasedArray.hpp" 1.8 + 1.9 class HeapRegion; 1.10 class HeapRegionClosure; 1.11 class FreeRegionList; 1.12 1.13 +class G1HeapRegionTable : public G1BiasedMappedArray<HeapRegion*> { 1.14 + protected: 1.15 + virtual HeapRegion* default_value() const { return NULL; } 1.16 +}; 1.17 + 1.18 // This class keeps track of the region metadata (i.e., HeapRegion 1.19 // instances). They are kept in the _regions array in address 1.20 // order. A region's index in the array corresponds to its index in 1.21 @@ -44,35 +51,21 @@ 1.22 // 1.23 // We keep track of three lengths: 1.24 // 1.25 -// * _length (returned by length()) is the number of currently 1.26 +// * _committed_length (returned by length()) is the number of currently 1.27 // committed regions. 1.28 // * _allocated_length (not exposed outside this class) is the 1.29 // number of regions for which we have HeapRegions. 1.30 -// * _max_length (returned by max_length()) is the maximum number of 1.31 -// regions the heap can have. 1.32 +// * max_length() returns the maximum number of regions the heap can have. 1.33 // 1.34 -// and maintain that: _length <= _allocated_length <= _max_length 1.35 +// and maintain that: _committed_length <= _allocated_length <= max_length() 1.36 1.37 class HeapRegionSeq: public CHeapObj<mtGC> { 1.38 friend class VMStructs; 1.39 1.40 - // The array that holds the HeapRegions. 1.41 - HeapRegion** _regions; 1.42 - 1.43 - // Version of _regions biased to address 0 1.44 - HeapRegion** _regions_biased; 1.45 + G1HeapRegionTable _regions; 1.46 1.47 // The number of regions committed in the heap. 1.48 - uint _length; 1.49 - 1.50 - // The address of the first reserved word in the heap. 1.51 - HeapWord* _heap_bottom; 1.52 - 1.53 - // The address of the last reserved word in the heap - 1. 1.54 - HeapWord* _heap_end; 1.55 - 1.56 - // The log of the region byte size. 1.57 - uint _region_shift; 1.58 + uint _committed_length; 1.59 1.60 // A hint for which index to start searching from for humongous 1.61 // allocations. 1.62 @@ -81,37 +74,33 @@ 1.63 // The number of regions for which we have allocated HeapRegions for. 1.64 uint _allocated_length; 1.65 1.66 - // The maximum number of regions in the heap. 1.67 - uint _max_length; 1.68 - 1.69 // Find a contiguous set of empty regions of length num, starting 1.70 // from the given index. 1.71 uint find_contiguous_from(uint from, uint num); 1.72 1.73 - // Map a heap address to a biased region index. Assume that the 1.74 - // address is valid. 1.75 - inline uintx addr_to_index_biased(HeapWord* addr) const; 1.76 - 1.77 void increment_allocated_length() { 1.78 - assert(_allocated_length < _max_length, "pre-condition"); 1.79 + assert(_allocated_length < max_length(), "pre-condition"); 1.80 _allocated_length++; 1.81 } 1.82 1.83 void increment_length() { 1.84 - assert(_length < _max_length, "pre-condition"); 1.85 - _length++; 1.86 + assert(length() < max_length(), "pre-condition"); 1.87 + _committed_length++; 1.88 } 1.89 1.90 void decrement_length() { 1.91 - assert(_length > 0, "pre-condition"); 1.92 - _length--; 1.93 + assert(length() > 0, "pre-condition"); 1.94 + _committed_length--; 1.95 } 1.96 1.97 + HeapWord* heap_bottom() const { return _regions.bottom_address_mapped(); } 1.98 + HeapWord* heap_end() const {return _regions.end_address_mapped(); } 1.99 + 1.100 public: 1.101 // Empty contructor, we'll initialize it with the initialize() method. 1.102 - HeapRegionSeq() { } 1.103 + HeapRegionSeq() : _regions(), _committed_length(0), _next_search_index(0), _allocated_length(0) { } 1.104 1.105 - void initialize(HeapWord* bottom, HeapWord* end, uint max_length); 1.106 + void initialize(HeapWord* bottom, HeapWord* end); 1.107 1.108 // Return the HeapRegion at the given index. Assume that the index 1.109 // is valid. 1.110 @@ -126,10 +115,10 @@ 1.111 inline HeapRegion* addr_to_region_unsafe(HeapWord* addr) const; 1.112 1.113 // Return the number of regions that have been committed in the heap. 1.114 - uint length() const { return _length; } 1.115 + uint length() const { return _committed_length; } 1.116 1.117 // Return the maximum number of regions in the heap. 1.118 - uint max_length() const { return _max_length; } 1.119 + uint max_length() const { return (uint)_regions.length(); } 1.120 1.121 // Expand the sequence to reflect that the heap has grown from 1.122 // old_end to new_end. Either create new HeapRegions, or re-use