--- old/src/hotspot/share/utilities/bitMap.hpp 2019-06-10 20:16:26.223680331 -0400 +++ new/src/hotspot/share/utilities/bitMap.hpp 2019-06-10 20:16:25.635648899 -0400 @@ -48,8 +48,10 @@ public: typedef size_t idx_t; // Type used for bit and word indices. - typedef uintptr_t bm_word_t; // Element type of array that represents - // the bitmap. BitsPerWord bits per element. + typedef uintptr_t bm_word_t; // Element type of array that represents the + // bitmap, with BitsPerWord bits per element. + // If this were to fail, there are lots of places that would need repair. + STATIC_ASSERT((sizeof(bm_word_t) * BitsPerByte) == BitsPerWord); // Hints for range sizes. typedef enum { @@ -60,10 +62,14 @@ bm_word_t* _map; // First word in bitmap idx_t _size; // Size of bitmap (in bits) - // Limit max_size_in_bits so roundup in calc_size_in_words can't overflow. + // Limit max_size_in_bits so aligning up to a word never overflows. static idx_t max_size_in_words() { return word_index(~idx_t(0)); } static idx_t max_size_in_bits() { return max_size_in_words() * BitsPerWord; } + // bit must be the begin/end of a validated range. + static inline idx_t range_begin_align_up(idx_t bit); + static inline idx_t range_end_align_down(idx_t bit); + // Helper for get_next_{zero,one}_bit variants. // - flip designates whether searching for 1s or 0s. Must be one of // find_{zeros,ones}_flip. @@ -79,6 +85,9 @@ // operation was requested. Measured in words. static const size_t small_range_words = 32; + // beg/end_aligned must be from range_begin/end aligners. + static bool is_small_aligned_range(idx_t beg_aligned, idx_t end_aligned); + protected: // Return the position of bit within the word that contains it (e.g., if // bitmap words are 32 bits, return a number 0 <= n <= 31). @@ -124,14 +133,13 @@ static void clear_range_of_words(bm_word_t* map, idx_t beg, idx_t end); - static bool is_small_range_of_words(idx_t beg_full_word, idx_t end_full_word); - - // The index of the first full word in a range. - idx_t word_index_round_up(idx_t bit) const; - // Verification. - static void verify_max_size_limited(idx_t bit) NOT_DEBUG_RETURN; + + // Verify size_in_bits does not exceed maximum size. + static void verify_valid_size(idx_t size_in_bits) NOT_DEBUG_RETURN; + // Verify index is less than size. void verify_index(idx_t index) const NOT_DEBUG_RETURN; + // Verify [beg,end) is a valid range. void verify_range(idx_t beg_index, idx_t end_index) const NOT_DEBUG_RETURN; // Statistics. @@ -191,7 +199,7 @@ void pretouch(); static idx_t calc_size_in_words(idx_t size_in_bits) { - verify_max_size_limited(size_in_bits); + verify_valid_size(size_in_bits); return word_index(size_in_bits + (BitsPerWord - 1)); }