< prev index next >

src/share/vm/utilities/bitMap.cpp

Print this page
rev 10381 : 8151440: Move BitMap verfication inline functions out from bitMap.hpp


  21  * questions.
  22  *
  23  */
  24 
  25 #include "precompiled.hpp"
  26 #include "memory/allocation.inline.hpp"
  27 #include "memory/resourceArea.hpp"
  28 #include "runtime/atomic.inline.hpp"
  29 #include "utilities/bitMap.inline.hpp"
  30 #include "utilities/copy.hpp"
  31 
  32 STATIC_ASSERT(sizeof(BitMap::bm_word_t) == BytesPerWord); // "Implementation assumption."
  33 
  34 BitMap::BitMap(idx_t size_in_bits, bool in_resource_area) :
  35   _map(NULL), _size(0)
  36 {
  37   assert(sizeof(bm_word_t) == BytesPerWord, "Implementation assumption.");
  38   resize(size_in_bits, in_resource_area);
  39 }
  40 












  41 void BitMap::resize(idx_t size_in_bits, bool in_resource_area) {
  42   idx_t old_size_in_words = size_in_words();
  43   bm_word_t* old_map = map();
  44 
  45   _size = size_in_bits;
  46   idx_t new_size_in_words = size_in_words();
  47   if (in_resource_area) {
  48     _map = NEW_RESOURCE_ARRAY(bm_word_t, new_size_in_words);
  49     Copy::disjoint_words((HeapWord*)old_map, (HeapWord*) _map,
  50                          MIN2(old_size_in_words, new_size_in_words));
  51   } else {
  52     _map = ArrayAllocator<bm_word_t, mtInternal>::reallocate(old_map, old_size_in_words, new_size_in_words);
  53   }
  54 
  55   if (new_size_in_words > old_size_in_words) {
  56     clear_range_of_words(old_size_in_words, new_size_in_words);
  57   }
  58 }
  59 
  60 void BitMap::set_range_within_word(idx_t beg, idx_t end) {




  21  * questions.
  22  *
  23  */
  24 
  25 #include "precompiled.hpp"
  26 #include "memory/allocation.inline.hpp"
  27 #include "memory/resourceArea.hpp"
  28 #include "runtime/atomic.inline.hpp"
  29 #include "utilities/bitMap.inline.hpp"
  30 #include "utilities/copy.hpp"
  31 
  32 STATIC_ASSERT(sizeof(BitMap::bm_word_t) == BytesPerWord); // "Implementation assumption."
  33 
  34 BitMap::BitMap(idx_t size_in_bits, bool in_resource_area) :
  35   _map(NULL), _size(0)
  36 {
  37   assert(sizeof(bm_word_t) == BytesPerWord, "Implementation assumption.");
  38   resize(size_in_bits, in_resource_area);
  39 }
  40 
  41 #ifdef ASSERT
  42 void BitMap::verify_index(idx_t index) const {
  43   assert(index < _size, "BitMap index out of bounds");
  44 }
  45 
  46 void BitMap::verify_range(idx_t beg_index, idx_t end_index) const {
  47   assert(beg_index <= end_index, "BitMap range error");
  48   // Note that [0,0) and [size,size) are both valid ranges.
  49   if (end_index != _size) verify_index(end_index);
  50 }
  51 #endif // #ifdef ASSERT
  52 
  53 void BitMap::resize(idx_t size_in_bits, bool in_resource_area) {
  54   idx_t old_size_in_words = size_in_words();
  55   bm_word_t* old_map = map();
  56 
  57   _size = size_in_bits;
  58   idx_t new_size_in_words = size_in_words();
  59   if (in_resource_area) {
  60     _map = NEW_RESOURCE_ARRAY(bm_word_t, new_size_in_words);
  61     Copy::disjoint_words((HeapWord*)old_map, (HeapWord*) _map,
  62                          MIN2(old_size_in_words, new_size_in_words));
  63   } else {
  64     _map = ArrayAllocator<bm_word_t, mtInternal>::reallocate(old_map, old_size_in_words, new_size_in_words);
  65   }
  66 
  67   if (new_size_in_words > old_size_in_words) {
  68     clear_range_of_words(old_size_in_words, new_size_in_words);
  69   }
  70 }
  71 
  72 void BitMap::set_range_within_word(idx_t beg, idx_t end) {


< prev index next >