658 // The region for the current card may be a young region. The
659 // current card may have been a card that was evicted from the
660 // card cache. When the card was inserted into the cache, we had
661 // determined that its region was non-young. While in the cache,
662 // the region may have been freed during a cleanup pause, reallocated
663 // and tagged as young.
664 //
665 // We wish to filter out cards for such a region but the current
666 // thread, if we're running concurrently, may "see" the young type
667 // change at any time (so an earlier "is_young" check may pass or
668 // fail arbitrarily). We tell the iteration code to perform this
669 // filtering when it has been determined that there has been an actual
670 // allocation in this region and making it safe to check the young type.
671
672 bool card_processed =
673 r->oops_on_card_seq_iterate_careful(dirtyRegion,
674 &filter_then_update_rs_oop_cl,
675 card_ptr);
676
677 // If unable to process the card then we encountered an unparsable
678 // part of the heap (e.g. a partially allocated object). Redirty
679 // and re-enqueue: if we put off the card until a GC pause, then the
680 // allocation will have completed.
681 if (!card_processed) {
682 assert(!_g1->is_gc_active(), "Unparsable heap during GC");
683 // The card might have gotten re-dirtied and re-enqueued while we
684 // worked. (In fact, it's pretty likely.)
685 if (*card_ptr != CardTableModRefBS::dirty_card_val()) {
686 *card_ptr = CardTableModRefBS::dirty_card_val();
687 MutexLockerEx x(Shared_DirtyCardQ_lock,
688 Mutex::_no_safepoint_check_flag);
689 DirtyCardQueue* sdcq =
690 JavaThread::dirty_card_queue_set().shared_dirty_card_queue();
691 sdcq->enqueue(card_ptr);
692 }
693 } else {
694 _conc_refine_cards++;
695 }
696
697 // This gets set to true if the card being refined has
698 // references that point into the collection set.
699 bool has_refs_into_cset = trigger_cl.triggered();
700
701 // We should only be detecting that the card contains references
702 // that point into the collection set if the current thread is
703 // a GC worker thread.
704 assert(!has_refs_into_cset || SafepointSynchronize::is_at_safepoint(),
705 "invalid result at non safepoint");
706
707 return has_refs_into_cset;
708 }
709
710 void G1RemSet::print_periodic_summary_info(const char* header, uint period_count) {
711 if ((G1SummarizeRSetStatsPeriod > 0) && log_is_enabled(Trace, gc, remset) &&
712 (period_count % G1SummarizeRSetStatsPeriod == 0)) {
|
658 // The region for the current card may be a young region. The
659 // current card may have been a card that was evicted from the
660 // card cache. When the card was inserted into the cache, we had
661 // determined that its region was non-young. While in the cache,
662 // the region may have been freed during a cleanup pause, reallocated
663 // and tagged as young.
664 //
665 // We wish to filter out cards for such a region but the current
666 // thread, if we're running concurrently, may "see" the young type
667 // change at any time (so an earlier "is_young" check may pass or
668 // fail arbitrarily). We tell the iteration code to perform this
669 // filtering when it has been determined that there has been an actual
670 // allocation in this region and making it safe to check the young type.
671
672 bool card_processed =
673 r->oops_on_card_seq_iterate_careful(dirtyRegion,
674 &filter_then_update_rs_oop_cl,
675 card_ptr);
676
677 // If unable to process the card then we encountered an unparsable
678 // part of the heap (e.g. a partially allocated object) while
679 // processing a stale card. Despite the card being stale, redirty
680 // and re-enqueue, because we've already cleaned the card. Without
681 // this we could incorrectly discard a non-stale card.
682 if (!card_processed) {
683 assert(!_g1->is_gc_active(), "Unparsable heap during GC");
684 // Using invalidate for one card is simple but expensive, but this
685 // should be rare; processing a stale card while a humongous
686 // object is in the midst of being allocated in the same region.
687 _ct_bs->invalidate(dirtyRegion);
688 } else {
689 _conc_refine_cards++;
690 }
691
692 // This gets set to true if the card being refined has
693 // references that point into the collection set.
694 bool has_refs_into_cset = trigger_cl.triggered();
695
696 // We should only be detecting that the card contains references
697 // that point into the collection set if the current thread is
698 // a GC worker thread.
699 assert(!has_refs_into_cset || SafepointSynchronize::is_at_safepoint(),
700 "invalid result at non safepoint");
701
702 return has_refs_into_cset;
703 }
704
705 void G1RemSet::print_periodic_summary_info(const char* header, uint period_count) {
706 if ((G1SummarizeRSetStatsPeriod > 0) && log_is_enabled(Trace, gc, remset) &&
707 (period_count % G1SummarizeRSetStatsPeriod == 0)) {
|