< prev index next >
src/share/vm/utilities/bitMap.cpp
Print this page
rev 13451 : imported patch remove_cmpxchg_ptr_users
rev 13475 : imported patch replace_if_null
rev 13477 : imported patch fix_popc_table
*** 208,223 ****
void BitMap::par_put_range_within_word(idx_t beg, idx_t end, bool value) {
assert(value == 0 || value == 1, "0 for clear, 1 for set");
// With a valid range (beg <= end), this test ensures that end != 0, as
// required by inverted_bit_mask_for_range. Also avoids an unnecessary write.
if (beg != end) {
! intptr_t* pw = (intptr_t*)word_addr(beg);
! intptr_t w = *pw;
! intptr_t mr = (intptr_t)inverted_bit_mask_for_range(beg, end);
! intptr_t nw = value ? (w | ~mr) : (w & mr);
while (true) {
! intptr_t res = Atomic::cmpxchg_ptr(nw, pw, w);
if (res == w) break;
w = res;
nw = value ? (w | ~mr) : (w & mr);
}
}
--- 208,223 ----
void BitMap::par_put_range_within_word(idx_t beg, idx_t end, bool value) {
assert(value == 0 || value == 1, "0 for clear, 1 for set");
// With a valid range (beg <= end), this test ensures that end != 0, as
// required by inverted_bit_mask_for_range. Also avoids an unnecessary write.
if (beg != end) {
! bm_word_t* pw = word_addr(beg);
! bm_word_t w = *pw;
! bm_word_t mr = inverted_bit_mask_for_range(beg, end);
! bm_word_t nw = value ? (w | ~mr) : (w & mr);
while (true) {
! bm_word_t res = Atomic::cmpxchg(nw, pw, w);
if (res == w) break;
w = res;
nw = value ? (w | ~mr) : (w & mr);
}
}
*** 615,638 ****
}
}
return true;
}
! BitMap::idx_t* BitMap::_pop_count_table = NULL;
void BitMap::init_pop_count_table() {
if (_pop_count_table == NULL) {
BitMap::idx_t *table = NEW_C_HEAP_ARRAY(idx_t, 256, mtInternal);
for (uint i = 0; i < 256; i++) {
table[i] = num_set_bits(i);
}
! intptr_t res = Atomic::cmpxchg_ptr((intptr_t) table,
! (intptr_t*) &_pop_count_table,
! (intptr_t) NULL_WORD);
! if (res != NULL_WORD) {
! guarantee( _pop_count_table == (void*) res, "invariant" );
FREE_C_HEAP_ARRAY(idx_t, table);
}
}
}
--- 615,635 ----
}
}
return true;
}
! const BitMap::idx_t* BitMap::_pop_count_table = NULL;
void BitMap::init_pop_count_table() {
if (_pop_count_table == NULL) {
BitMap::idx_t *table = NEW_C_HEAP_ARRAY(idx_t, 256, mtInternal);
for (uint i = 0; i < 256; i++) {
table[i] = num_set_bits(i);
}
! if (!Atomic::replace_if_null(table, &_pop_count_table)) {
! guarantee(_pop_count_table != NULL, "invariant");
FREE_C_HEAP_ARRAY(idx_t, table);
}
}
}
< prev index next >