< prev index next >

src/hotspot/share/utilities/bitMap.inline.hpp

Print this page




  31 #include "utilities/count_trailing_zeros.hpp"
  32 
  33 inline void BitMap::set_bit(idx_t bit) {
  34   verify_index(bit);
  35   *word_addr(bit) |= bit_mask(bit);
  36 }
  37 
  38 inline void BitMap::clear_bit(idx_t bit) {
  39   verify_index(bit);
  40   *word_addr(bit) &= ~bit_mask(bit);
  41 }
  42 
  43 inline const BitMap::bm_word_t BitMap::load_word_ordered(const volatile bm_word_t* const addr, atomic_memory_order memory_order) {
  44   if (memory_order == memory_order_relaxed || memory_order == memory_order_release) {
  45     return Atomic::load(addr);
  46   } else {
  47     assert(memory_order == memory_order_acq_rel ||
  48            memory_order == memory_order_acquire ||
  49            memory_order == memory_order_conservative,
  50            "unexpected memory ordering");
  51     return OrderAccess::load_acquire(addr);
  52   }
  53 }
  54 
  55 inline bool BitMap::par_at(idx_t index, atomic_memory_order memory_order) const {
  56   verify_index(index);
  57   assert(memory_order == memory_order_acquire ||
  58          memory_order == memory_order_relaxed,
  59          "unexpected memory ordering");
  60   const volatile bm_word_t* const addr = word_addr(index);
  61   return (load_word_ordered(addr, memory_order) & bit_mask(index)) != 0;
  62 }
  63 
  64 inline bool BitMap::par_set_bit(idx_t bit, atomic_memory_order memory_order) {
  65   verify_index(bit);
  66   volatile bm_word_t* const addr = word_addr(bit);
  67   const bm_word_t mask = bit_mask(bit);
  68   bm_word_t old_val = load_word_ordered(addr, memory_order);
  69 
  70   do {
  71     const bm_word_t new_val = old_val | mask;




  31 #include "utilities/count_trailing_zeros.hpp"
  32 
  33 inline void BitMap::set_bit(idx_t bit) {
  34   verify_index(bit);
  35   *word_addr(bit) |= bit_mask(bit);
  36 }
  37 
  38 inline void BitMap::clear_bit(idx_t bit) {
  39   verify_index(bit);
  40   *word_addr(bit) &= ~bit_mask(bit);
  41 }
  42 
  43 inline const BitMap::bm_word_t BitMap::load_word_ordered(const volatile bm_word_t* const addr, atomic_memory_order memory_order) {
  44   if (memory_order == memory_order_relaxed || memory_order == memory_order_release) {
  45     return Atomic::load(addr);
  46   } else {
  47     assert(memory_order == memory_order_acq_rel ||
  48            memory_order == memory_order_acquire ||
  49            memory_order == memory_order_conservative,
  50            "unexpected memory ordering");
  51     return Atomic::load_acquire(addr);
  52   }
  53 }
  54 
  55 inline bool BitMap::par_at(idx_t index, atomic_memory_order memory_order) const {
  56   verify_index(index);
  57   assert(memory_order == memory_order_acquire ||
  58          memory_order == memory_order_relaxed,
  59          "unexpected memory ordering");
  60   const volatile bm_word_t* const addr = word_addr(index);
  61   return (load_word_ordered(addr, memory_order) & bit_mask(index)) != 0;
  62 }
  63 
  64 inline bool BitMap::par_set_bit(idx_t bit, atomic_memory_order memory_order) {
  65   verify_index(bit);
  66   volatile bm_word_t* const addr = word_addr(bit);
  67   const bm_word_t mask = bit_mask(bit);
  68   bm_word_t old_val = load_word_ordered(addr, memory_order);
  69 
  70   do {
  71     const bm_word_t new_val = old_val | mask;


< prev index next >