@@ -211,55 +211,40 @@ void G1BlockOffsetTable::update_for_block_work(HeapWord* blk_start, HeapWord* bl
211
211
" boundary: " PTR_FORMAT,
212
212
(uint )offset_array (offset_card),
213
213
p2i (blk_start), p2i (boundary));
214
- for (uint8_t * j = offset_card + 1 ; j <= end_card; j++) {
215
- assert (offset_array (j) > 0 &&
216
- offset_array (j) <= (uint8_t ) (CardTable::card_size_in_words () + BOTConstants::N_powers - 1 ),
217
- " offset array should have been set - "
218
- " %u not > 0 OR %u not <= %u" ,
219
- (uint ) offset_array (j),
220
- (uint ) offset_array (j),
221
- (uint ) (CardTable::card_size_in_words () + BOTConstants::N_powers - 1 ));
222
- }
223
- #endif
224
- }
225
214
226
- void G1BlockOffsetTable::verify (const HeapRegion* hr) const {
227
- assert (hr->bottom () < hr->top (), " Only non-empty regions should be verified." );
228
- uint8_t * start_card = entry_for_addr (hr->bottom ());
229
- uint8_t * end_card = entry_for_addr (hr->top () - 1 );
215
+ G1BlockOffsetTable::verify_for_block (blk_start, blk_end);
216
+ #endif // ASSERT
217
+ }
230
218
231
- for (uint8_t * current_card = start_card; current_card < end_card; current_card++) {
232
- uint8_t entry = offset_array (current_card);
233
- if (entry < CardTable::card_size_in_words ()) {
234
- // The entry should point to an object before the current card. Verify that
235
- // it is possible to walk from that object in to the current card by just
236
- // iterating over the objects following it.
237
- HeapWord* card_address = addr_for_entry (current_card);
238
- HeapWord* obj_end = card_address - entry;
239
- while (obj_end < card_address) {
240
- HeapWord* obj = obj_end;
241
- size_t obj_size = hr->block_size (obj);
242
- obj_end = obj + obj_size;
243
- guarantee (obj_end > obj && obj_end <= hr->top (),
244
- " Invalid object end. obj: " PTR_FORMAT " obj_size: " SIZE_FORMAT " obj_end: " PTR_FORMAT " top: " PTR_FORMAT,
245
- p2i (obj), obj_size, p2i (obj_end), p2i (hr->top ()));
246
- }
247
- } else {
248
- // Because we refine the BOT based on which cards are dirty there is not much we can verify here.
249
- // We need to make sure that we are going backwards and that we don't pass the start of the
250
- // corresponding heap region. But that is about all we can verify.
251
- size_t backskip = BOTConstants::entry_to_cards_back (entry);
252
- guarantee (backskip >= 1 , " Must be going back at least one card." );
219
+ #ifdef ASSERT
220
+ void G1BlockOffsetTable::verify_offset (uint8_t * card_index, uint8_t upper_boundary) const {
221
+ assert (offset_array (card_index) <= upper_boundary,
222
+ " Offset %u should not be larger than upper boundary %u." ,
223
+ (uint ) offset_array (card_index),
224
+ (uint ) upper_boundary);
225
+ }
253
226
254
- size_t max_backskip = current_card - start_card;
255
- guarantee (backskip <= max_backskip,
256
- " Going backwards beyond the start_card. start_card: " SIZE_FORMAT " current_card: " SIZE_FORMAT " backskip: " SIZE_FORMAT,
257
- p2i (start_card), p2i (current_card), backskip);
227
+ void G1BlockOffsetTable::verify_for_block (HeapWord* blk_start, HeapWord* blk_end) const {
228
+ assert (is_crossing_card_boundary (blk_start, blk_end), " precondition" );
258
229
259
- HeapWord* backskip_address = addr_for_entry (current_card - backskip);
260
- guarantee (backskip_address >= hr->bottom (),
261
- " Going backwards beyond bottom of the region: bottom: " PTR_FORMAT " , backskip_address: " PTR_FORMAT,
262
- p2i (hr->bottom ()), p2i (backskip_address));
230
+ uint8_t * start_card = entry_for_addr (align_up_by_card_size (blk_start));
231
+ uint8_t * end_card = entry_for_addr (blk_end - 1 );
232
+ // Check cards in [start_card, end_card]
233
+ verify_offset (start_card, CardTable::card_size_in_words ());
234
+
235
+ for (uint8_t * current_card = start_card + 1 ; current_card <= end_card; ++current_card) {
236
+ assert (offset_array (current_card) > 0 ,
237
+ " Offset %u is not larger than 0." ,
238
+ (uint ) offset_array (current_card));
239
+ verify_offset (current_card, (uint8_t ) (CardTable::card_size_in_words () + BOTConstants::N_powers - 1 ));
240
+
241
+ uint8_t * prev = current_card - 1 ;
242
+ uint8_t * value = current_card;
243
+ if (offset_array (prev) != offset_array (value)) {
244
+ assert (offset_array (value) >= offset_array (prev), " monotonic" );
245
+ size_t n_cards_back = BOTConstants::entry_to_cards_back (offset_array (value));
246
+ assert (start_card == (current_card - n_cards_back), " inv" );
263
247
}
264
248
}
265
249
}
250
+ #endif // ASSERT
1 commit comments
openjdk-notifier[bot] commentedon Apr 12, 2024
Review
Issues