comparison src/share/vm/gc_implementation/g1/concurrentMark.cpp @ 1359:23b1b27ac76c

6909756: G1: guarantee(G1CollectedHeap::heap()->mark_in_progress(),"Precondition.") Summary: Make sure that two marking cycles do not overlap, i.e., a new one can only start after the concurrent marking thread finishes all its work. In the fix I piggy-back a couple of minor extra fixes: some general code reformatting for consistency (only around the code I modified), the removal of a field (G1CollectorPolicy::_should_initiate_conc_mark) which doesn't seem to be used at all (it's only set but never read), as well as moving the "is GC locker active" test earlier into the G1 pause / Full GC and using a more appropriate method for it. Reviewed-by: johnc, jmasa, jcoomes, ysr
author tonyp
date Tue, 06 Apr 2010 10:59:45 -0400
parents 72f725c5a7be
children 7666957bc44d
comparison
equal deleted inserted replaced
1358:72f725c5a7be 1359:23b1b27ac76c
706 // from external roots in the CMS bit map. 706 // from external roots in the CMS bit map.
707 // Called at the first checkpoint. 707 // Called at the first checkpoint.
708 // 708 //
709 709
710 void ConcurrentMark::clearNextBitmap() { 710 void ConcurrentMark::clearNextBitmap() {
711 guarantee(!G1CollectedHeap::heap()->mark_in_progress(), "Precondition."); 711 G1CollectedHeap* g1h = G1CollectedHeap::heap();
712 712 G1CollectorPolicy* g1p = g1h->g1_policy();
713 // clear the mark bitmap (no grey objects to start with). 713
714 // We need to do this in chunks and offer to yield in between 714 // Make sure that the concurrent mark thread looks to still be in
715 // each chunk. 715 // the current cycle.
716 HeapWord* start = _nextMarkBitMap->startWord(); 716 guarantee(cmThread()->during_cycle(), "invariant");
717 HeapWord* end = _nextMarkBitMap->endWord(); 717
718 HeapWord* cur = start; 718 // We are finishing up the current cycle by clearing the next
719 size_t chunkSize = M; 719 // marking bitmap and getting it ready for the next cycle. During
720 while (cur < end) { 720 // this time no other cycle can start. So, let's make sure that this
721 HeapWord* next = cur + chunkSize; 721 // is the case.
722 if (next > end) 722 guarantee(!g1h->mark_in_progress(), "invariant");
723 next = end; 723
724 MemRegion mr(cur,next); 724 // clear the mark bitmap (no grey objects to start with).
725 _nextMarkBitMap->clearRange(mr); 725 // We need to do this in chunks and offer to yield in between
726 cur = next; 726 // each chunk.
727 do_yield_check(); 727 HeapWord* start = _nextMarkBitMap->startWord();
728 } 728 HeapWord* end = _nextMarkBitMap->endWord();
729 HeapWord* cur = start;
730 size_t chunkSize = M;
731 while (cur < end) {
732 HeapWord* next = cur + chunkSize;
733 if (next > end)
734 next = end;
735 MemRegion mr(cur,next);
736 _nextMarkBitMap->clearRange(mr);
737 cur = next;
738 do_yield_check();
739
740 // Repeat the asserts from above. We'll do them as asserts here to
741 // minimize their overhead on the product. However, we'll have
742 // them as guarantees at the beginning / end of the bitmap
743 // clearing to get some checking in the product.
744 assert(cmThread()->during_cycle(), "invariant");
745 assert(!g1h->mark_in_progress(), "invariant");
746 }
747
748 // Repeat the asserts from above.
749 guarantee(cmThread()->during_cycle(), "invariant");
750 guarantee(!g1h->mark_in_progress(), "invariant");
729 } 751 }
730 752
731 class NoteStartOfMarkHRClosure: public HeapRegionClosure { 753 class NoteStartOfMarkHRClosure: public HeapRegionClosure {
732 public: 754 public:
733 bool doHeapRegion(HeapRegion* r) { 755 bool doHeapRegion(HeapRegion* r) {