8059474: Clean up vm/utilities/Bitmap type uses
authorshade
Wed, 01 Oct 2014 12:29:28 +0400
changeset 26937 dd2b0f6de283
parent 26936 504bad404be6
child 26938 e0b35f8104a7
8059474: Clean up vm/utilities/Bitmap type uses Reviewed-by: coleenp, mgerdin
hotspot/src/share/vm/utilities/bitMap.cpp
hotspot/src/share/vm/utilities/bitMap.hpp
hotspot/src/share/vm/utilities/bitMap.inline.hpp
--- a/hotspot/src/share/vm/utilities/bitMap.cpp	Tue Sep 30 13:14:22 2014 +0200
+++ b/hotspot/src/share/vm/utilities/bitMap.cpp	Wed Oct 01 12:29:28 2014 +0400
@@ -342,9 +342,9 @@
   bm_word_t* other_map = other.map();
   idx_t size = size_in_words();
   for (idx_t index = 0; index < size; index++) {
-    idx_t temp = map(index) | other_map[index];
-    changed = changed || (temp != map(index));
-    map()[index] = temp;
+    idx_t temp = dest_map[index] | other_map[index];
+    changed = changed || (temp != dest_map[index]);
+    dest_map[index] = temp;
   }
   return changed;
 }
@@ -407,10 +407,10 @@
   bm_word_t* word = map();
   idx_t rest = size();
   for (; rest >= (idx_t) BitsPerWord; rest -= BitsPerWord) {
-    if (*word != (bm_word_t) AllBits) return false;
+    if (*word != ~(bm_word_t)0) return false;
     word++;
   }
-  return rest == 0 || (*word | ~right_n_bits((int)rest)) == (bm_word_t) AllBits;
+  return rest == 0 || (*word | ~right_n_bits((int)rest)) == ~(bm_word_t)0;
 }
 
 
@@ -418,10 +418,10 @@
   bm_word_t* word = map();
   idx_t rest = size();
   for (; rest >= (idx_t) BitsPerWord; rest -= BitsPerWord) {
-    if (*word != (bm_word_t) NoBits) return false;
+    if (*word != 0) return false;
     word++;
   }
