comparison src/share/vm/memory/cardTableRS.cpp @ 21114:2daf39328194

Better error reporting for missing card marks
author Tom Rodriguez <tom.rodriguez@oracle.com>
date Thu, 23 Apr 2015 21:18:27 -0700
parents 7848fc12602b
children
comparison
equal deleted inserted replaced
21113:0cf5897db25a 21114:2daf39328194
350 assert(jp >= _begin && jp < _end, 350 assert(jp >= _begin && jp < _end,
351 err_msg("Error: jp " PTR_FORMAT " should be within " 351 err_msg("Error: jp " PTR_FORMAT " should be within "
352 "[_begin, _end) = [" PTR_FORMAT "," PTR_FORMAT ")", 352 "[_begin, _end) = [" PTR_FORMAT "," PTR_FORMAT ")",
353 p2i(jp), p2i(_begin), p2i(_end))); 353 p2i(jp), p2i(_begin), p2i(_end)));
354 oop obj = oopDesc::load_decode_heap_oop(p); 354 oop obj = oopDesc::load_decode_heap_oop(p);
355 guarantee(obj == NULL || (HeapWord*)obj >= _boundary, 355 if (!(obj == NULL || (HeapWord*)obj >= _boundary)) {
356 err_msg("pointer " PTR_FORMAT " at " PTR_FORMAT " on " 356 tty->print_cr("pointer " PTR_FORMAT " at " PTR_FORMAT " on "
357 "clean card crosses boundary" PTR_FORMAT, 357 "clean card crosses boundary" PTR_FORMAT,
358 p2i((HeapWord*)obj), p2i(jp), p2i(_boundary))); 358 p2i((HeapWord*)obj), p2i(jp), p2i(_boundary));
359 #ifndef PRODUCT
360 obj->print();
361 #endif
362 had_error = true;
363 }
359 } 364 }
360 365
361 public: 366 public:
367 bool had_error;
368
362 VerifyCleanCardClosure(HeapWord* b, HeapWord* begin, HeapWord* end) : 369 VerifyCleanCardClosure(HeapWord* b, HeapWord* begin, HeapWord* end) :
363 _boundary(b), _begin(begin), _end(end) { 370 _boundary(b), _begin(begin), _end(end), had_error(false) {
364 assert(b <= begin, 371 assert(b <= begin,
365 err_msg("Error: boundary " PTR_FORMAT " should be at or below begin " PTR_FORMAT, 372 err_msg("Error: boundary " PTR_FORMAT " should be at or below begin " PTR_FORMAT,
366 p2i(b), p2i(begin))); 373 p2i(b), p2i(begin)));
367 assert(begin <= end, 374 assert(begin <= end,
368 err_msg("Error: begin " PTR_FORMAT " should be strictly below end " PTR_FORMAT, 375 err_msg("Error: begin " PTR_FORMAT " should be strictly below end " PTR_FORMAT,
398 405
399 void CardTableRS::verify_space(Space* s, HeapWord* gen_boundary) { 406 void CardTableRS::verify_space(Space* s, HeapWord* gen_boundary) {
400 // We don't need to do young-gen spaces. 407 // We don't need to do young-gen spaces.
401 if (s->end() <= gen_boundary) return; 408 if (s->end() <= gen_boundary) return;
402 MemRegion used = s->used_region(); 409 MemRegion used = s->used_region();
410 bool had_error = false;
403 411
404 jbyte* cur_entry = byte_for(used.start()); 412 jbyte* cur_entry = byte_for(used.start());
405 jbyte* limit = byte_after(used.last()); 413 jbyte* limit = byte_after(used.last());
406 while (cur_entry < limit) { 414 while (cur_entry < limit) {
407 if (*cur_entry == CardTableModRefBS::clean_card) { 415 if (*cur_entry == CardTableModRefBS::clean_card) {
436 MemRegion mr(begin, end); 444 MemRegion mr(begin, end);
437 VerifyCleanCardClosure verify_blk(gen_boundary, begin, end); 445 VerifyCleanCardClosure verify_blk(gen_boundary, begin, end);
438 for (HeapWord* cur = start_block; cur < end; cur += s->block_size(cur)) { 446 for (HeapWord* cur = start_block; cur < end; cur += s->block_size(cur)) {
439 if (s->block_is_obj(cur) && s->obj_is_alive(cur)) { 447 if (s->block_is_obj(cur) && s->obj_is_alive(cur)) {
440 oop(cur)->oop_iterate_no_header(&verify_blk, mr); 448 oop(cur)->oop_iterate_no_header(&verify_blk, mr);
449 had_error |= verify_blk.had_error;
450 if (verify_blk.had_error) {
451 verify_blk.had_error = false;
452 #ifndef PRODUCT
453 oop(cur)->print();
454 #endif
455 }
441 } 456 }
442 } 457 }
443 } 458 }
444 cur_entry = first_dirty; 459 cur_entry = first_dirty;
445 } else { 460 } else {
596 // the card-scanning code, if only to simplify the underlying 611 // the card-scanning code, if only to simplify the underlying
597 // state machine analysis/proof. ysr 1/28/2002. XXX 612 // state machine analysis/proof. ysr 1/28/2002. XXX
598 cur_entry++; 613 cur_entry++;
599 } 614 }
600 } 615 }
616 guarantee(!had_error, "Card table errors found");
601 } 617 }
602 618
603 void CardTableRS::verify() { 619 void CardTableRS::verify() {
604 // At present, we only know how to verify the card table RS for 620 // At present, we only know how to verify the card table RS for
605 // generational heaps. 621 // generational heaps.