Mercurial > hg > truffle
comparison src/share/vm/gc_implementation/g1/heapRegion.hpp @ 3766:c3f1170908be
7045330: G1: Simplify/fix the HeapRegionSeq class
7042285: G1: native memory leak during humongous object allocation
6804436: G1: heap region indices should be size_t
Summary: A series of fixes and improvements to the HeapRegionSeq class: a) replace the _regions growable array with a standard C array, b) avoid de-allocating / re-allocating HeapRegion instances when the heap shrinks / grows (fix for 7042285), c) introduce fast method to map address to HeapRegion via a "biased" array pointer, d) embed the _hrs object in G1CollectedHeap, instead of pointing to it via an indirection, e) assume that all the regions added to the HeapRegionSeq instance are contiguous, f) replace int's with size_t's for indexes (and expand that to HeapRegion as part of 6804436), g) remove unnecessary / unused methods, h) rename a couple of fields (_alloc_search_start and _seq_bottom), i) fix iterate_from() not to always start from index 0 irrespective of the region passed to it, j) add a verification method to check the HeapRegionSeq assumptions, k) always call the wrappers for _hrs.iterate(), _hrs_length(), and _hrs.at() from G1CollectedHeap, not those methods directly, and l) unify the code that expands the sequence (by either re-using or creating a new HeapRegion) and make it robust wrt to a HeapRegion allocation failing.
Reviewed-by: stefank, johnc, brutisso
author | tonyp |
---|---|
date | Fri, 10 Jun 2011 13:16:40 -0400 |
parents | 063382f9b575 |
children | 6747fd0512e0 |
comparison
equal
deleted
inserted
replaced
3765:ae5b2f1dcf12 | 3766:c3f1170908be |
---|---|
50 class HeapRegionRemSet; | 50 class HeapRegionRemSet; |
51 class HeapRegionRemSetIterator; | 51 class HeapRegionRemSetIterator; |
52 class HeapRegion; | 52 class HeapRegion; |
53 class HeapRegionSetBase; | 53 class HeapRegionSetBase; |
54 | 54 |
55 #define HR_FORMAT "%d:["PTR_FORMAT","PTR_FORMAT","PTR_FORMAT"]" | 55 #define HR_FORMAT SIZE_FORMAT":(%s)["PTR_FORMAT","PTR_FORMAT","PTR_FORMAT"]" |
56 #define HR_FORMAT_PARAMS(_hr_) (_hr_)->hrs_index(), (_hr_)->bottom(), \ | 56 #define HR_FORMAT_PARAMS(_hr_) \ |
57 (_hr_)->top(), (_hr_)->end() | 57 (_hr_)->hrs_index(), \ |
58 (_hr_)->is_survivor() ? "S" : (_hr_)->is_young() ? "E" : "-", \ | |
59 (_hr_)->bottom(), (_hr_)->top(), (_hr_)->end() | |
58 | 60 |
59 // A dirty card to oop closure for heap regions. It | 61 // A dirty card to oop closure for heap regions. It |
60 // knows how to get the G1 heap and how to use the bitmap | 62 // knows how to get the G1 heap and how to use the bitmap |
61 // in the concurrent marker used by G1 to filter remembered | 63 // in the concurrent marker used by G1 to filter remembered |
62 // sets. | 64 // sets. |
235 HeapRegionRemSet* _rem_set; | 237 HeapRegionRemSet* _rem_set; |
236 | 238 |
237 G1BlockOffsetArrayContigSpace* offsets() { return &_offsets; } | 239 G1BlockOffsetArrayContigSpace* offsets() { return &_offsets; } |
238 | 240 |
239 protected: | 241 protected: |
240 // If this region is a member of a HeapRegionSeq, the index in that | 242 // The index of this region in the heap region sequence. |
241 // sequence, otherwise -1. | 243 size_t _hrs_index; |
242 int _hrs_index; | |
243 | 244 |
244 HumongousType _humongous_type; | 245 HumongousType _humongous_type; |
245 // For a humongous region, region in which it starts. | 246 // For a humongous region, region in which it starts. |
246 HeapRegion* _humongous_start_region; | 247 HeapRegion* _humongous_start_region; |
247 // For the start region of a humongous sequence, it's original end(). | 248 // For the start region of a humongous sequence, it's original end(). |
294 // </PREDICTION> | 295 // </PREDICTION> |
295 | 296 |
296 enum YoungType { | 297 enum YoungType { |
297 NotYoung, // a region is not young | 298 NotYoung, // a region is not young |
298 Young, // a region is young | 299 Young, // a region is young |
299 Survivor // a region is young and it contains | 300 Survivor // a region is young and it contains survivors |
300 // survivor | |
301 }; | 301 }; |
302 | 302 |
303 volatile YoungType _young_type; | 303 volatile YoungType _young_type; |
304 int _young_index_in_cset; | 304 int _young_index_in_cset; |
305 SurvRateGroup* _surv_rate_group; | 305 SurvRateGroup* _surv_rate_group; |
349 // the total value for the collection set. | 349 // the total value for the collection set. |
350 size_t _predicted_bytes_to_copy; | 350 size_t _predicted_bytes_to_copy; |
351 | 351 |
352 public: | 352 public: |
353 // If "is_zeroed" is "true", the region "mr" can be assumed to contain zeros. | 353 // If "is_zeroed" is "true", the region "mr" can be assumed to contain zeros. |
354 HeapRegion(G1BlockOffsetSharedArray* sharedOffsetArray, | 354 HeapRegion(size_t hrs_index, |
355 G1BlockOffsetSharedArray* sharedOffsetArray, | |
355 MemRegion mr, bool is_zeroed); | 356 MemRegion mr, bool is_zeroed); |
356 | 357 |
357 static int LogOfHRGrainBytes; | 358 static int LogOfHRGrainBytes; |
358 static int LogOfHRGrainWords; | 359 static int LogOfHRGrainWords; |
359 // The normal type of these should be size_t. However, they used to | 360 // The normal type of these should be size_t. However, they used to |
391 return ContiguousSpace::allocate(word_size); | 392 return ContiguousSpace::allocate(word_size); |
392 } | 393 } |
393 | 394 |
394 // If this region is a member of a HeapRegionSeq, the index in that | 395 // If this region is a member of a HeapRegionSeq, the index in that |
395 // sequence, otherwise -1. | 396 // sequence, otherwise -1. |
396 int hrs_index() const { return _hrs_index; } | 397 size_t hrs_index() const { return _hrs_index; } |
397 void set_hrs_index(int index) { _hrs_index = index; } | |
398 | 398 |
399 // The number of bytes marked live in the region in the last marking phase. | 399 // The number of bytes marked live in the region in the last marking phase. |
400 size_t marked_bytes() { return _prev_marked_bytes; } | 400 size_t marked_bytes() { return _prev_marked_bytes; } |
401 size_t live_bytes() { | 401 size_t live_bytes() { |
402 return (top() - prev_top_at_mark_start()) * HeapWordSize + marked_bytes(); | 402 return (top() - prev_top_at_mark_start()) * HeapWordSize + marked_bytes(); |
577 HeapRegion* get_next_dirty_cards_region() const { return _next_dirty_cards_region; } | 577 HeapRegion* get_next_dirty_cards_region() const { return _next_dirty_cards_region; } |
578 HeapRegion** next_dirty_cards_region_addr() { return &_next_dirty_cards_region; } | 578 HeapRegion** next_dirty_cards_region_addr() { return &_next_dirty_cards_region; } |
579 void set_next_dirty_cards_region(HeapRegion* hr) { _next_dirty_cards_region = hr; } | 579 void set_next_dirty_cards_region(HeapRegion* hr) { _next_dirty_cards_region = hr; } |
580 bool is_on_dirty_cards_region_list() const { return get_next_dirty_cards_region() != NULL; } | 580 bool is_on_dirty_cards_region_list() const { return get_next_dirty_cards_region() != NULL; } |
581 | 581 |
582 HeapWord* orig_end() { return _orig_end; } | |
583 | |
582 // Allows logical separation between objects allocated before and after. | 584 // Allows logical separation between objects allocated before and after. |
583 void save_marks(); | 585 void save_marks(); |
584 | 586 |
585 // Reset HR stuff to default values. | 587 // Reset HR stuff to default values. |
586 void hr_clear(bool par, bool clear_space); | 588 void hr_clear(bool par, bool clear_space); |