8059474: Clean up vm/utilities/Bitmap type uses

Reviewed-by: coleenp, mgerdin
This commit is contained in:
Aleksey Shipilev 2014-10-01 12:29:28 +04:00
parent 82931dcc1c
commit 8c9dff938c
3 changed files with 22 additions and 22 deletions

View File

@ -342,9 +342,9 @@ bool BitMap::set_union_with_result(BitMap other) {
bm_word_t* other_map = other.map();
idx_t size = size_in_words();
for (idx_t index = 0; index < size; index++) {
idx_t temp = map(index) | other_map[index];
changed = changed || (temp != map(index));
map()[index] = temp;
idx_t temp = dest_map[index] | other_map[index];
changed = changed || (temp != dest_map[index]);
dest_map[index] = temp;
}
return changed;
}
@ -407,10 +407,10 @@ bool BitMap::is_full() const {
bm_word_t* word = map();
idx_t rest = size();
for (; rest >= (idx_t) BitsPerWord; rest -= BitsPerWord) {
if (*word != (bm_word_t) AllBits) return false;
if (*word != ~(bm_word_t)0) return false;
word++;
}
return rest == 0 || (*word | ~right_n_bits((int)rest)) == (bm_word_t) AllBits;
return rest == 0 || (*word | ~right_n_bits((int)rest)) == ~(bm_word_t)0;
}
@ -418,10 +418,10 @@ bool BitMap::is_empty() const {
bm_word_t* word = map();
idx_t rest = size();
for (; rest >= (idx_t) BitsPerWord; rest -= BitsPerWord) {
if (*word != (bm_word_t) NoBits) return false;
if (*word != 0) return false;
word++;
}
return rest == 0 || (*word & right_n_bits((int)rest)) == (bm_word_t) NoBits;
return rest == 0 || (*word & right_n_bits((int)rest)) == 0;
}
void BitMap::clear_large() {
@ -441,7 +441,7 @@ bool BitMap::iterate(BitMapClosure* blk, idx_t leftOffset, idx_t rightOffset) {
offset < rightOffset && index < endIndex;
offset = (++index) << LogBitsPerWord) {
idx_t rest = map(index) >> (offset & (BitsPerWord - 1));
for (; offset < rightOffset && rest != (bm_word_t)NoBits; offset++) {
for (; offset < rightOffset && rest != 0; offset++) {
if (rest & 1) {
if (!blk->do_bit(offset)) return false;
// resample at each closure application
@ -468,7 +468,7 @@ void BitMap::init_pop_count_table() {
(intptr_t) NULL_WORD);
if (res != NULL_WORD) {
guarantee( _pop_count_table == (void*) res, "invariant" );
FREE_C_HEAP_ARRAY(bm_word_t, table, mtInternal);
FREE_C_HEAP_ARRAY(idx_t, table, mtInternal);
}
}
}

View File

@ -80,7 +80,7 @@ class BitMap VALUE_OBJ_CLASS_SPEC {
// Set a word to a specified value or to all ones; clear a word.
void set_word (idx_t word, bm_word_t val) { _map[word] = val; }
void set_word (idx_t word) { set_word(word, ~(uintptr_t)0); }
void set_word (idx_t word) { set_word(word, ~(bm_word_t)0); }
void clear_word(idx_t word) { _map[word] = 0; }
// Utilities for ranges of bits. Ranges are half-open [beg, end).

View File

@ -130,7 +130,7 @@ inline void BitMap::par_set_range(idx_t beg, idx_t end, RangeSizeHint hint) {
inline void BitMap::set_range_of_words(idx_t beg, idx_t end) {
bm_word_t* map = _map;
for (idx_t i = beg; i < end; ++i) map[i] = ~(uintptr_t)0;
for (idx_t i = beg; i < end; ++i) map[i] = ~(bm_word_t)0;
}
@ -172,8 +172,8 @@ BitMap::get_next_one_offset_inline(idx_t l_offset, idx_t r_offset) const {
// check bits including and to the _left_ of offset's position
idx_t pos = bit_in_word(res_offset);
idx_t res = map(index) >> pos;
if (res != (uintptr_t)NoBits) {
bm_word_t res = map(index) >> pos;
if (res != 0) {
// find the position of the 1-bit
for (; !(res & 1); res_offset++) {
res = res >> 1;
@ -207,7 +207,7 @@ BitMap::get_next_one_offset_inline(idx_t l_offset, idx_t r_offset) const {
// skip over all word length 0-bit runs
for (index++; index < r_index; index++) {
res = map(index);
if (res != (uintptr_t)NoBits) {
if (res != 0) {
// found a 1, return the offset
for (res_offset = bit_index(index); !(res & 1); res_offset++) {
res = res >> 1;
@ -235,9 +235,9 @@ BitMap::get_next_zero_offset_inline(idx_t l_offset, idx_t r_offset) const {
// check bits including and to the _left_ of offset's position
idx_t pos = res_offset & (BitsPerWord - 1);
idx_t res = (map(index) >> pos) | left_n_bits((int)pos);
bm_word_t res = (map(index) >> pos) | left_n_bits((int)pos);
if (res != (uintptr_t)AllBits) {
if (res != ~(bm_word_t)0) {
// find the position of the 0-bit
for (; res & 1; res_offset++) {
res = res >> 1;
@ -248,7 +248,7 @@ BitMap::get_next_zero_offset_inline(idx_t l_offset, idx_t r_offset) const {
// skip over all word length 1-bit runs
for (index++; index < r_index; index++) {
res = map(index);
if (res != (uintptr_t)AllBits) {
if (res != ~(bm_word_t)0) {
// found a 0, return the offset
for (res_offset = index << LogBitsPerWord; res & 1;
res_offset++) {
@ -277,8 +277,8 @@ BitMap::get_next_one_offset_inline_aligned_right(idx_t l_offset,
idx_t res_offset = l_offset;
// check bits including and to the _left_ of offset's position
idx_t res = map(index) >> bit_in_word(res_offset);
if (res != (uintptr_t)NoBits) {
bm_word_t res = map(index) >> bit_in_word(res_offset);
if (res != 0) {
// find the position of the 1-bit
for (; !(res & 1); res_offset++) {
res = res >> 1;
@ -290,7 +290,7 @@ BitMap::get_next_one_offset_inline_aligned_right(idx_t l_offset,
// skip over all word length 0-bit runs
for (index++; index < r_index; index++) {
res = map(index);
if (res != (uintptr_t)NoBits) {
if (res != 0) {
// found a 1, return the offset
for (res_offset = bit_index(index); !(res & 1); res_offset++) {
res = res >> 1;
@ -321,11 +321,11 @@ BitMap::inverted_bit_mask_for_range(idx_t beg, idx_t end) const {
}
inline void BitMap::set_large_range_of_words(idx_t beg, idx_t end) {
memset(_map + beg, ~(unsigned char)0, (end - beg) * sizeof(uintptr_t));
memset(_map + beg, ~(unsigned char)0, (end - beg) * sizeof(bm_word_t));
}
inline void BitMap::clear_large_range_of_words(idx_t beg, idx_t end) {
memset(_map + beg, 0, (end - beg) * sizeof(uintptr_t));
memset(_map + beg, 0, (end - beg) * sizeof(bm_word_t));
}
inline BitMap::idx_t BitMap::word_index_round_up(idx_t bit) const {