src/share/vm/gc_implementation/g1/concurrentMark.inline.hpp

Print this page
rev 6923 : imported patch 8054819-rename-heapregionseq
rev 6924 : 8055919: Remove dead code in G1 concurrent marking code
Reviewed-by:


 108     // end of region is not card aligned - increment to cover
 109     // all the cards spanned by the region.
 110     end_idx += 1;
 111   }
 112   // The card bitmap is task/worker specific => no need to use
 113   // the 'par' BitMap routines.
 114   // Set bits in the exclusive bit range [start_idx, end_idx).
 115   set_card_bitmap_range(task_card_bm, start_idx, end_idx, false /* is_par */);
 116 }
 117 
 118 // Counts the given memory region in the task/worker counting
 119 // data structures for the given worker id.
 120 inline void ConcurrentMark::count_region(MemRegion mr,
 121                                          HeapRegion* hr,
 122                                          uint worker_id) {
 123   size_t* marked_bytes_array = count_marked_bytes_array_for(worker_id);
 124   BitMap* task_card_bm = count_card_bitmap_for(worker_id);
 125   count_region(mr, hr, marked_bytes_array, task_card_bm);
 126 }
 127 
 128 // Counts the given memory region, which may be a single object, in the
 129 // task/worker counting data structures for the given worker id.
 130 inline void ConcurrentMark::count_region(MemRegion mr, uint worker_id) {
 131   HeapWord* addr = mr.start();
 132   HeapRegion* hr = _g1h->heap_region_containing_raw(addr);
 133   count_region(mr, hr, worker_id);
 134 }
 135 
 136 // Counts the given object in the given task/worker counting data structures.
 137 inline void ConcurrentMark::count_object(oop obj,
 138                                          HeapRegion* hr,
 139                                          size_t* marked_bytes_array,
 140                                          BitMap* task_card_bm) {
 141   MemRegion mr((HeapWord*)obj, obj->size());
 142   count_region(mr, hr, marked_bytes_array, task_card_bm);
 143 }
 144 
 145 // Counts the given object in the task/worker counting data
 146 // structures for the given worker id.
 147 inline void ConcurrentMark::count_object(oop obj,
 148                                          HeapRegion* hr,
 149                                          uint worker_id) {
 150   size_t* marked_bytes_array = count_marked_bytes_array_for(worker_id);
 151   BitMap* task_card_bm = count_card_bitmap_for(worker_id);
 152   HeapWord* addr = (HeapWord*) obj;
 153   count_object(obj, hr, marked_bytes_array, task_card_bm);
 154 }
 155 
 156 // Attempts to mark the given object and, if successful, counts
 157 // the object in the given task/worker counting structures.
 158 inline bool ConcurrentMark::par_mark_and_count(oop obj,
 159                                                HeapRegion* hr,
 160                                                size_t* marked_bytes_array,
 161                                                BitMap* task_card_bm) {
 162   HeapWord* addr = (HeapWord*)obj;
 163   if (_nextMarkBitMap->parMark(addr)) {
 164     // Update the task specific count data for the object.
 165     count_object(obj, hr, marked_bytes_array, task_card_bm);
 166     return true;
 167   }
 168   return false;
 169 }
 170 
 171 // Attempts to mark the given object and, if successful, counts
 172 // the object in the task/worker counting structures for the
 173 // given worker id.
 174 inline bool ConcurrentMark::par_mark_and_count(oop obj,
 175                                                size_t word_size,
 176                                                HeapRegion* hr,
 177                                                uint worker_id) {
 178   HeapWord* addr = (HeapWord*)obj;
 179   if (_nextMarkBitMap->parMark(addr)) {
 180     MemRegion mr(addr, word_size);
 181     count_region(mr, hr, worker_id);
 182     return true;
 183   }
 184   return false;
 185 }
 186 
 187 // Attempts to mark the given object and, if successful, counts
 188 // the object in the task/worker counting structures for the
 189 // given worker id.
 190 inline bool ConcurrentMark::par_mark_and_count(oop obj,
 191                                                HeapRegion* hr,
 192                                                uint worker_id) {
 193   HeapWord* addr = (HeapWord*)obj;
 194   if (_nextMarkBitMap->parMark(addr)) {
 195     // Update the task specific count data for the object.
 196     count_object(obj, hr, worker_id);
 197     return true;
 198   }
 199   return false;
 200 }
 201 
 202 // As above - but we don't know the heap region containing the
 203 // object and so have to supply it.
 204 inline bool ConcurrentMark::par_mark_and_count(oop obj, uint worker_id) {
 205   HeapWord* addr = (HeapWord*)obj;
 206   HeapRegion* hr = _g1h->heap_region_containing_raw(addr);
 207   return par_mark_and_count(obj, hr, worker_id);
 208 }
 209 
 210 // Similar to the above routine but we already know the size, in words, of
 211 // the object that we wish to mark/count
 212 inline bool ConcurrentMark::par_mark_and_count(oop obj,
 213                                                size_t word_size,
 214                                                uint worker_id) {
 215   HeapWord* addr = (HeapWord*)obj;
 216   if (_nextMarkBitMap->parMark(addr)) {
 217     // Update the task specific count data for the object.
 218     MemRegion mr(addr, word_size);
 219     count_region(mr, worker_id);
 220     return true;
 221   }
 222   return false;
 223 }
 224 
 225 // Unconditionally mark the given object, and unconditionally count
 226 // the object in the counting structures for worker id 0.
 227 // Should *not* be called from parallel code.
 228 inline bool ConcurrentMark::mark_and_count(oop obj, HeapRegion* hr) {
 229   HeapWord* addr = (HeapWord*)obj;
 230   _nextMarkBitMap->mark(addr);
 231   // Update the task specific count data for the object.
 232   count_object(obj, hr, 0 /* worker_id */);
 233   return true;
 234 }
 235 
 236 // As above - but we don't have the heap region containing the
 237 // object, so we have to supply it.
 238 inline bool ConcurrentMark::mark_and_count(oop obj) {
 239   HeapWord* addr = (HeapWord*)obj;
 240   HeapRegion* hr = _g1h->heap_region_containing_raw(addr);
 241   return mark_and_count(obj, hr);
 242 }
 243 
 244 inline bool CMBitMapRO::iterate(BitMapClosure* cl, MemRegion mr) {
 245   HeapWord* start_addr = MAX2(startWord(), mr.start());
 246   HeapWord* end_addr = MIN2(endWord(), mr.end());
 247 
 248   if (end_addr > start_addr) {
 249     // Right-open interval [start-offset, end-offset).
 250     BitMap::idx_t start_offset = heapWordToOffset(start_addr);
 251     BitMap::idx_t end_offset = heapWordToOffset(end_addr);
 252 
 253     start_offset = _bm.get_next_one_offset(start_offset, end_offset);
 254     while (start_offset < end_offset) {
 255       if (!cl->do_bit(start_offset)) {
 256         return false;
 257       }
 258       HeapWord* next_addr = MIN2(nextObject(offsetToHeapWord(start_offset)), end_addr);
 259       BitMap::idx_t next_offset = heapWordToOffset(next_addr);
 260       start_offset = _bm.get_next_one_offset(next_offset, end_offset);
 261     }




 108     // end of region is not card aligned - increment to cover
 109     // all the cards spanned by the region.
 110     end_idx += 1;
 111   }
 112   // The card bitmap is task/worker specific => no need to use
 113   // the 'par' BitMap routines.
 114   // Set bits in the exclusive bit range [start_idx, end_idx).
 115   set_card_bitmap_range(task_card_bm, start_idx, end_idx, false /* is_par */);
 116 }
 117 
 118 // Counts the given memory region in the task/worker counting
 119 // data structures for the given worker id.
 120 inline void ConcurrentMark::count_region(MemRegion mr,
 121                                          HeapRegion* hr,
 122                                          uint worker_id) {
 123   size_t* marked_bytes_array = count_marked_bytes_array_for(worker_id);
 124   BitMap* task_card_bm = count_card_bitmap_for(worker_id);
 125   count_region(mr, hr, marked_bytes_array, task_card_bm);
 126 }
 127 








 128 // Counts the given object in the given task/worker counting data structures.
 129 inline void ConcurrentMark::count_object(oop obj,
 130                                          HeapRegion* hr,
 131                                          size_t* marked_bytes_array,
 132                                          BitMap* task_card_bm) {
 133   MemRegion mr((HeapWord*)obj, obj->size());
 134   count_region(mr, hr, marked_bytes_array, task_card_bm);
 135 }
 136 











 137 // Attempts to mark the given object and, if successful, counts
 138 // the object in the given task/worker counting structures.
 139 inline bool ConcurrentMark::par_mark_and_count(oop obj,
 140                                                HeapRegion* hr,
 141                                                size_t* marked_bytes_array,
 142                                                BitMap* task_card_bm) {
 143   HeapWord* addr = (HeapWord*)obj;
 144   if (_nextMarkBitMap->parMark(addr)) {
 145     // Update the task specific count data for the object.
 146     count_object(obj, hr, marked_bytes_array, task_card_bm);
 147     return true;
 148   }
 149   return false;
 150 }
 151 
 152 // Attempts to mark the given object and, if successful, counts
 153 // the object in the task/worker counting structures for the
 154 // given worker id.
 155 inline bool ConcurrentMark::par_mark_and_count(oop obj,
 156                                                size_t word_size,
 157                                                HeapRegion* hr,
 158                                                uint worker_id) {
 159   HeapWord* addr = (HeapWord*)obj;
 160   if (_nextMarkBitMap->parMark(addr)) {
 161     MemRegion mr(addr, word_size);
 162     count_region(mr, hr, worker_id);
 163     return true;
 164   }
 165   return false;

























































 166 }
 167 
 168 inline bool CMBitMapRO::iterate(BitMapClosure* cl, MemRegion mr) {
 169   HeapWord* start_addr = MAX2(startWord(), mr.start());
 170   HeapWord* end_addr = MIN2(endWord(), mr.end());
 171 
 172   if (end_addr > start_addr) {
 173     // Right-open interval [start-offset, end-offset).
 174     BitMap::idx_t start_offset = heapWordToOffset(start_addr);
 175     BitMap::idx_t end_offset = heapWordToOffset(end_addr);
 176 
 177     start_offset = _bm.get_next_one_offset(start_offset, end_offset);
 178     while (start_offset < end_offset) {
 179       if (!cl->do_bit(start_offset)) {
 180         return false;
 181       }
 182       HeapWord* next_addr = MIN2(nextObject(offsetToHeapWord(start_offset)), end_addr);
 183       BitMap::idx_t next_offset = heapWordToOffset(next_addr);
 184       start_offset = _bm.get_next_one_offset(next_offset, end_offset);
 185     }