Mercurial > hg > graal-jvmci-8
comparison src/share/vm/gc_implementation/g1/g1CollectedHeap.cpp @ 20291:e0954897238a
7132678: G1: verify that the marking bitmaps have no marks for objects over TAMS
Reviewed-by: jmasa, tschatzl, ehelin
Contributed-by: tony.printezis@oracle.com, bengt.rutisson@oracle.com
author | brutisso |
---|---|
date | Tue, 29 Apr 2014 09:33:20 +0200 |
parents | f3aeae1f9fc5 |
children | 3f2894c5052e |
comparison
equal
deleted
inserted
replaced
20290:85c339200299 | 20291:e0954897238a |
---|---|
769 // If we have continues humongous regions (hr != NULL), then the | 769 // If we have continues humongous regions (hr != NULL), then the |
770 // end of the last one should match new_end and its top should | 770 // end of the last one should match new_end and its top should |
771 // match new_top. | 771 // match new_top. |
772 assert(hr == NULL || | 772 assert(hr == NULL || |
773 (hr->end() == new_end && hr->top() == new_top), "sanity"); | 773 (hr->end() == new_end && hr->top() == new_top), "sanity"); |
774 check_bitmaps("Humongous Region Allocation", first_hr); | |
774 | 775 |
775 assert(first_hr->used() == word_size * HeapWordSize, "invariant"); | 776 assert(first_hr->used() == word_size * HeapWordSize, "invariant"); |
776 _summary_bytes_used += first_hr->used(); | 777 _summary_bytes_used += first_hr->used(); |
777 _humongous_set.add(first_hr); | 778 _humongous_set.add(first_hr); |
778 | 779 |
1327 | 1328 |
1328 assert(used() == recalculate_used(), "Should be equal"); | 1329 assert(used() == recalculate_used(), "Should be equal"); |
1329 | 1330 |
1330 verify_before_gc(); | 1331 verify_before_gc(); |
1331 | 1332 |
1333 check_bitmaps("Full GC Start"); | |
1332 pre_full_gc_dump(gc_timer); | 1334 pre_full_gc_dump(gc_timer); |
1333 | 1335 |
1334 COMPILER2_PRESENT(DerivedPointerTable::clear()); | 1336 COMPILER2_PRESENT(DerivedPointerTable::clear()); |
1335 | 1337 |
1336 // Disable discovery and empty the discovered lists | 1338 // Disable discovery and empty the discovered lists |
1499 | 1501 |
1500 _hrs.verify_optional(); | 1502 _hrs.verify_optional(); |
1501 verify_region_sets_optional(); | 1503 verify_region_sets_optional(); |
1502 | 1504 |
1503 verify_after_gc(); | 1505 verify_after_gc(); |
1506 | |
1507 // Clear the previous marking bitmap, if needed for bitmap verification. | |
1508 // Note we cannot do this when we clear the next marking bitmap in | |
1509 // ConcurrentMark::abort() above since VerifyDuringGC verifies the | |
1510 // objects marked during a full GC against the previous bitmap. | |
1511 // But we need to clear it before calling check_bitmaps below since | |
1512 // the full GC has compacted objects and updated TAMS but not updated | |
1513 // the prev bitmap. | |
1514 if (G1VerifyBitmaps) { | |
1515 ((CMBitMap*) concurrent_mark()->prevMarkBitMap())->clearAll(); | |
1516 } | |
1517 check_bitmaps("Full GC End"); | |
1504 | 1518 |
1505 // Start a new incremental collection set for the next pause | 1519 // Start a new incremental collection set for the next pause |
1506 assert(g1_policy()->collection_set() == NULL, "must be"); | 1520 assert(g1_policy()->collection_set() == NULL, "must be"); |
1507 g1_policy()->start_incremental_cset_building(); | 1521 g1_policy()->start_incremental_cset_building(); |
1508 | 1522 |
3984 gc_prologue(false); | 3998 gc_prologue(false); |
3985 increment_total_collections(false /* full gc */); | 3999 increment_total_collections(false /* full gc */); |
3986 increment_gc_time_stamp(); | 4000 increment_gc_time_stamp(); |
3987 | 4001 |
3988 verify_before_gc(); | 4002 verify_before_gc(); |
4003 check_bitmaps("GC Start"); | |
3989 | 4004 |
3990 COMPILER2_PRESENT(DerivedPointerTable::clear()); | 4005 COMPILER2_PRESENT(DerivedPointerTable::clear()); |
3991 | 4006 |
3992 // Please see comment in g1CollectedHeap.hpp and | 4007 // Please see comment in g1CollectedHeap.hpp and |
3993 // G1CollectedHeap::ref_processing_init() to see how | 4008 // G1CollectedHeap::ref_processing_init() to see how |
4229 // is_gc_active() check to decided which top to use when | 4244 // is_gc_active() check to decided which top to use when |
4230 // scanning cards (see CR 7039627). | 4245 // scanning cards (see CR 7039627). |
4231 increment_gc_time_stamp(); | 4246 increment_gc_time_stamp(); |
4232 | 4247 |
4233 verify_after_gc(); | 4248 verify_after_gc(); |
4249 check_bitmaps("GC End"); | |
4234 | 4250 |
4235 assert(!ref_processor_stw()->discovery_enabled(), "Postcondition"); | 4251 assert(!ref_processor_stw()->discovery_enabled(), "Postcondition"); |
4236 ref_processor_stw()->verify_no_references_recorded(); | 4252 ref_processor_stw()->verify_no_references_recorded(); |
4237 | 4253 |
4238 // CM reference discovery will be re-enabled if necessary. | 4254 // CM reference discovery will be re-enabled if necessary. |
6084 bool locked) { | 6100 bool locked) { |
6085 assert(!hr->isHumongous(), "this is only for non-humongous regions"); | 6101 assert(!hr->isHumongous(), "this is only for non-humongous regions"); |
6086 assert(!hr->is_empty(), "the region should not be empty"); | 6102 assert(!hr->is_empty(), "the region should not be empty"); |
6087 assert(free_list != NULL, "pre-condition"); | 6103 assert(free_list != NULL, "pre-condition"); |
6088 | 6104 |
6105 if (G1VerifyBitmaps) { | |
6106 MemRegion mr(hr->bottom(), hr->end()); | |
6107 concurrent_mark()->clearRangePrevBitmap(mr); | |
6108 } | |
6109 | |
6089 // Clear the card counts for this region. | 6110 // Clear the card counts for this region. |
6090 // Note: we only need to do this if the region is not young | 6111 // Note: we only need to do this if the region is not young |
6091 // (since we don't refine cards in young regions). | 6112 // (since we don't refine cards in young regions). |
6092 if (!hr->is_young()) { | 6113 if (!hr->is_young()) { |
6093 _cg1r->hot_card_cache()->reset_card_counts(hr); | 6114 _cg1r->hot_card_cache()->reset_card_counts(hr); |
6218 } | 6239 } |
6219 | 6240 |
6220 void G1CollectedHeap::verify_dirty_young_regions() { | 6241 void G1CollectedHeap::verify_dirty_young_regions() { |
6221 verify_dirty_young_list(_young_list->first_region()); | 6242 verify_dirty_young_list(_young_list->first_region()); |
6222 } | 6243 } |
6223 #endif | 6244 |
6245 bool G1CollectedHeap::verify_no_bits_over_tams(const char* bitmap_name, CMBitMapRO* bitmap, | |
6246 HeapWord* tams, HeapWord* end) { | |
6247 guarantee(tams <= end, | |
6248 err_msg("tams: "PTR_FORMAT" end: "PTR_FORMAT, tams, end)); | |
6249 HeapWord* result = bitmap->getNextMarkedWordAddress(tams, end); | |
6250 if (result < end) { | |
6251 gclog_or_tty->cr(); | |
6252 gclog_or_tty->print_cr("## wrong marked address on %s bitmap: "PTR_FORMAT, | |
6253 bitmap_name, result); | |
6254 gclog_or_tty->print_cr("## %s tams: "PTR_FORMAT" end: "PTR_FORMAT, | |
6255 bitmap_name, tams, end); | |
6256 return false; | |
6257 } | |
6258 return true; | |
6259 } | |
6260 | |
6261 bool G1CollectedHeap::verify_bitmaps(const char* caller, HeapRegion* hr) { | |
6262 CMBitMapRO* prev_bitmap = concurrent_mark()->prevMarkBitMap(); | |
6263 CMBitMapRO* next_bitmap = (CMBitMapRO*) concurrent_mark()->nextMarkBitMap(); | |
6264 | |
6265 HeapWord* bottom = hr->bottom(); | |
6266 HeapWord* ptams = hr->prev_top_at_mark_start(); | |
6267 HeapWord* ntams = hr->next_top_at_mark_start(); | |
6268 HeapWord* end = hr->end(); | |
6269 | |
6270 bool res_p = verify_no_bits_over_tams("prev", prev_bitmap, ptams, end); | |
6271 | |
6272 bool res_n = true; | |
6273 // We reset mark_in_progress() before we reset _cmThread->in_progress() and in this window | |
6274 // we do the clearing of the next bitmap concurrently. Thus, we can not verify the bitmap | |
6275 // if we happen to be in that state. | |
6276 if (mark_in_progress() || !_cmThread->in_progress()) { | |
6277 res_n = verify_no_bits_over_tams("next", next_bitmap, ntams, end); | |
6278 } | |
6279 if (!res_p || !res_n) { | |
6280 gclog_or_tty->print_cr("#### Bitmap verification failed for "HR_FORMAT, | |
6281 HR_FORMAT_PARAMS(hr)); | |
6282 gclog_or_tty->print_cr("#### Caller: %s", caller); | |
6283 return false; | |
6284 } | |
6285 return true; | |
6286 } | |
6287 | |
6288 void G1CollectedHeap::check_bitmaps(const char* caller, HeapRegion* hr) { | |
6289 if (!G1VerifyBitmaps) return; | |
6290 | |
6291 guarantee(verify_bitmaps(caller, hr), "bitmap verification"); | |
6292 } | |
6293 | |
6294 class G1VerifyBitmapClosure : public HeapRegionClosure { | |
6295 private: | |
6296 const char* _caller; | |
6297 G1CollectedHeap* _g1h; | |
6298 bool _failures; | |
6299 | |
6300 public: | |
6301 G1VerifyBitmapClosure(const char* caller, G1CollectedHeap* g1h) : | |
6302 _caller(caller), _g1h(g1h), _failures(false) { } | |
6303 | |
6304 bool failures() { return _failures; } | |
6305 | |
6306 virtual bool doHeapRegion(HeapRegion* hr) { | |
6307 if (hr->continuesHumongous()) return false; | |
6308 | |
6309 bool result = _g1h->verify_bitmaps(_caller, hr); | |
6310 if (!result) { | |
6311 _failures = true; | |
6312 } | |
6313 return false; | |
6314 } | |
6315 }; | |
6316 | |
6317 void G1CollectedHeap::check_bitmaps(const char* caller) { | |
6318 if (!G1VerifyBitmaps) return; | |
6319 | |
6320 G1VerifyBitmapClosure cl(caller, this); | |
6321 heap_region_iterate(&cl); | |
6322 guarantee(!cl.failures(), "bitmap verification"); | |
6323 } | |
6324 #endif // PRODUCT | |
6224 | 6325 |
6225 void G1CollectedHeap::cleanUpCardTable() { | 6326 void G1CollectedHeap::cleanUpCardTable() { |
6226 G1SATBCardTableModRefBS* ct_bs = g1_barrier_set(); | 6327 G1SATBCardTableModRefBS* ct_bs = g1_barrier_set(); |
6227 double start = os::elapsedTime(); | 6328 double start = os::elapsedTime(); |
6228 | 6329 |
6607 false /* is_old */, | 6708 false /* is_old */, |
6608 false /* do_expand */); | 6709 false /* do_expand */); |
6609 if (new_alloc_region != NULL) { | 6710 if (new_alloc_region != NULL) { |
6610 set_region_short_lived_locked(new_alloc_region); | 6711 set_region_short_lived_locked(new_alloc_region); |
6611 _hr_printer.alloc(new_alloc_region, G1HRPrinter::Eden, young_list_full); | 6712 _hr_printer.alloc(new_alloc_region, G1HRPrinter::Eden, young_list_full); |
6713 check_bitmaps("Mutator Region Allocation", new_alloc_region); | |
6612 return new_alloc_region; | 6714 return new_alloc_region; |
6613 } | 6715 } |
6614 } | 6716 } |
6615 return NULL; | 6717 return NULL; |
6616 } | 6718 } |
6673 // for survivors too. | 6775 // for survivors too. |
6674 new_alloc_region->record_top_and_timestamp(); | 6776 new_alloc_region->record_top_and_timestamp(); |
6675 if (survivor) { | 6777 if (survivor) { |
6676 new_alloc_region->set_survivor(); | 6778 new_alloc_region->set_survivor(); |
6677 _hr_printer.alloc(new_alloc_region, G1HRPrinter::Survivor); | 6779 _hr_printer.alloc(new_alloc_region, G1HRPrinter::Survivor); |
6780 check_bitmaps("Survivor Region Allocation", new_alloc_region); | |
6678 } else { | 6781 } else { |
6679 _hr_printer.alloc(new_alloc_region, G1HRPrinter::Old); | 6782 _hr_printer.alloc(new_alloc_region, G1HRPrinter::Old); |
6783 check_bitmaps("Old Region Allocation", new_alloc_region); | |
6680 } | 6784 } |
6681 bool during_im = g1_policy()->during_initial_mark_pause(); | 6785 bool during_im = g1_policy()->during_initial_mark_pause(); |
6682 new_alloc_region->note_start_of_copying(during_im); | 6786 new_alloc_region->note_start_of_copying(during_im); |
6683 return new_alloc_region; | 6787 return new_alloc_region; |
6684 } else { | 6788 } else { |