8151440: Move BitMap verfication inline functions out from bitMap.hpp

Reviewed-by: tschatzl, pliden, kbarrett
This commit is contained in:
Stefan Karlsson 2016-03-09 12:45:44 +01:00
parent 48813d4d84
commit dd34e9b751
3 changed files with 50 additions and 46 deletions

View File

@ -34,10 +34,21 @@ STATIC_ASSERT(sizeof(BitMap::bm_word_t) == BytesPerWord); // "Implementation ass
BitMap::BitMap(idx_t size_in_bits, bool in_resource_area) :
_map(NULL), _size(0)
{
assert(sizeof(bm_word_t) == BytesPerWord, "Implementation assumption.");
resize(size_in_bits, in_resource_area);
}
#ifdef ASSERT
void BitMap::verify_index(idx_t index) const {
assert(index < _size, "BitMap index out of bounds");
}
void BitMap::verify_range(idx_t beg_index, idx_t end_index) const {
assert(beg_index <= end_index, "BitMap range error");
// Note that [0,0) and [size,size) are both valid ranges.
if (end_index != _size) verify_index(end_index);
}
#endif // #ifdef ASSERT
void BitMap::resize(idx_t size_in_bits, bool in_resource_area) {
idx_t old_size_in_words = size_in_words();
bm_word_t* old_map = map();

View File

@ -100,9 +100,8 @@ class BitMap VALUE_OBJ_CLASS_SPEC {
idx_t word_index_round_up(idx_t bit) const;
// Verification.
inline void verify_index(idx_t index) const NOT_DEBUG_RETURN;
inline void verify_range(idx_t beg_index, idx_t end_index) const
NOT_DEBUG_RETURN;
void verify_index(idx_t index) const NOT_DEBUG_RETURN;
void verify_range(idx_t beg_index, idx_t end_index) const NOT_DEBUG_RETURN;
// Statistics.
static idx_t* _pop_count_table;
@ -306,36 +305,12 @@ class BitMap2D VALUE_OBJ_CLASS_SPEC {
return _map.size() / _bits_per_slot;
}
bool is_valid_index(idx_t slot_index, idx_t bit_within_slot_index) {
verify_bit_within_slot_index(bit_within_slot_index);
return (bit_index(slot_index, bit_within_slot_index) < size_in_bits());
}
bool at(idx_t slot_index, idx_t bit_within_slot_index) const {
verify_bit_within_slot_index(bit_within_slot_index);
return _map.at(bit_index(slot_index, bit_within_slot_index));
}
void set_bit(idx_t slot_index, idx_t bit_within_slot_index) {
verify_bit_within_slot_index(bit_within_slot_index);
_map.set_bit(bit_index(slot_index, bit_within_slot_index));
}
void clear_bit(idx_t slot_index, idx_t bit_within_slot_index) {
verify_bit_within_slot_index(bit_within_slot_index);
_map.clear_bit(bit_index(slot_index, bit_within_slot_index));
}
void at_put(idx_t slot_index, idx_t bit_within_slot_index, bool value) {
verify_bit_within_slot_index(bit_within_slot_index);
_map.at_put(bit_index(slot_index, bit_within_slot_index), value);
}
void at_put_grow(idx_t slot_index, idx_t bit_within_slot_index, bool value) {
verify_bit_within_slot_index(bit_within_slot_index);
_map.at_put_grow(bit_index(slot_index, bit_within_slot_index), value);
}
bool is_valid_index(idx_t slot_index, idx_t bit_within_slot_index);
bool at(idx_t slot_index, idx_t bit_within_slot_index) const;
void set_bit(idx_t slot_index, idx_t bit_within_slot_index);
void clear_bit(idx_t slot_index, idx_t bit_within_slot_index);
void at_put(idx_t slot_index, idx_t bit_within_slot_index, bool value);
void at_put_grow(idx_t slot_index, idx_t bit_within_slot_index, bool value);
void clear();
};

View File

@ -28,18 +28,6 @@
#include "runtime/atomic.inline.hpp"
#include "utilities/bitMap.hpp"
#ifdef ASSERT
inline void BitMap::verify_index(idx_t index) const {
assert(index < _size, "BitMap index out of bounds");
}
inline void BitMap::verify_range(idx_t beg_index, idx_t end_index) const {
assert(beg_index <= end_index, "BitMap range error");
// Note that [0,0) and [size,size) are both valid ranges.
if (end_index != _size) verify_index(end_index);
}
#endif // #ifdef ASSERT
inline void BitMap::set_bit(idx_t bit) {
verify_index(bit);
*word_addr(bit) |= bit_mask(bit);
@ -344,6 +332,36 @@ inline BitMap::idx_t BitMap::get_next_zero_offset(idx_t l_offset,
return get_next_zero_offset_inline(l_offset, r_offset);
}
inline bool BitMap2D::is_valid_index(idx_t slot_index, idx_t bit_within_slot_index) {
verify_bit_within_slot_index(bit_within_slot_index);
return (bit_index(slot_index, bit_within_slot_index) < size_in_bits());
}
inline bool BitMap2D::at(idx_t slot_index, idx_t bit_within_slot_index) const {
verify_bit_within_slot_index(bit_within_slot_index);
return _map.at(bit_index(slot_index, bit_within_slot_index));
}
inline void BitMap2D::set_bit(idx_t slot_index, idx_t bit_within_slot_index) {
verify_bit_within_slot_index(bit_within_slot_index);
_map.set_bit(bit_index(slot_index, bit_within_slot_index));
}
inline void BitMap2D::clear_bit(idx_t slot_index, idx_t bit_within_slot_index) {
verify_bit_within_slot_index(bit_within_slot_index);
_map.clear_bit(bit_index(slot_index, bit_within_slot_index));
}
inline void BitMap2D::at_put(idx_t slot_index, idx_t bit_within_slot_index, bool value) {
verify_bit_within_slot_index(bit_within_slot_index);
_map.at_put(bit_index(slot_index, bit_within_slot_index), value);
}
inline void BitMap2D::at_put_grow(idx_t slot_index, idx_t bit_within_slot_index, bool value) {
verify_bit_within_slot_index(bit_within_slot_index);
_map.at_put_grow(bit_index(slot_index, bit_within_slot_index), value);
}
inline void BitMap2D::clear() {
_map.clear();
}