1.1 --- a/src/share/vm/gc_implementation/g1/heapRegionRemSet.cpp Mon Mar 24 15:30:14 2014 +0100 1.2 +++ b/src/share/vm/gc_implementation/g1/heapRegionRemSet.cpp Mon Mar 24 15:30:30 2014 +0100 1.3 @@ -29,6 +29,7 @@ 1.4 #include "gc_implementation/g1/heapRegionRemSet.hpp" 1.5 #include "gc_implementation/g1/heapRegionSeq.inline.hpp" 1.6 #include "memory/allocation.hpp" 1.7 +#include "memory/padded.inline.hpp" 1.8 #include "memory/space.inline.hpp" 1.9 #include "oops/oop.inline.hpp" 1.10 #include "utilities/bitMap.inline.hpp" 1.11 @@ -358,27 +359,29 @@ 1.12 } 1.13 1.14 int** OtherRegionsTable::_from_card_cache = NULL; 1.15 -size_t OtherRegionsTable::_from_card_cache_max_regions = 0; 1.16 +uint OtherRegionsTable::_from_card_cache_max_regions = 0; 1.17 size_t OtherRegionsTable::_from_card_cache_mem_size = 0; 1.18 1.19 -void OtherRegionsTable::init_from_card_cache(size_t max_regions) { 1.20 +void OtherRegionsTable::init_from_card_cache(uint max_regions) { 1.21 + guarantee(_from_card_cache == NULL, "Should not call this multiple times"); 1.22 + uint n_par_rs = HeapRegionRemSet::num_par_rem_sets(); 1.23 + 1.24 _from_card_cache_max_regions = max_regions; 1.25 + _from_card_cache = Padded2DArray<int, mtGC>::create_unfreeable(n_par_rs, 1.26 + _from_card_cache_max_regions, 1.27 + &_from_card_cache_mem_size); 1.28 1.29 - int n_par_rs = HeapRegionRemSet::num_par_rem_sets(); 1.30 - _from_card_cache = NEW_C_HEAP_ARRAY(int*, n_par_rs, mtGC); 1.31 - for (int i = 0; i < n_par_rs; i++) { 1.32 - _from_card_cache[i] = NEW_C_HEAP_ARRAY(int, max_regions, mtGC); 1.33 - for (size_t j = 0; j < max_regions; j++) { 1.34 + for (uint i = 0; i < n_par_rs; i++) { 1.35 + for (uint j = 0; j < _from_card_cache_max_regions; j++) { 1.36 _from_card_cache[i][j] = -1; // An invalid value. 1.37 } 1.38 } 1.39 - _from_card_cache_mem_size = n_par_rs * max_regions * sizeof(int); 1.40 } 1.41 1.42 -void OtherRegionsTable::shrink_from_card_cache(size_t new_n_regs) { 1.43 - for (int i = 0; i < HeapRegionRemSet::num_par_rem_sets(); i++) { 1.44 +void OtherRegionsTable::shrink_from_card_cache(uint new_n_regs) { 1.45 + for (uint i = 0; i < HeapRegionRemSet::num_par_rem_sets(); i++) { 1.46 assert(new_n_regs <= _from_card_cache_max_regions, "Must be within max."); 1.47 - for (size_t j = new_n_regs; j < _from_card_cache_max_regions; j++) { 1.48 + for (uint j = new_n_regs; j < _from_card_cache_max_regions; j++) { 1.49 _from_card_cache[i][j] = -1; // An invalid value. 1.50 } 1.51 } 1.52 @@ -386,8 +389,8 @@ 1.53 1.54 #ifndef PRODUCT 1.55 void OtherRegionsTable::print_from_card_cache() { 1.56 - for (int i = 0; i < HeapRegionRemSet::num_par_rem_sets(); i++) { 1.57 - for (size_t j = 0; j < _from_card_cache_max_regions; j++) { 1.58 + for (uint i = 0; i < HeapRegionRemSet::num_par_rem_sets(); i++) { 1.59 + for (uint j = 0; j < _from_card_cache_max_regions; j++) { 1.60 gclog_or_tty->print_cr("_from_card_cache[%d][%d] = %d.", 1.61 i, j, _from_card_cache[i][j]); 1.62 } 1.63 @@ -727,8 +730,8 @@ 1.64 } 1.65 1.66 void OtherRegionsTable::clear_fcc() { 1.67 - size_t hrs_idx = hr()->hrs_index(); 1.68 - for (int i = 0; i < HeapRegionRemSet::num_par_rem_sets(); i++) { 1.69 + uint hrs_idx = hr()->hrs_index(); 1.70 + for (uint i = 0; i < HeapRegionRemSet::num_par_rem_sets(); i++) { 1.71 _from_card_cache[i][hrs_idx] = -1; 1.72 } 1.73 } 1.74 @@ -762,8 +765,8 @@ 1.75 _coarse_map.par_at_put(hrs_ind, 0); 1.76 } 1.77 // Check to see if any of the fcc entries come from here. 1.78 - size_t hr_ind = (size_t) hr()->hrs_index(); 1.79 - for (int tid = 0; tid < HeapRegionRemSet::num_par_rem_sets(); tid++) { 1.80 + uint hr_ind = hr()->hrs_index(); 1.81 + for (uint tid = 0; tid < HeapRegionRemSet::num_par_rem_sets(); tid++) { 1.82 int fcc_ent = _from_card_cache[tid][hr_ind]; 1.83 if (fcc_ent != -1) { 1.84 HeapWord* card_addr = (HeapWord*) 1.85 @@ -838,8 +841,8 @@ 1.86 // Determines how many threads can add records to an rset in parallel. 1.87 // This can be done by either mutator threads together with the 1.88 // concurrent refinement threads or GC threads. 1.89 -int HeapRegionRemSet::num_par_rem_sets() { 1.90 - return (int)MAX2(DirtyCardQueueSet::num_par_ids() + ConcurrentG1Refine::thread_num(), ParallelGCThreads); 1.91 +uint HeapRegionRemSet::num_par_rem_sets() { 1.92 + return (uint)MAX2(DirtyCardQueueSet::num_par_ids() + ConcurrentG1Refine::thread_num(), ParallelGCThreads); 1.93 } 1.94 1.95 HeapRegionRemSet::HeapRegionRemSet(G1BlockOffsetSharedArray* bosa,