< prev index next >

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

Print this page




 180       if (!cl->do_bit(start_offset)) {
 181         return false;
 182       }
 183       HeapWord* next_addr = MIN2(nextObject(offsetToHeapWord(start_offset)), end_addr);
 184       BitMap::idx_t next_offset = heapWordToOffset(next_addr);
 185       start_offset = _bm.get_next_one_offset(next_offset, end_offset);
 186     }
 187   }
 188   return true;
 189 }
 190 
 191 inline bool CMBitMapRO::iterate(BitMapClosure* cl) {
 192   MemRegion mr(startWord(), sizeInWords());
 193   return iterate(cl, mr);
 194 }
 195 
 196 #define check_mark(addr)                                                       \
 197   assert(_bmStartWord <= (addr) && (addr) < (_bmStartWord + _bmWordSize),      \
 198          "outside underlying space?");                                         \
 199   assert(G1CollectedHeap::heap()->is_in_exact(addr),                           \
 200          err_msg("Trying to access not available bitmap "PTR_FORMAT            \
 201                  " corresponding to "PTR_FORMAT" (%u)",                        \
 202                  p2i(this), p2i(addr), G1CollectedHeap::heap()->addr_to_region(addr)));
 203 
 204 inline void CMBitMap::mark(HeapWord* addr) {
 205   check_mark(addr);
 206   _bm.set_bit(heapWordToOffset(addr));
 207 }
 208 
 209 inline void CMBitMap::clear(HeapWord* addr) {
 210   check_mark(addr);
 211   _bm.clear_bit(heapWordToOffset(addr));
 212 }
 213 
 214 inline bool CMBitMap::parMark(HeapWord* addr) {
 215   check_mark(addr);
 216   return _bm.par_set_bit(heapWordToOffset(addr));
 217 }
 218 
 219 inline bool CMBitMap::parClear(HeapWord* addr) {
 220   check_mark(addr);
 221   return _bm.par_clear_bit(heapWordToOffset(addr));


 327         // by only doing a bookkeeping update and avoiding the
 328         // actual scan of the object - a typeArray contains no
 329         // references, and the metadata is built-in.
 330         process_grey_object<false>(obj);
 331       } else {
 332         if (_cm->verbose_high()) {
 333           gclog_or_tty->print_cr("[%u] below a finger (local: " PTR_FORMAT
 334                                  ", global: " PTR_FORMAT ") pushing "
 335                                  PTR_FORMAT " on mark stack",
 336                                  _worker_id, p2i(_finger),
 337                                  p2i(global_finger), p2i(obj));
 338         }
 339         push(obj);
 340       }
 341     }
 342   }
 343 }
 344 
 345 inline void CMTask::deal_with_reference(oop obj) {
 346   if (_cm->verbose_high()) {
 347     gclog_or_tty->print_cr("[%u] we're dealing with reference = "PTR_FORMAT,
 348                            _worker_id, p2i((void*) obj));
 349   }
 350 
 351   increment_refs_reached();
 352 
 353   HeapWord* objAddr = (HeapWord*) obj;
 354   assert(obj->is_oop_or_null(true /* ignore mark word */), err_msg("Expected an oop or NULL at " PTR_FORMAT, p2i(obj)));
 355   if (_g1h->is_in_g1_reserved(objAddr)) {
 356     assert(obj != NULL, "null check is implicit");
 357     if (!_nextMarkBitMap->isMarked(objAddr)) {
 358       // Only get the containing region if the object is not marked on the
 359       // bitmap (otherwise, it's a waste of time since we won't do
 360       // anything with it).
 361       HeapRegion* hr = _g1h->heap_region_containing_raw(obj);
 362       if (!hr->obj_allocated_since_next_marking(obj)) {
 363         make_reference_grey(obj, hr);
 364       }
 365     }
 366   }
 367 }


 376 inline void ConcurrentMark::grayRoot(oop obj, size_t word_size,
 377                                      uint worker_id, HeapRegion* hr) {
 378   assert(obj != NULL, "pre-condition");
 379   HeapWord* addr = (HeapWord*) obj;
 380   if (hr == NULL) {
 381     hr = _g1h->heap_region_containing_raw(addr);
 382   } else {
 383     assert(hr->is_in(addr), "pre-condition");
 384   }
 385   assert(hr != NULL, "sanity");
 386   // Given that we're looking for a region that contains an object
 387   // header it's impossible to get back a HC region.
 388   assert(!hr->is_continues_humongous(), "sanity");
 389 
 390   // We cannot assert that word_size == obj->size() given that obj
 391   // might not be in a consistent state (another thread might be in
 392   // the process of copying it). So the best thing we can do is to
 393   // assert that word_size is under an upper bound which is its
 394   // containing region's capacity.
 395   assert(word_size * HeapWordSize <= hr->capacity(),
 396          err_msg("size: "SIZE_FORMAT" capacity: "SIZE_FORMAT" "HR_FORMAT,
 397                  word_size * HeapWordSize, hr->capacity(),
 398                  HR_FORMAT_PARAMS(hr)));
 399 
 400   if (addr < hr->next_top_at_mark_start()) {
 401     if (!_nextMarkBitMap->isMarked(addr)) {
 402       par_mark_and_count(obj, word_size, hr, worker_id);
 403     }
 404   }
 405 }
 406 
 407 #endif // SHARE_VM_GC_G1_CONCURRENTMARK_INLINE_HPP


 180       if (!cl->do_bit(start_offset)) {
 181         return false;
 182       }
 183       HeapWord* next_addr = MIN2(nextObject(offsetToHeapWord(start_offset)), end_addr);
 184       BitMap::idx_t next_offset = heapWordToOffset(next_addr);
 185       start_offset = _bm.get_next_one_offset(next_offset, end_offset);
 186     }
 187   }
 188   return true;
 189 }
 190 
 191 inline bool CMBitMapRO::iterate(BitMapClosure* cl) {
 192   MemRegion mr(startWord(), sizeInWords());
 193   return iterate(cl, mr);
 194 }
 195 
 196 #define check_mark(addr)                                                       \
 197   assert(_bmStartWord <= (addr) && (addr) < (_bmStartWord + _bmWordSize),      \
 198          "outside underlying space?");                                         \
 199   assert(G1CollectedHeap::heap()->is_in_exact(addr),                           \
 200          err_msg("Trying to access not available bitmap " PTR_FORMAT           \
 201                  " corresponding to " PTR_FORMAT " (%u)",                      \
 202                  p2i(this), p2i(addr), G1CollectedHeap::heap()->addr_to_region(addr)));
 203 
 204 inline void CMBitMap::mark(HeapWord* addr) {
 205   check_mark(addr);
 206   _bm.set_bit(heapWordToOffset(addr));
 207 }
 208 
 209 inline void CMBitMap::clear(HeapWord* addr) {
 210   check_mark(addr);
 211   _bm.clear_bit(heapWordToOffset(addr));
 212 }
 213 
 214 inline bool CMBitMap::parMark(HeapWord* addr) {
 215   check_mark(addr);
 216   return _bm.par_set_bit(heapWordToOffset(addr));
 217 }
 218 
 219 inline bool CMBitMap::parClear(HeapWord* addr) {
 220   check_mark(addr);
 221   return _bm.par_clear_bit(heapWordToOffset(addr));


 327         // by only doing a bookkeeping update and avoiding the
 328         // actual scan of the object - a typeArray contains no
 329         // references, and the metadata is built-in.
 330         process_grey_object<false>(obj);
 331       } else {
 332         if (_cm->verbose_high()) {
 333           gclog_or_tty->print_cr("[%u] below a finger (local: " PTR_FORMAT
 334                                  ", global: " PTR_FORMAT ") pushing "
 335                                  PTR_FORMAT " on mark stack",
 336                                  _worker_id, p2i(_finger),
 337                                  p2i(global_finger), p2i(obj));
 338         }
 339         push(obj);
 340       }
 341     }
 342   }
 343 }
 344 
 345 inline void CMTask::deal_with_reference(oop obj) {
 346   if (_cm->verbose_high()) {
 347     gclog_or_tty->print_cr("[%u] we're dealing with reference = " PTR_FORMAT,
 348                            _worker_id, p2i((void*) obj));
 349   }
 350 
 351   increment_refs_reached();
 352 
 353   HeapWord* objAddr = (HeapWord*) obj;
 354   assert(obj->is_oop_or_null(true /* ignore mark word */), err_msg("Expected an oop or NULL at " PTR_FORMAT, p2i(obj)));
 355   if (_g1h->is_in_g1_reserved(objAddr)) {
 356     assert(obj != NULL, "null check is implicit");
 357     if (!_nextMarkBitMap->isMarked(objAddr)) {
 358       // Only get the containing region if the object is not marked on the
 359       // bitmap (otherwise, it's a waste of time since we won't do
 360       // anything with it).
 361       HeapRegion* hr = _g1h->heap_region_containing_raw(obj);
 362       if (!hr->obj_allocated_since_next_marking(obj)) {
 363         make_reference_grey(obj, hr);
 364       }
 365     }
 366   }
 367 }


 376 inline void ConcurrentMark::grayRoot(oop obj, size_t word_size,
 377                                      uint worker_id, HeapRegion* hr) {
 378   assert(obj != NULL, "pre-condition");
 379   HeapWord* addr = (HeapWord*) obj;
 380   if (hr == NULL) {
 381     hr = _g1h->heap_region_containing_raw(addr);
 382   } else {
 383     assert(hr->is_in(addr), "pre-condition");
 384   }
 385   assert(hr != NULL, "sanity");
 386   // Given that we're looking for a region that contains an object
 387   // header it's impossible to get back a HC region.
 388   assert(!hr->is_continues_humongous(), "sanity");
 389 
 390   // We cannot assert that word_size == obj->size() given that obj
 391   // might not be in a consistent state (another thread might be in
 392   // the process of copying it). So the best thing we can do is to
 393   // assert that word_size is under an upper bound which is its
 394   // containing region's capacity.
 395   assert(word_size * HeapWordSize <= hr->capacity(),
 396          err_msg("size: " SIZE_FORMAT " capacity: " SIZE_FORMAT " " HR_FORMAT,
 397                  word_size * HeapWordSize, hr->capacity(),
 398                  HR_FORMAT_PARAMS(hr)));
 399 
 400   if (addr < hr->next_top_at_mark_start()) {
 401     if (!_nextMarkBitMap->isMarked(addr)) {
 402       par_mark_and_count(obj, word_size, hr, worker_id);
 403     }
 404   }
 405 }
 406 
 407 #endif // SHARE_VM_GC_G1_CONCURRENTMARK_INLINE_HPP
< prev index next >