src/share/vm/gc_implementation/g1/g1BlockOffsetTable.hpp

Print this page
rev 3849 : 7194633: G1: Assertion and guarantee failures in block offset table
Summary: Add detailed error messages to assertions and guarantees in G1's block offset table.
Reviewed-by:

*** 76,86 **** // Note that the committed size of the covered space may have changed, // so the table size might also wish to change. virtual void resize(size_t new_word_size) = 0; virtual void set_bottom(HeapWord* new_bottom) { ! assert(new_bottom <= _end, "new_bottom > _end"); _bottom = new_bottom; resize(pointer_delta(_end, _bottom)); } // Requires "addr" to be contained by a block, and returns the address of --- 76,88 ---- // Note that the committed size of the covered space may have changed, // so the table size might also wish to change. virtual void resize(size_t new_word_size) = 0; virtual void set_bottom(HeapWord* new_bottom) { ! assert(new_bottom <= _end, ! err_msg("new_bottom ("PTR_FORMAT") > _end ("PTR_FORMAT")", ! new_bottom, _end)); _bottom = new_bottom; resize(pointer_delta(_end, _bottom)); } // Requires "addr" to be contained by a block, and returns the address of
*** 132,164 **** // Array for keeping offsets for retrieving object start fast given an // address. VirtualSpace _vs; u_char* _offset_array; // byte array keeping backwards offsets // Bounds checking accessors: // For performance these have to devolve to array accesses in product builds. u_char offset_array(size_t index) const { ! assert(index < _vs.committed_size(), "index out of range"); return _offset_array[index]; } void set_offset_array(size_t index, u_char offset) { ! assert(index < _vs.committed_size(), "index out of range"); ! assert(offset <= N_words, "offset too large"); _offset_array[index] = offset; } void set_offset_array(size_t index, HeapWord* high, HeapWord* low) { ! assert(index < _vs.committed_size(), "index out of range"); assert(high >= low, "addresses out of order"); ! assert(pointer_delta(high, low) <= N_words, "offset too large"); _offset_array[index] = (u_char) pointer_delta(high, low); } void set_offset_array(HeapWord* left, HeapWord* right, u_char offset) { ! assert(index_for(right - 1) < _vs.committed_size(), ! "right address out of range"); assert(left < right, "Heap addresses out of order"); size_t num_cards = pointer_delta(right, left) >> LogN_words; if (UseMemSetInBOT) { memset(&_offset_array[index_for(left)], offset, num_cards); } else { --- 134,179 ---- // Array for keeping offsets for retrieving object start fast given an // address. VirtualSpace _vs; u_char* _offset_array; // byte array keeping backwards offsets + void check_index(size_t index, const char* msg) const { + assert(index < _vs.committed_size(), + err_msg("%s - " + "index: "SIZE_FORMAT", _vs.committed_size: "SIZE_FORMAT, + msg, index, _vs.committed_size())); + } + + void check_offset(unsigned offset, const char* msg) const { + assert(offset <= N_words, + err_msg("%s - " + "offset: "UINT32_FORMAT", N_words: "UINT32_FORMAT, + msg, offset, N_words)); + } + // Bounds checking accessors: // For performance these have to devolve to array accesses in product builds. u_char offset_array(size_t index) const { ! check_index(index, "index out of range"); return _offset_array[index]; } void set_offset_array(size_t index, u_char offset) { ! check_index(index, "index out of range"); ! check_offset(offset, "offset too large"); _offset_array[index] = offset; } void set_offset_array(size_t index, HeapWord* high, HeapWord* low) { ! check_index(index, "index out of range"); assert(high >= low, "addresses out of order"); ! check_offset((unsigned)pointer_delta(high, low), "offset too large"); _offset_array[index] = (u_char) pointer_delta(high, low); } void set_offset_array(HeapWord* left, HeapWord* right, u_char offset) { ! check_index(index_for(right - 1), "right address out of range"); assert(left < right, "Heap addresses out of order"); size_t num_cards = pointer_delta(right, left) >> LogN_words; if (UseMemSetInBOT) { memset(&_offset_array[index_for(left)], offset, num_cards); } else {
*** 169,179 **** } } } void set_offset_array(size_t left, size_t right, u_char offset) { ! assert(right < _vs.committed_size(), "right address out of range"); assert(left <= right, "indexes out of order"); size_t num_cards = right - left + 1; if (UseMemSetInBOT) { memset(&_offset_array[left], offset, num_cards); } else { --- 184,194 ---- } } } void set_offset_array(size_t left, size_t right, u_char offset) { ! check_index(right, "right index out of range"); assert(left <= right, "indexes out of order"); size_t num_cards = right - left + 1; if (UseMemSetInBOT) { memset(&_offset_array[left], offset, num_cards); } else {
*** 184,198 **** } } } void check_offset_array(size_t index, HeapWord* high, HeapWord* low) const { ! assert(index < _vs.committed_size(), "index out of range"); assert(high >= low, "addresses out of order"); ! assert(pointer_delta(high, low) <= N_words, "offset too large"); ! assert(_offset_array[index] == pointer_delta(high, low), ! "Wrong offset"); } bool is_card_boundary(HeapWord* p) const; // Return the number of slots needed for an offset array --- 199,212 ---- } } } void check_offset_array(size_t index, HeapWord* high, HeapWord* low) const { ! check_index(index, "index out of range"); assert(high >= low, "addresses out of order"); ! check_offset(pointer_delta(high, low), "offset too large"); ! assert(_offset_array[index] == pointer_delta(high, low), "Wrong offset"); } bool is_card_boundary(HeapWord* p) const; // Return the number of slots needed for an offset array
*** 479,489 **** void alloc_block_work1(HeapWord* blk_start, HeapWord* blk_end) { alloc_block_work2(&_next_offset_threshold, &_next_offset_index, blk_start, blk_end); } - public: G1BlockOffsetArrayContigSpace(G1BlockOffsetSharedArray* array, MemRegion mr); // Initialize the threshold to reflect the first boundary after the // bottom of the covered region. --- 493,502 ----