260 start_offset = _bm.get_next_one_offset(next_offset, end_offset); 261 } 262 } 263 return true; 264 } 265 266 inline bool CMBitMapRO::iterate(BitMapClosure* cl) { 267 MemRegion mr(startWord(), sizeInWords()); 268 return iterate(cl, mr); 269 } 270 271 inline void CMTask::push(oop obj) { 272 HeapWord* objAddr = (HeapWord*) obj; 273 assert(_g1h->is_in_g1_reserved(objAddr), "invariant"); 274 assert(!_g1h->is_on_master_free_list( 275 _g1h->heap_region_containing((HeapWord*) objAddr)), "invariant"); 276 assert(!_g1h->is_obj_ill(obj), "invariant"); 277 assert(_nextMarkBitMap->isMarked(objAddr), "invariant"); 278 279 if (_cm->verbose_high()) { 280 gclog_or_tty->print_cr("[%u] pushing "PTR_FORMAT, _worker_id, (void*) obj); 281 } 282 283 if (!_task_queue->push(obj)) { 284 // The local task queue looks full. We need to push some entries 285 // to the global stack. 286 287 if (_cm->verbose_medium()) { 288 gclog_or_tty->print_cr("[%u] task queue overflow, " 289 "moving entries to the global stack", 290 _worker_id); 291 } 292 move_entries_to_global_stack(); 293 294 // this should succeed since, even if we overflow the global 295 // stack, we should have definitely removed some entries from the 296 // local queue. So, there must be space on it. 297 bool success = _task_queue->push(obj); 298 assert(success, "invariant"); 299 } 300 301 statsOnly( int tmp_size = _task_queue->size(); 302 if (tmp_size > _local_max_size) { 303 _local_max_size = tmp_size; 304 } 305 ++_local_pushes ); 306 } 307 308 // This determines whether the method below will check both the local 309 // and global fingers when determining whether to push on the stack a 310 // gray object (value 1) or whether it will only check the global one 311 // (value 0). The tradeoffs are that the former will be a bit more 312 // accurate and possibly push less on the stack, but it might also be 313 // a little bit slower. 314 315 #define _CHECK_BOTH_FINGERS_ 1 316 317 inline void CMTask::deal_with_reference(oop obj) { 318 if (_cm->verbose_high()) { 319 gclog_or_tty->print_cr("[%u] we're dealing with reference = "PTR_FORMAT, 320 _worker_id, (void*) obj); 321 } 322 323 ++_refs_reached; 324 325 HeapWord* objAddr = (HeapWord*) obj; 326 assert(obj->is_oop_or_null(true /* ignore mark word */), "Error"); 327 if (_g1h->is_in_g1_reserved(objAddr)) { 328 assert(obj != NULL, "null check is implicit"); 329 if (!_nextMarkBitMap->isMarked(objAddr)) { 330 // Only get the containing region if the object is not marked on the 331 // bitmap (otherwise, it's a waste of time since we won't do 332 // anything with it). 333 HeapRegion* hr = _g1h->heap_region_containing_raw(obj); 334 if (!hr->obj_allocated_since_next_marking(obj)) { 335 if (_cm->verbose_high()) { 336 gclog_or_tty->print_cr("[%u] "PTR_FORMAT" is not considered marked", 337 _worker_id, (void*) obj); 338 } 339 340 // we need to mark it first 341 if (_cm->par_mark_and_count(obj, hr, _marked_bytes_array, _card_bm)) { 342 // No OrderAccess:store_load() is needed. It is implicit in the 343 // CAS done in CMBitMap::parMark() call in the routine above. 344 HeapWord* global_finger = _cm->finger(); 345 346 #if _CHECK_BOTH_FINGERS_ 347 // we will check both the local and global fingers 348 349 if (_finger != NULL && objAddr < _finger) { 350 if (_cm->verbose_high()) { 351 gclog_or_tty->print_cr("[%u] below the local finger ("PTR_FORMAT"), " 352 "pushing it", _worker_id, _finger); 353 } 354 push(obj); 355 } else if (_curr_region != NULL && objAddr < _region_limit) { 356 // do nothing 357 } else if (objAddr < global_finger) { 358 // Notice that the global finger might be moving forward 359 // concurrently. This is not a problem. In the worst case, we 360 // mark the object while it is above the global finger and, by 361 // the time we read the global finger, it has moved forward 362 // passed this object. In this case, the object will probably 363 // be visited when a task is scanning the region and will also 364 // be pushed on the stack. So, some duplicate work, but no 365 // correctness problems. 366 367 if (_cm->verbose_high()) { 368 gclog_or_tty->print_cr("[%u] below the global finger " 369 "("PTR_FORMAT"), pushing it", 370 _worker_id, global_finger); 371 } 372 push(obj); 373 } else { 374 // do nothing 375 } 376 #else // _CHECK_BOTH_FINGERS_ 377 // we will only check the global finger 378 379 if (objAddr < global_finger) { 380 // see long comment above 381 382 if (_cm->verbose_high()) { 383 gclog_or_tty->print_cr("[%u] below the global finger " 384 "("PTR_FORMAT"), pushing it", 385 _worker_id, global_finger); 386 } 387 push(obj); 388 } 389 #endif // _CHECK_BOTH_FINGERS_ 390 } 391 } 392 } 393 } 394 } 395 396 inline void ConcurrentMark::markPrev(oop p) { 397 assert(!_prevMarkBitMap->isMarked((HeapWord*) p), "sanity"); 398 // Note we are overriding the read-only view of the prev map here, via 399 // the cast. 400 ((CMBitMap*)_prevMarkBitMap)->mark((HeapWord*) p); 401 } 402 403 inline void ConcurrentMark::grayRoot(oop obj, size_t word_size, 404 uint worker_id, HeapRegion* hr) { 405 assert(obj != NULL, "pre-condition"); | 260 start_offset = _bm.get_next_one_offset(next_offset, end_offset); 261 } 262 } 263 return true; 264 } 265 266 inline bool CMBitMapRO::iterate(BitMapClosure* cl) { 267 MemRegion mr(startWord(), sizeInWords()); 268 return iterate(cl, mr); 269 } 270 271 inline void CMTask::push(oop obj) { 272 HeapWord* objAddr = (HeapWord*) obj; 273 assert(_g1h->is_in_g1_reserved(objAddr), "invariant"); 274 assert(!_g1h->is_on_master_free_list( 275 _g1h->heap_region_containing((HeapWord*) objAddr)), "invariant"); 276 assert(!_g1h->is_obj_ill(obj), "invariant"); 277 assert(_nextMarkBitMap->isMarked(objAddr), "invariant"); 278 279 if (_cm->verbose_high()) { 280 gclog_or_tty->print_cr("[%u] pushing " PTR_FORMAT, _worker_id, p2i((void*) obj)); 281 } 282 283 if (!_task_queue->push(obj)) { 284 // The local task queue looks full. We need to push some entries 285 // to the global stack. 286 287 if (_cm->verbose_medium()) { 288 gclog_or_tty->print_cr("[%u] task queue overflow, " 289 "moving entries to the global stack", 290 _worker_id); 291 } 292 move_entries_to_global_stack(); 293 294 // this should succeed since, even if we overflow the global 295 // stack, we should have definitely removed some entries from the 296 // local queue. So, there must be space on it. 297 bool success = _task_queue->push(obj); 298 assert(success, "invariant"); 299 } 300 301 statsOnly( int tmp_size = _task_queue->size(); 302 if (tmp_size > _local_max_size) { 303 _local_max_size = tmp_size; 304 } 305 ++_local_pushes ); 306 } 307 308 // This determines whether the method below will check both the local 309 // and global fingers when determining whether to push on the stack a 310 // gray object (value 1) or whether it will only check the global one 311 // (value 0). The tradeoffs are that the former will be a bit more 312 // accurate and possibly push less on the stack, but it might also be 313 // a little bit slower. 314 315 #define _CHECK_BOTH_FINGERS_ 1 316 317 inline void CMTask::deal_with_reference(oop obj) { 318 if (_cm->verbose_high()) { 319 gclog_or_tty->print_cr("[%u] we're dealing with reference = "PTR_FORMAT, 320 _worker_id, p2i((void*) obj)); 321 } 322 323 ++_refs_reached; 324 325 HeapWord* objAddr = (HeapWord*) obj; 326 assert(obj->is_oop_or_null(true /* ignore mark word */), "Error"); 327 if (_g1h->is_in_g1_reserved(objAddr)) { 328 assert(obj != NULL, "null check is implicit"); 329 if (!_nextMarkBitMap->isMarked(objAddr)) { 330 // Only get the containing region if the object is not marked on the 331 // bitmap (otherwise, it's a waste of time since we won't do 332 // anything with it). 333 HeapRegion* hr = _g1h->heap_region_containing_raw(obj); 334 if (!hr->obj_allocated_since_next_marking(obj)) { 335 if (_cm->verbose_high()) { 336 gclog_or_tty->print_cr("[%u] "PTR_FORMAT" is not considered marked", 337 _worker_id, p2i((void*) obj)); 338 } 339 340 // we need to mark it first 341 if (_cm->par_mark_and_count(obj, hr, _marked_bytes_array, _card_bm)) { 342 // No OrderAccess:store_load() is needed. It is implicit in the 343 // CAS done in CMBitMap::parMark() call in the routine above. 344 HeapWord* global_finger = _cm->finger(); 345 346 #if _CHECK_BOTH_FINGERS_ 347 // we will check both the local and global fingers 348 349 if (_finger != NULL && objAddr < _finger) { 350 if (_cm->verbose_high()) { 351 gclog_or_tty->print_cr("[%u] below the local finger ("PTR_FORMAT"), " 352 "pushing it", _worker_id, p2i(_finger)); 353 } 354 push(obj); 355 } else if (_curr_region != NULL && objAddr < _region_limit) { 356 // do nothing 357 } else if (objAddr < global_finger) { 358 // Notice that the global finger might be moving forward 359 // concurrently. This is not a problem. In the worst case, we 360 // mark the object while it is above the global finger and, by 361 // the time we read the global finger, it has moved forward 362 // passed this object. In this case, the object will probably 363 // be visited when a task is scanning the region and will also 364 // be pushed on the stack. So, some duplicate work, but no 365 // correctness problems. 366 367 if (_cm->verbose_high()) { 368 gclog_or_tty->print_cr("[%u] below the global finger " 369 "("PTR_FORMAT"), pushing it", 370 _worker_id, p2i(global_finger)); 371 } 372 push(obj); 373 } else { 374 // do nothing 375 } 376 #else // _CHECK_BOTH_FINGERS_ 377 // we will only check the global finger 378 379 if (objAddr < global_finger) { 380 // see long comment above 381 382 if (_cm->verbose_high()) { 383 gclog_or_tty->print_cr("[%u] below the global finger " 384 "("PTR_FORMAT"), pushing it", 385 _worker_id, p2i(global_finger)); 386 } 387 push(obj); 388 } 389 #endif // _CHECK_BOTH_FINGERS_ 390 } 391 } 392 } 393 } 394 } 395 396 inline void ConcurrentMark::markPrev(oop p) { 397 assert(!_prevMarkBitMap->isMarked((HeapWord*) p), "sanity"); 398 // Note we are overriding the read-only view of the prev map here, via 399 // the cast. 400 ((CMBitMap*)_prevMarkBitMap)->mark((HeapWord*) p); 401 } 402 403 inline void ConcurrentMark::grayRoot(oop obj, size_t word_size, 404 uint worker_id, HeapRegion* hr) { 405 assert(obj != NULL, "pre-condition"); |