874 _nextMarkBitMap->clearRange(mr);
875 cur = next;
876 do_yield_check();
877
878 // Repeat the asserts from above. We'll do them as asserts here to
879 // minimize their overhead on the product. However, we'll have
880 // them as guarantees at the beginning / end of the bitmap
881 // clearing to get some checking in the product.
882 assert(cmThread()->during_cycle(), "invariant");
883 assert(!g1h->mark_in_progress(), "invariant");
884 }
885
886 // Clear the liveness counting data
887 clear_all_count_data();
888
889 // Repeat the asserts from above.
890 guarantee(cmThread()->during_cycle(), "invariant");
891 guarantee(!g1h->mark_in_progress(), "invariant");
892 }
893
894 class NoteStartOfMarkHRClosure: public HeapRegionClosure {
895 public:
896 bool doHeapRegion(HeapRegion* r) {
897 if (!r->continuesHumongous()) {
898 r->note_start_of_marking();
899 }
900 return false;
901 }
902 };
903
904 void ConcurrentMark::checkpointRootsInitialPre() {
905 G1CollectedHeap* g1h = G1CollectedHeap::heap();
906 G1CollectorPolicy* g1p = g1h->g1_policy();
907
908 _has_aborted = false;
909
910 #ifndef PRODUCT
911 if (G1PrintReachableAtInitialMark) {
912 print_reachable("at-cycle-start",
913 VerifyOption_G1UsePrevMarking, true /* all */);
3341 assert(task_card_bm->size() == _card_bm.size(), "size mismatch");
3342 assert(marked_bytes_array != NULL, "uninitialized");
3343
3344 memset(marked_bytes_array, 0, (size_t) max_regions * sizeof(size_t));
3345 task_card_bm->clear();
3346 }
3347 }
3348
3349 void ConcurrentMark::print_stats() {
3350 if (verbose_stats()) {
3351 gclog_or_tty->print_cr("---------------------------------------------------------------------");
3352 for (size_t i = 0; i < _active_tasks; ++i) {
3353 _tasks[i]->print_stats();
3354 gclog_or_tty->print_cr("---------------------------------------------------------------------");
3355 }
3356 }
3357 }
3358
3359 // abandon current marking iteration due to a Full GC
3360 void ConcurrentMark::abort() {
3361 // Clear all marks to force marking thread to do nothing
3362 _nextMarkBitMap->clearAll();
3363
3364 // Note we cannot clear the previous marking bitmap here
3365 // since VerifyDuringGC verifies the objects marked during
3366 // a full GC against the previous bitmap.
3367
3368 // Clear the liveness counting data
3369 clear_all_count_data();
3370 // Empty mark stack
3371 reset_marking_state();
3372 for (uint i = 0; i < _max_worker_id; ++i) {
3373 _tasks[i]->clear_region_fields();
3374 }
3375 _first_overflow_barrier_sync.abort();
3376 _second_overflow_barrier_sync.abort();
3377 const GCId& gc_id = _g1h->gc_tracer_cm()->gc_id();
3378 if (!gc_id.is_undefined()) {
3379 // We can do multiple full GCs before ConcurrentMarkThread::run() gets a chance
3380 // to detect that it was aborted. Only keep track of the first GC id that we aborted.
3381 _aborted_gc_id = gc_id;
|
874 _nextMarkBitMap->clearRange(mr);
875 cur = next;
876 do_yield_check();
877
878 // Repeat the asserts from above. We'll do them as asserts here to
879 // minimize their overhead on the product. However, we'll have
880 // them as guarantees at the beginning / end of the bitmap
881 // clearing to get some checking in the product.
882 assert(cmThread()->during_cycle(), "invariant");
883 assert(!g1h->mark_in_progress(), "invariant");
884 }
885
886 // Clear the liveness counting data
887 clear_all_count_data();
888
889 // Repeat the asserts from above.
890 guarantee(cmThread()->during_cycle(), "invariant");
891 guarantee(!g1h->mark_in_progress(), "invariant");
892 }
893
894 bool ConcurrentMark::nextMarkBitmapIsClear() {
895 return _nextMarkBitMap->getNextMarkedWordAddress(_heap_start, _heap_end) == _heap_end;
896 }
897
898 class NoteStartOfMarkHRClosure: public HeapRegionClosure {
899 public:
900 bool doHeapRegion(HeapRegion* r) {
901 if (!r->continuesHumongous()) {
902 r->note_start_of_marking();
903 }
904 return false;
905 }
906 };
907
908 void ConcurrentMark::checkpointRootsInitialPre() {
909 G1CollectedHeap* g1h = G1CollectedHeap::heap();
910 G1CollectorPolicy* g1p = g1h->g1_policy();
911
912 _has_aborted = false;
913
914 #ifndef PRODUCT
915 if (G1PrintReachableAtInitialMark) {
916 print_reachable("at-cycle-start",
917 VerifyOption_G1UsePrevMarking, true /* all */);
3345 assert(task_card_bm->size() == _card_bm.size(), "size mismatch");
3346 assert(marked_bytes_array != NULL, "uninitialized");
3347
3348 memset(marked_bytes_array, 0, (size_t) max_regions * sizeof(size_t));
3349 task_card_bm->clear();
3350 }
3351 }
3352
3353 void ConcurrentMark::print_stats() {
3354 if (verbose_stats()) {
3355 gclog_or_tty->print_cr("---------------------------------------------------------------------");
3356 for (size_t i = 0; i < _active_tasks; ++i) {
3357 _tasks[i]->print_stats();
3358 gclog_or_tty->print_cr("---------------------------------------------------------------------");
3359 }
3360 }
3361 }
3362
3363 // abandon current marking iteration due to a Full GC
3364 void ConcurrentMark::abort() {
3365 // Clear all marks in the next bitmap for the next marking cycle. This will allow us to skip the next
3366 // concurrent bitmap clearing.
3367 _nextMarkBitMap->clearAll();
3368
3369 // Note we cannot clear the previous marking bitmap here
3370 // since VerifyDuringGC verifies the objects marked during
3371 // a full GC against the previous bitmap.
3372
3373 // Clear the liveness counting data
3374 clear_all_count_data();
3375 // Empty mark stack
3376 reset_marking_state();
3377 for (uint i = 0; i < _max_worker_id; ++i) {
3378 _tasks[i]->clear_region_fields();
3379 }
3380 _first_overflow_barrier_sync.abort();
3381 _second_overflow_barrier_sync.abort();
3382 const GCId& gc_id = _g1h->gc_tracer_cm()->gc_id();
3383 if (!gc_id.is_undefined()) {
3384 // We can do multiple full GCs before ConcurrentMarkThread::run() gets a chance
3385 // to detect that it was aborted. Only keep track of the first GC id that we aborted.
3386 _aborted_gc_id = gc_id;
|