295 } |
295 } |
296 |
296 |
297 _g1p->record_update_rs_time(worker_i, (os::elapsedTime() - start) * 1000.0); |
297 _g1p->record_update_rs_time(worker_i, (os::elapsedTime() - start) * 1000.0); |
298 } |
298 } |
299 |
299 |
300 #ifndef PRODUCT |
|
301 class PrintRSClosure : public HeapRegionClosure { |
|
302 int _count; |
|
303 public: |
|
304 PrintRSClosure() : _count(0) {} |
|
305 bool doHeapRegion(HeapRegion* r) { |
|
306 HeapRegionRemSet* hrrs = r->rem_set(); |
|
307 _count += (int) hrrs->occupied(); |
|
308 if (hrrs->occupied() == 0) { |
|
309 gclog_or_tty->print("Heap Region [" PTR_FORMAT ", " PTR_FORMAT ") " |
|
310 "has no remset entries\n", |
|
311 r->bottom(), r->end()); |
|
312 } else { |
|
313 gclog_or_tty->print("Printing rem set for heap region [" PTR_FORMAT ", " PTR_FORMAT ")\n", |
|
314 r->bottom(), r->end()); |
|
315 r->print(); |
|
316 hrrs->print(); |
|
317 gclog_or_tty->print("\nDone printing rem set\n"); |
|
318 } |
|
319 return false; |
|
320 } |
|
321 int occupied() {return _count;} |
|
322 }; |
|
323 #endif |
|
324 |
|
325 class CountRSSizeClosure: public HeapRegionClosure { |
300 class CountRSSizeClosure: public HeapRegionClosure { |
326 size_t _n; |
301 size_t _n; |
327 size_t _tot; |
302 size_t _tot; |
328 size_t _max; |
303 size_t _max; |
329 HeapRegion* _max_r; |
304 HeapRegion* _max_r; |
445 // We now clear the cached values of _cset_rs_update_cl for this worker |
420 // We now clear the cached values of _cset_rs_update_cl for this worker |
446 _cset_rs_update_cl[worker_i] = NULL; |
421 _cset_rs_update_cl[worker_i] = NULL; |
447 } |
422 } |
448 |
423 |
449 void G1RemSet::prepare_for_oops_into_collection_set_do() { |
424 void G1RemSet::prepare_for_oops_into_collection_set_do() { |
450 #if G1_REM_SET_LOGGING |
|
451 PrintRSClosure cl; |
|
452 _g1->collection_set_iterate(&cl); |
|
453 #endif |
|
454 cleanupHRRS(); |
425 cleanupHRRS(); |
455 ConcurrentG1Refine* cg1r = _g1->concurrent_g1_refine(); |
426 ConcurrentG1Refine* cg1r = _g1->concurrent_g1_refine(); |
456 _g1->set_refine_cte_cl_concurrency(false); |
427 _g1->set_refine_cte_cl_concurrency(false); |
457 DirtyCardQueueSet& dcqs = JavaThread::dirty_card_queue_set(); |
428 DirtyCardQueueSet& dcqs = JavaThread::dirty_card_queue_set(); |
458 dcqs.concatenate_logs(); |
429 dcqs.concatenate_logs(); |
466 _cards_scanned[i] = 0; |
437 _cards_scanned[i] = 0; |
467 } |
438 } |
468 _total_cards_scanned = 0; |
439 _total_cards_scanned = 0; |
469 } |
440 } |
470 |
441 |
471 |
|
472 class cleanUpIteratorsClosure : public HeapRegionClosure { |
|
473 bool doHeapRegion(HeapRegion *r) { |
|
474 HeapRegionRemSet* hrrs = r->rem_set(); |
|
475 hrrs->init_for_par_iteration(); |
|
476 return false; |
|
477 } |
|
478 }; |
|
479 |
442 |
480 // This closure, applied to a DirtyCardQueueSet, is used to immediately |
443 // This closure, applied to a DirtyCardQueueSet, is used to immediately |
481 // update the RSets for the regions in the CSet. For each card it iterates |
444 // update the RSets for the regions in the CSet. For each card it iterates |
482 // through the oops which coincide with that card. It scans the reference |
445 // through the oops which coincide with that card. It scans the reference |
483 // fields in each oop; when it finds an oop that points into the collection |
446 // fields in each oop; when it finds an oop that points into the collection |
535 }; |
498 }; |
536 |
499 |
537 void G1RemSet::cleanup_after_oops_into_collection_set_do() { |
500 void G1RemSet::cleanup_after_oops_into_collection_set_do() { |
538 guarantee( _cards_scanned != NULL, "invariant" ); |
501 guarantee( _cards_scanned != NULL, "invariant" ); |
539 _total_cards_scanned = 0; |
502 _total_cards_scanned = 0; |
540 for (uint i = 0; i < n_workers(); ++i) |
503 for (uint i = 0; i < n_workers(); ++i) { |
541 _total_cards_scanned += _cards_scanned[i]; |
504 _total_cards_scanned += _cards_scanned[i]; |
|
505 } |
542 FREE_C_HEAP_ARRAY(size_t, _cards_scanned); |
506 FREE_C_HEAP_ARRAY(size_t, _cards_scanned); |
543 _cards_scanned = NULL; |
507 _cards_scanned = NULL; |
544 // Cleanup after copy |
508 // Cleanup after copy |
545 #if G1_REM_SET_LOGGING |
|
546 PrintRSClosure cl; |
|
547 _g1->heap_region_iterate(&cl); |
|
548 #endif |
|
549 _g1->set_refine_cte_cl_concurrency(true); |
509 _g1->set_refine_cte_cl_concurrency(true); |
550 cleanUpIteratorsClosure iterClosure; |
|
551 _g1->collection_set_iterate(&iterClosure); |
|
552 // Set all cards back to clean. |
510 // Set all cards back to clean. |
553 _g1->cleanUpCardTable(); |
511 _g1->cleanUpCardTable(); |
554 |
512 |
555 DirtyCardQueueSet& into_cset_dcqs = _g1->into_cset_dirty_card_queue_set(); |
513 DirtyCardQueueSet& into_cset_dcqs = _g1->into_cset_dirty_card_queue_set(); |
556 int into_cset_n_buffers = into_cset_dcqs.completed_buffers_num(); |
514 int into_cset_n_buffers = into_cset_dcqs.completed_buffers_num(); |