Mercurial > hg > truffle
comparison src/share/vm/gc_implementation/g1/sparsePRT.cpp @ 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 | 97ba643ea3ed |
children | 720b6a76dd9d |
comparison
equal
deleted
inserted
replaced
3765:ae5b2f1dcf12 | 3766:c3f1170908be |
---|---|
479 return sizeof(this) + _next->mem_size(); | 479 return sizeof(this) + _next->mem_size(); |
480 } | 480 } |
481 | 481 |
482 bool SparsePRT::add_card(RegionIdx_t region_id, CardIdx_t card_index) { | 482 bool SparsePRT::add_card(RegionIdx_t region_id, CardIdx_t card_index) { |
483 #if SPARSE_PRT_VERBOSE | 483 #if SPARSE_PRT_VERBOSE |
484 gclog_or_tty->print_cr(" Adding card %d from region %d to region %d sparse.", | 484 gclog_or_tty->print_cr(" Adding card %d from region %d to region " |
485 card_index, region_id, _hr->hrs_index()); | 485 SIZE_FORMAT" sparse.", |
486 card_index, region_id, _hr->hrs_index()); | |
486 #endif | 487 #endif |
487 if (_next->occupied_entries() * 2 > _next->capacity()) { | 488 if (_next->occupied_entries() * 2 > _next->capacity()) { |
488 expand(); | 489 expand(); |
489 } | 490 } |
490 return _next->add_card(region_id, card_index); | 491 return _next->add_card(region_id, card_index); |
531 void SparsePRT::expand() { | 532 void SparsePRT::expand() { |
532 RSHashTable* last = _next; | 533 RSHashTable* last = _next; |
533 _next = new RSHashTable(last->capacity() * 2); | 534 _next = new RSHashTable(last->capacity() * 2); |
534 | 535 |
535 #if SPARSE_PRT_VERBOSE | 536 #if SPARSE_PRT_VERBOSE |
536 gclog_or_tty->print_cr(" Expanded sparse table for %d to %d.", | 537 gclog_or_tty->print_cr(" Expanded sparse table for "SIZE_FORMAT" to %d.", |
537 _hr->hrs_index(), _next->capacity()); | 538 _hr->hrs_index(), _next->capacity()); |
538 #endif | 539 #endif |
539 for (size_t i = 0; i < last->capacity(); i++) { | 540 for (size_t i = 0; i < last->capacity(); i++) { |
540 SparsePRTEntry* e = last->entry((int)i); | 541 SparsePRTEntry* e = last->entry((int)i); |
541 if (e->valid_entry()) { | 542 if (e->valid_entry()) { |
542 #if SPARSE_PRT_VERBOSE | 543 #if SPARSE_PRT_VERBOSE |