< prev index next >

src/share/vm/utilities/bitMap.cpp

Print this page
rev 7793 : 8073315: Enable gcc -Wtype-limits and fix upcoming issues.


  16  * 2 along with this work; if not, write to the Free Software Foundation,
  17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  18  *
  19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  20  * or visit www.oracle.com if you need additional information or have any
  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 BitMap::BitMap(bm_word_t* map, idx_t size_in_bits) :
  33   _map(map), _size(size_in_bits), _map_allocator(false)
  34 {
  35   assert(sizeof(bm_word_t) == BytesPerWord, "Implementation assumption.");
  36   assert(size_in_bits >= 0, "just checking");
  37 }
  38 
  39 
  40 BitMap::BitMap(idx_t size_in_bits, bool in_resource_area) :
  41   _map(NULL), _size(0), _map_allocator(false)
  42 {
  43   assert(sizeof(bm_word_t) == BytesPerWord, "Implementation assumption.");
  44   resize(size_in_bits, in_resource_area);
  45 }
  46 
  47 void BitMap::resize(idx_t size_in_bits, bool in_resource_area) {
  48   assert(size_in_bits >= 0, "just checking");
  49   idx_t old_size_in_words = size_in_words();
  50   bm_word_t* old_map = map();
  51 
  52   _size = size_in_bits;
  53   idx_t new_size_in_words = size_in_words();
  54   if (in_resource_area) {
  55     _map = NEW_RESOURCE_ARRAY(bm_word_t, new_size_in_words);
  56     Copy::disjoint_words((HeapWord*)old_map, (HeapWord*) _map,
  57                          MIN2(old_size_in_words, new_size_in_words));
  58   } else {
  59     _map = _map_allocator.reallocate(new_size_in_words);
  60   }
  61 
  62   if (new_size_in_words > old_size_in_words) {
  63     clear_range_of_words(old_size_in_words, new_size_in_words);
  64   }
  65 }
  66 
  67 void BitMap::set_range_within_word(idx_t beg, idx_t end) {
  68   // With a valid range (beg <= end), this test ensures that end != 0, as




  16  * 2 along with this work; if not, write to the Free Software Foundation,
  17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  18  *
  19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  20  * or visit www.oracle.com if you need additional information or have any
  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 BitMap::BitMap(bm_word_t* map, idx_t size_in_bits) :
  33   _map(map), _size(size_in_bits), _map_allocator(false)
  34 {
  35   assert(sizeof(bm_word_t) == BytesPerWord, "Implementation assumption.");

  36 }
  37 
  38 
  39 BitMap::BitMap(idx_t size_in_bits, bool in_resource_area) :
  40   _map(NULL), _size(0), _map_allocator(false)
  41 {
  42   assert(sizeof(bm_word_t) == BytesPerWord, "Implementation assumption.");
  43   resize(size_in_bits, in_resource_area);
  44 }
  45 
  46 void BitMap::resize(idx_t size_in_bits, bool in_resource_area) {

  47   idx_t old_size_in_words = size_in_words();
  48   bm_word_t* old_map = map();
  49 
  50   _size = size_in_bits;
  51   idx_t new_size_in_words = size_in_words();
  52   if (in_resource_area) {
  53     _map = NEW_RESOURCE_ARRAY(bm_word_t, new_size_in_words);
  54     Copy::disjoint_words((HeapWord*)old_map, (HeapWord*) _map,
  55                          MIN2(old_size_in_words, new_size_in_words));
  56   } else {
  57     _map = _map_allocator.reallocate(new_size_in_words);
  58   }
  59 
  60   if (new_size_in_words > old_size_in_words) {
  61     clear_range_of_words(old_size_in_words, new_size_in_words);
  62   }
  63 }
  64 
  65 void BitMap::set_range_within_word(idx_t beg, idx_t end) {
  66   // With a valid range (beg <= end), this test ensures that end != 0, as


< prev index next >