< 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));
 222 }
 223 
 224 #undef check_mark
 225 
 226 template<typename Fn>
 227 inline void CMMarkStack::iterate(Fn fn) {
 228   assert(_saved_index == _index,
 229          err_msg("saved index: %d index: %d", _saved_index, _index));
 230   for (int i = 0; i < _index; ++i) {
 231     fn(_base[i]);
 232   }
 233 }
 234 
 235 // It scans an object and visits its children.
 236 inline void CMTask::scan_object(oop obj) { process_grey_object<true>(obj); }
 237 
 238 inline void CMTask::push(oop obj) {
 239   HeapWord* objAddr = (HeapWord*) obj;
 240   assert(_g1h->is_in_g1_reserved(objAddr), "invariant");
 241   assert(!_g1h->is_on_master_free_list(
 242               _g1h->heap_region_containing((HeapWord*) objAddr)), "invariant");
 243   assert(!_g1h->is_obj_ill(obj), "invariant");
 244   assert(_nextMarkBitMap->isMarked(objAddr), "invariant");
 245 
 246   if (_cm->verbose_high()) {
 247     gclog_or_tty->print_cr("[%u] pushing " PTR_FORMAT, _worker_id, p2i((void*) obj));
 248   }
 249 


 368                                  ", global: " PTR_FORMAT ") pushing "
 369                                  PTR_FORMAT " on mark stack",
 370                                  _worker_id, p2i(_finger),
 371                                  p2i(global_finger), p2i(obj));
 372         }
 373         push(obj);
 374       }
 375     }
 376   }
 377 }
 378 
 379 inline void CMTask::deal_with_reference(oop obj) {
 380   if (_cm->verbose_high()) {
 381     gclog_or_tty->print_cr("[%u] we're dealing with reference = " PTR_FORMAT,
 382                            _worker_id, p2i((void*) obj));
 383   }
 384 
 385   increment_refs_reached();
 386 
 387   HeapWord* objAddr = (HeapWord*) obj;
 388   assert(obj->is_oop_or_null(true /* ignore mark word */), err_msg("Expected an oop or NULL at " PTR_FORMAT, p2i(obj)));
 389   if (_g1h->is_in_g1_reserved(objAddr)) {
 390     assert(obj != NULL, "null check is implicit");
 391     if (!_nextMarkBitMap->isMarked(objAddr)) {
 392       // Only get the containing region if the object is not marked on the
 393       // bitmap (otherwise, it's a waste of time since we won't do
 394       // anything with it).
 395       HeapRegion* hr = _g1h->heap_region_containing_raw(obj);
 396       if (!hr->obj_allocated_since_next_marking(obj)) {
 397         make_reference_grey(obj, hr);
 398       }
 399     }
 400   }
 401 }
 402 
 403 inline void ConcurrentMark::markPrev(oop p) {
 404   assert(!_prevMarkBitMap->isMarked((HeapWord*) p), "sanity");
 405   // Note we are overriding the read-only view of the prev map here, via
 406   // the cast.
 407   ((CMBitMap*)_prevMarkBitMap)->mark((HeapWord*) p);
 408 }


 410 inline void ConcurrentMark::grayRoot(oop obj, size_t word_size,
 411                                      uint worker_id, HeapRegion* hr) {
 412   assert(obj != NULL, "pre-condition");
 413   HeapWord* addr = (HeapWord*) obj;
 414   if (hr == NULL) {
 415     hr = _g1h->heap_region_containing_raw(addr);
 416   } else {
 417     assert(hr->is_in(addr), "pre-condition");
 418   }
 419   assert(hr != NULL, "sanity");
 420   // Given that we're looking for a region that contains an object
 421   // header it's impossible to get back a HC region.
 422   assert(!hr->is_continues_humongous(), "sanity");
 423 
 424   // We cannot assert that word_size == obj->size() given that obj
 425   // might not be in a consistent state (another thread might be in
 426   // the process of copying it). So the best thing we can do is to
 427   // assert that word_size is under an upper bound which is its
 428   // containing region's capacity.
 429   assert(word_size * HeapWordSize <= hr->capacity(),
 430          err_msg("size: " SIZE_FORMAT " capacity: " SIZE_FORMAT " " HR_FORMAT,
 431                  word_size * HeapWordSize, hr->capacity(),
 432                  HR_FORMAT_PARAMS(hr)));
 433 
 434   if (addr < hr->next_top_at_mark_start()) {
 435     if (!_nextMarkBitMap->isMarked(addr)) {
 436       par_mark_and_count(obj, word_size, hr, worker_id);
 437     }
 438   }
 439 }
 440 
 441 #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          "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));
 222 }
 223 
 224 #undef check_mark
 225 
 226 template<typename Fn>
 227 inline void CMMarkStack::iterate(Fn fn) {
 228   assert(_saved_index == _index, "saved index: %d index: %d", _saved_index, _index);

 229   for (int i = 0; i < _index; ++i) {
 230     fn(_base[i]);
 231   }
 232 }
 233 
 234 // It scans an object and visits its children.
 235 inline void CMTask::scan_object(oop obj) { process_grey_object<true>(obj); }
 236 
 237 inline void CMTask::push(oop obj) {
 238   HeapWord* objAddr = (HeapWord*) obj;
 239   assert(_g1h->is_in_g1_reserved(objAddr), "invariant");
 240   assert(!_g1h->is_on_master_free_list(
 241               _g1h->heap_region_containing((HeapWord*) objAddr)), "invariant");
 242   assert(!_g1h->is_obj_ill(obj), "invariant");
 243   assert(_nextMarkBitMap->isMarked(objAddr), "invariant");
 244 
 245   if (_cm->verbose_high()) {
 246     gclog_or_tty->print_cr("[%u] pushing " PTR_FORMAT, _worker_id, p2i((void*) obj));
 247   }
 248 


 367                                  ", global: " PTR_FORMAT ") pushing "
 368                                  PTR_FORMAT " on mark stack",
 369                                  _worker_id, p2i(_finger),
 370                                  p2i(global_finger), p2i(obj));
 371         }
 372         push(obj);
 373       }
 374     }
 375   }
 376 }
 377 
 378 inline void CMTask::deal_with_reference(oop obj) {
 379   if (_cm->verbose_high()) {
 380     gclog_or_tty->print_cr("[%u] we're dealing with reference = " PTR_FORMAT,
 381                            _worker_id, p2i((void*) obj));
 382   }
 383 
 384   increment_refs_reached();
 385 
 386   HeapWord* objAddr = (HeapWord*) obj;
 387   assert(obj->is_oop_or_null(true /* ignore mark word */), "Expected an oop or NULL at " PTR_FORMAT, p2i(obj));
 388   if (_g1h->is_in_g1_reserved(objAddr)) {
 389     assert(obj != NULL, "null check is implicit");
 390     if (!_nextMarkBitMap->isMarked(objAddr)) {
 391       // Only get the containing region if the object is not marked on the
 392       // bitmap (otherwise, it's a waste of time since we won't do
 393       // anything with it).
 394       HeapRegion* hr = _g1h->heap_region_containing_raw(obj);
 395       if (!hr->obj_allocated_since_next_marking(obj)) {
 396         make_reference_grey(obj, hr);
 397       }
 398     }
 399   }
 400 }
 401 
 402 inline void ConcurrentMark::markPrev(oop p) {
 403   assert(!_prevMarkBitMap->isMarked((HeapWord*) p), "sanity");
 404   // Note we are overriding the read-only view of the prev map here, via
 405   // the cast.
 406   ((CMBitMap*)_prevMarkBitMap)->mark((HeapWord*) p);
 407 }


 409 inline void ConcurrentMark::grayRoot(oop obj, size_t word_size,
 410                                      uint worker_id, HeapRegion* hr) {
 411   assert(obj != NULL, "pre-condition");
 412   HeapWord* addr = (HeapWord*) obj;
 413   if (hr == NULL) {
 414     hr = _g1h->heap_region_containing_raw(addr);
 415   } else {
 416     assert(hr->is_in(addr), "pre-condition");
 417   }
 418   assert(hr != NULL, "sanity");
 419   // Given that we're looking for a region that contains an object
 420   // header it's impossible to get back a HC region.
 421   assert(!hr->is_continues_humongous(), "sanity");
 422 
 423   // We cannot assert that word_size == obj->size() given that obj
 424   // might not be in a consistent state (another thread might be in
 425   // the process of copying it). So the best thing we can do is to
 426   // assert that word_size is under an upper bound which is its
 427   // containing region's capacity.
 428   assert(word_size * HeapWordSize <= hr->capacity(),
 429          "size: " SIZE_FORMAT " capacity: " SIZE_FORMAT " " HR_FORMAT,
 430          word_size * HeapWordSize, hr->capacity(),
 431          HR_FORMAT_PARAMS(hr));
 432 
 433   if (addr < hr->next_top_at_mark_start()) {
 434     if (!_nextMarkBitMap->isMarked(addr)) {
 435       par_mark_and_count(obj, word_size, hr, worker_id);
 436     }
 437   }
 438 }
 439 
 440 #endif // SHARE_VM_GC_G1_CONCURRENTMARK_INLINE_HPP
< prev index next >