src/share/vm/gc_implementation/g1/g1CardCounts.cpp

Print this page
rev 4650 : 8014408: G1: crashes with assert assert(prev_committed_card_num == _committed_max_card_num) failed
Summary: Mismatch in the card number calculation between next and previous committed sizes of the card counts table.
Reviewed-by:


  84 
  85     MemTracker::record_virtual_memory_type((address)rs.base(), mtGC);
  86 
  87     _card_counts_storage.initialize(rs, 0);
  88     _card_counts = (jubyte*) _card_counts_storage.low();
  89   }
  90 }
  91 
  92 void G1CardCounts::resize(size_t heap_capacity) {
  93   // Expand the card counts table to handle a heap with the given capacity.
  94 
  95   if (!has_reserved_count_table()) {
  96     // Don't expand if we failed to reserve the card counts table.
  97     return;
  98   }
  99 
 100   assert(_committed_size ==
 101          ReservedSpace::allocation_align_size_up(_committed_size),
 102          err_msg("Unaligned? committed_size: " SIZE_FORMAT, _committed_size));
 103 
 104   // Verify that the committed space for the card counts
 105   // matches our committed max card num.


 106   size_t prev_committed_size = _committed_size;
 107   size_t prev_committed_card_num = prev_committed_size / sizeof(jbyte);

 108   assert(prev_committed_card_num == _committed_max_card_num,
 109          err_msg("Card mismatch: "
 110                  "prev: " SIZE_FORMAT ", "
 111                  "committed: "SIZE_FORMAT,
 112                  prev_committed_card_num, _committed_max_card_num));

 113 
 114   size_t new_size = (heap_capacity >> CardTableModRefBS::card_shift) * sizeof(jbyte);
 115   size_t new_committed_size = ReservedSpace::allocation_align_size_up(new_size);
 116   size_t new_committed_card_num =
 117                 MIN2(_reserved_max_card_num, new_committed_size / sizeof(jbyte));
 118 
 119   if (_committed_max_card_num < new_committed_card_num) {
 120     // we need to expand the backing store for the card counts
 121     size_t expand_size = new_committed_size - prev_committed_size;
 122 
 123     if (!_card_counts_storage.expand_by(expand_size)) {
 124       warning("Card counts table backing store commit failure");
 125       return;
 126     }
 127     assert(_card_counts_storage.committed_size() == new_committed_size,
 128            "expansion commit failure");
 129 
 130     _committed_size = new_committed_size;
 131     _committed_max_card_num = new_committed_card_num;
 132 
 133     clear_range(prev_committed_card_num, _committed_max_card_num);
 134   }
 135 }
 136 
 137 uint G1CardCounts::add_card_count(jbyte* card_ptr) {




  84 
  85     MemTracker::record_virtual_memory_type((address)rs.base(), mtGC);
  86 
  87     _card_counts_storage.initialize(rs, 0);
  88     _card_counts = (jubyte*) _card_counts_storage.low();
  89   }
  90 }
  91 
  92 void G1CardCounts::resize(size_t heap_capacity) {
  93   // Expand the card counts table to handle a heap with the given capacity.
  94 
  95   if (!has_reserved_count_table()) {
  96     // Don't expand if we failed to reserve the card counts table.
  97     return;
  98   }
  99 
 100   assert(_committed_size ==
 101          ReservedSpace::allocation_align_size_up(_committed_size),
 102          err_msg("Unaligned? committed_size: " SIZE_FORMAT, _committed_size));
 103 
 104   // Verify that the committed space for the card counts matches our
 105   // committed max card num. Note for some allocation alignments, the
 106   // amount of space actually committed for the counts table will be able
 107   // to span more cards than the number spanned by the maximum heap.
 108   size_t prev_committed_size = _committed_size;
 109   size_t prev_committed_card_num = committed_to_card_num(prev_committed_size);
 110 
 111   assert(prev_committed_card_num == _committed_max_card_num,
 112          err_msg("Card mismatch: "
 113                  "prev: " SIZE_FORMAT ", "
 114                  "committed: "SIZE_FORMAT", "
 115                  "reserved: "SIZE_FORMAT,
 116                  prev_committed_card_num, _committed_max_card_num, _reserved_max_card_num));
 117 
 118   size_t new_size = (heap_capacity >> CardTableModRefBS::card_shift) * sizeof(jbyte);
 119   size_t new_committed_size = ReservedSpace::allocation_align_size_up(new_size);
 120   size_t new_committed_card_num = committed_to_card_num(new_committed_size);

 121 
 122   if (_committed_max_card_num < new_committed_card_num) {
 123     // we need to expand the backing store for the card counts
 124     size_t expand_size = new_committed_size - prev_committed_size;
 125 
 126     if (!_card_counts_storage.expand_by(expand_size)) {
 127       warning("Card counts table backing store commit failure");
 128       return;
 129     }
 130     assert(_card_counts_storage.committed_size() == new_committed_size,
 131            "expansion commit failure");
 132 
 133     _committed_size = new_committed_size;
 134     _committed_max_card_num = new_committed_card_num;
 135 
 136     clear_range(prev_committed_card_num, _committed_max_card_num);
 137   }
 138 }
 139 
 140 uint G1CardCounts::add_card_count(jbyte* card_ptr) {