< prev index next >
src/share/vm/utilities/bitMap.cpp
Print this page
rev 13431 : imported patch remove_cmpxchg_ptr_users
rev 13455 : [mq]: replace_if_null
rev 13457 : [mq]: fix_popc_table
@@ -208,16 +208,16 @@
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);
+ 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) {
- intptr_t res = Atomic::cmpxchg_ptr(nw, pw, w);
+ bm_word_t res = Atomic::cmpxchg(nw, pw, w);
if (res == w) break;
w = res;
nw = value ? (w | ~mr) : (w & mr);
}
}
@@ -615,24 +615,21 @@
}
}
return true;
}
-BitMap::idx_t* BitMap::_pop_count_table = NULL;
+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);
}
- 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" );
+ 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 >