-  return rest == 0 || (*word & right_n_bits((int)rest)) == (bm_word_t) NoBits;
+  return rest == 0 || (*word & right_n_bits((int)rest)) == 0;
 }
 
 void BitMap::clear_large() {
@@ -441,7 +441,7 @@
        offset < rightOffset && index < endIndex;
        offset = (++index) << LogBitsPerWord) {
     idx_t rest = map(index) >> (offset & (BitsPerWord - 1));
-    for (; offset < rightOffset && rest != (bm_word_t)NoBits; offset++) {
+    for (; offset < rightOffset && rest != 0; offset++) {
       if (rest & 1) {
         if (!blk->do_bit(offset)) return false;
         //  resample at each closure application
@@ -468,7 +468,7 @@
                                        (intptr_t)  NULL_WORD);
     if (res != NULL_WORD) {
       guarantee( _pop_count_table == (void*) res, "invariant" );
-      FREE_C_HEAP_ARRAY(bm_word_t, table, mtInternal);
+      FREE_C_HEAP_ARRAY(idx_t, table, mtInternal);
     }
   }
 }
--- a/hotspot/src/share/vm/utilities/bitMap.hpp	Tue Sep 30 13:14:22 2014 +0200
+++ b/hotspot/src/share/vm/utilities/bitMap.hpp	Wed Oct 01 12:29:28 2014 +0400
@@ -80,7 +80,7 @@
 
   // Set a word to a specified value or to all ones; clear a word.
   void set_word  (idx_t word, bm_word_t val) { _map[word] = val; }
-  void set_word  (idx_t word)            { set_word(word, ~(uintptr_t)0); }
+  void set_word  (idx_t word)            { set_word(word, ~(bm_word_t)0); }
   void clear_word(idx_t word)            { _map[word] = 0; }
 
   // Utilities for ranges of bits.  Ranges are half-open [beg, end).
--- a/hotspot/src/share/vm/utilities/bitMap.inline.hpp	Tue Sep 30 13:14:22 2014 +0200
+++ b/hotspot/src/share/vm/utilities/bitMap.inline.hpp	Wed Oct 01 12:29:28 2014 +0400
@@ -130,7 +130,7 @@
 
 inline void BitMap::set_range_of_words(idx_t beg, idx_t end) {
   bm_word_t* map = _map;
-  for (idx_t i = beg; i < end; ++i) map[i] = ~(uintptr_t)0;
+  for (idx_t i = beg; i < end; ++i) map[i] = ~(bm_word_t)0;
 }
 
 
@@ -172,8 +172,8 @@
 
   // check bits including and to the _left_ of offset's position
   idx_t pos = bit_in_word(res_offset);
-  idx_t res = map(index) >> pos;
-  if (res != (uintptr_t)NoBits) {
+  bm_word_t res = map(index) >> pos;
+  if (res != 0) {
     // find the position of the 1-bit
     for (; !(res & 1); res_offset++) {
       res = res >> 1;
@@ -207,7 +207,7 @@
   // skip over all word length 0-bit runs
   for (index++; index < r_index; index++) {
     res = map(index);
-    if (res != (uintptr_t)NoBits) {
+    if (res != 0) {
       // found a 1, return the offset
       for (res_offset = bit_index(index); !(res & 1); res_offset++) {
         res = res >> 1;
@@ -235,9 +235,9 @@
 
   // check bits including and to the _left_ of offset's position
   idx_t pos = res_offset & (BitsPerWord - 1);
-  idx_t res = (map(index) >> pos) | left_n_bits((int)pos);
+  bm_word_t res = (map(index) >> pos) | left_n_bits((int)pos);
 
-  if (res != (uintptr_t)AllBits) {
+  if (res != ~(bm_word_t)0) {
     // find the position of the 0-bit
     for (; res & 1; res_offset++) {
       res = res >> 1;
@@ -248,7 +248,7 @@
   // skip over all word length 1-bit runs
   for (index++; index < r_index; index++) {
     res = map(index);
-    if (res != (uintptr_t)AllBits) {
+    if (res != ~(bm_word_t)0) {
       // found a 0, return the offset
       for (res_offset = index << LogBitsPerWord; res & 1;
            res_offset++) {
@@ -277,8 +277,8 @@
   idx_t res_offset = l_offset;
 
   // check bits including and to the _left_ of offset's position
-  idx_t res = map(index) >> bit_in_word(res_offset);
-  if (res != (uintptr_t)NoBits) {
+  bm_word_t res = map(index) >> bit_in_word(res_offset);
+  if (res != 0) {
     // find the position of the 1-bit
     for (; !(res & 1); res_offset++) {
       res = res >> 1;
@@ -290,7 +290,7 @@
   // skip over all word length 0-bit runs
   for (index++; index < r_index; index++) {
     res = map(index);
-    if (res != (uintptr_t)NoBits) {
+    if (res != 0) {
       // found a 1, return the offset
       for (res_offset = bit_index(index); !(res & 1); res_offset++) {
         res = res >> 1;
@@ -321,11 +321,11 @@
 }
 
 inline void BitMap::set_large_range_of_words(idx_t beg, idx_t end) {
-  memset(_map + beg, ~(unsigned char)0, (end - beg) * sizeof(uintptr_t));
+  memset(_map + beg, ~(unsigned char)0, (end - beg) * sizeof(bm_word_t));
 }
 
 inline void BitMap::clear_large_range_of_words(idx_t beg, idx_t end) {
-  memset(_map + beg, 0, (end - beg) * sizeof(uintptr_t));
+  memset(_map + beg, 0, (end - beg) * sizeof(bm_word_t));
 }
 
 inline BitMap::idx_t BitMap::word_index_round_up(idx_t bit) const {