hotspot/src/share/vm/utilities/bitMap.inline.hpp
changeset 19998 c18a7b05127a
parent 11574 8a7fe61966c0
child 22234 da823d78ad65
equal deleted inserted replaced
19997:372bbd87870c 19998:c18a7b05127a
    50   *word_addr(bit) &= ~bit_mask(bit);
    50   *word_addr(bit) &= ~bit_mask(bit);
    51 }
    51 }
    52 
    52 
    53 inline bool BitMap::par_set_bit(idx_t bit) {
    53 inline bool BitMap::par_set_bit(idx_t bit) {
    54   verify_index(bit);
    54   verify_index(bit);
    55   volatile idx_t* const addr = word_addr(bit);
    55   volatile bm_word_t* const addr = word_addr(bit);
    56   const idx_t mask = bit_mask(bit);
    56   const bm_word_t mask = bit_mask(bit);
    57   idx_t old_val = *addr;
    57   bm_word_t old_val = *addr;
    58 
    58 
    59   do {
    59   do {
    60     const idx_t new_val = old_val | mask;
    60     const bm_word_t new_val = old_val | mask;
    61     if (new_val == old_val) {
    61     if (new_val == old_val) {
    62       return false;     // Someone else beat us to it.
    62       return false;     // Someone else beat us to it.
    63     }
    63     }
    64     const idx_t cur_val = (idx_t) Atomic::cmpxchg_ptr((void*) new_val,
    64     const bm_word_t cur_val = (bm_word_t) Atomic::cmpxchg_ptr((void*) new_val,
    65                                                       (volatile void*) addr,
    65                                                       (volatile void*) addr,
    66                                                       (void*) old_val);
    66                                                       (void*) old_val);
    67     if (cur_val == old_val) {
    67     if (cur_val == old_val) {
    68       return true;      // Success.
    68       return true;      // Success.
    69     }
    69     }
    71   } while (true);
    71   } while (true);
    72 }
    72 }
    73 
    73 
    74 inline bool BitMap::par_clear_bit(idx_t bit) {
    74 inline bool BitMap::par_clear_bit(idx_t bit) {
    75   verify_index(bit);
    75   verify_index(bit);
    76   volatile idx_t* const addr = word_addr(bit);
    76   volatile bm_word_t* const addr = word_addr(bit);
    77   const idx_t mask = ~bit_mask(bit);
    77   const bm_word_t mask = ~bit_mask(bit);
    78   idx_t old_val = *addr;
    78   bm_word_t old_val = *addr;
    79 
    79 
    80   do {
    80   do {
    81     const idx_t new_val = old_val & mask;
    81     const bm_word_t new_val = old_val & mask;
    82     if (new_val == old_val) {
    82     if (new_val == old_val) {
    83       return false;     // Someone else beat us to it.
    83       return false;     // Someone else beat us to it.
    84     }
    84     }
    85     const idx_t cur_val = (idx_t) Atomic::cmpxchg_ptr((void*) new_val,
    85     const bm_word_t cur_val = (bm_word_t) Atomic::cmpxchg_ptr((void*) new_val,
    86                                                       (volatile void*) addr,
    86                                                       (volatile void*) addr,
    87                                                       (void*) old_val);
    87                                                       (void*) old_val);
    88     if (cur_val == old_val) {
    88     if (cur_val == old_val) {
    89       return true;      // Success.
    89       return true;      // Success.
    90     }
    90     }