< prev index next >

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

Print this page




 149   }
 150   return false;
 151 }
 152 
 153 // Attempts to mark the given object and, if successful, counts
 154 // the object in the task/worker counting structures for the
 155 // given worker id.
 156 inline bool ConcurrentMark::par_mark_and_count(oop obj,
 157                                                size_t word_size,
 158                                                HeapRegion* hr,
 159                                                uint worker_id) {
 160   HeapWord* addr = (HeapWord*)obj;
 161   if (_nextMarkBitMap->parMark(addr)) {
 162     MemRegion mr(addr, word_size);
 163     count_region(mr, hr, worker_id);
 164     return true;
 165   }
 166   return false;
 167 }
 168 
 169 inline bool CMBitMapRO::iterate(BitMapClosure* cl, MemRegion mr) {
 170   HeapWord* start_addr = MAX2(startWord(), mr.start());
 171   HeapWord* end_addr = MIN2(endWord(), mr.end());
 172 
 173   if (end_addr > start_addr) {
 174     // Right-open interval [start-offset, end-offset).
 175     BitMap::idx_t start_offset = heapWordToOffset(start_addr);
 176     BitMap::idx_t end_offset = heapWordToOffset(end_addr);
 177 
 178     start_offset = _bm.get_next_one_offset(start_offset, end_offset);
 179     while (start_offset < end_offset) {
 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 




 149   }
 150   return false;
 151 }
 152 
 153 // Attempts to mark the given object and, if successful, counts
 154 // the object in the task/worker counting structures for the
 155 // given worker id.
 156 inline bool ConcurrentMark::par_mark_and_count(oop obj,
 157                                                size_t word_size,
 158                                                HeapRegion* hr,
 159                                                uint worker_id) {
 160   HeapWord* addr = (HeapWord*)obj;
 161   if (_nextMarkBitMap->parMark(addr)) {
 162     MemRegion mr(addr, word_size);
 163     count_region(mr, hr, worker_id);
 164     return true;
 165   }
 166   return false;
 167 }
 168 

























































 169 template<typename Fn>
 170 inline void CMMarkStack::iterate(Fn fn) {
 171   assert(_saved_index == _index,
 172          err_msg("saved index: %d index: %d", _saved_index, _index));
 173   for (int i = 0; i < _index; ++i) {
 174     fn(_base[i]);
 175   }
 176 }
 177 
 178 // It scans an object and visits its children.
 179 inline void CMTask::scan_object(oop obj) { process_grey_object<true>(obj); }
 180 
 181 inline void CMTask::push(oop obj) {
 182   HeapWord* objAddr = (HeapWord*) obj;
 183   assert(_g1h->is_in_g1_reserved(objAddr), "invariant");
 184   assert(!_g1h->is_on_master_free_list(
 185               _g1h->heap_region_containing((HeapWord*) objAddr)), "invariant");
 186   assert(!_g1h->is_obj_ill(obj), "invariant");
 187   assert(_nextMarkBitMap->isMarked(objAddr), "invariant");
 188 


< prev index next >