< prev index next >

src/hotspot/share/utilities/bitMap.cpp

Print this page
rev 48406 : 8194406: Use Atomic::replace_if_null
Reviewed-by: coleenp, dholmes


 611         if (!blk->do_bit(offset)) return false;
 612         //  resample at each closure application
 613         // (see, for instance, CMS bug 4525989)
 614         rest = map(index) >> (offset & (BitsPerWord -1));
 615       }
 616       rest = rest >> 1;
 617     }
 618   }
 619   return true;
 620 }
 621 
 622 const BitMap::idx_t* BitMap::_pop_count_table = NULL;
 623 
 624 void BitMap::init_pop_count_table() {
 625   if (_pop_count_table == NULL) {
 626     BitMap::idx_t *table = NEW_C_HEAP_ARRAY(idx_t, 256, mtInternal);
 627     for (uint i = 0; i < 256; i++) {
 628       table[i] = num_set_bits(i);
 629     }
 630 
 631     if (Atomic::cmpxchg(table, &_pop_count_table, (BitMap::idx_t*)NULL) != NULL) {
 632       guarantee(_pop_count_table != NULL, "invariant");
 633       FREE_C_HEAP_ARRAY(idx_t, table);
 634     }
 635   }
 636 }
 637 
 638 BitMap::idx_t BitMap::num_set_bits(bm_word_t w) {
 639   idx_t bits = 0;
 640 
 641   while (w != 0) {
 642     while ((w & 1) == 0) {
 643       w >>= 1;
 644     }
 645     bits++;
 646     w >>= 1;
 647   }
 648   return bits;
 649 }
 650 
 651 BitMap::idx_t BitMap::num_set_bits_from_table(unsigned char c) {




 611         if (!blk->do_bit(offset)) return false;
 612         //  resample at each closure application
 613         // (see, for instance, CMS bug 4525989)
 614         rest = map(index) >> (offset & (BitsPerWord -1));
 615       }
 616       rest = rest >> 1;
 617     }
 618   }
 619   return true;
 620 }
 621 
 622 const BitMap::idx_t* BitMap::_pop_count_table = NULL;
 623 
 624 void BitMap::init_pop_count_table() {
 625   if (_pop_count_table == NULL) {
 626     BitMap::idx_t *table = NEW_C_HEAP_ARRAY(idx_t, 256, mtInternal);
 627     for (uint i = 0; i < 256; i++) {
 628       table[i] = num_set_bits(i);
 629     }
 630 
 631     if (!Atomic::replace_if_null(table, &_pop_count_table)) {
 632       guarantee(_pop_count_table != NULL, "invariant");
 633       FREE_C_HEAP_ARRAY(idx_t, table);
 634     }
 635   }
 636 }
 637 
 638 BitMap::idx_t BitMap::num_set_bits(bm_word_t w) {
 639   idx_t bits = 0;
 640 
 641   while (w != 0) {
 642     while ((w & 1) == 0) {
 643       w >>= 1;
 644     }
 645     bits++;
 646     w >>= 1;
 647   }
 648   return bits;
 649 }
 650 
 651 BitMap::idx_t BitMap::num_set_bits_from_table(unsigned char c) {


< prev index next >