< prev index next >

src/hotspot/share/utilities/bitMap.cpp

Print this page
rev 54931 : [mq]: max_size

@@ -1,7 +1,7 @@
 /*
- * Copyright (c) 1997, 2018, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2019, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
  * under the terms of the GNU General Public License version 2 only, as
  * published by the Free Software Foundation.

@@ -71,10 +71,11 @@
   }
 };
 
 template <class Allocator>
 BitMap::bm_word_t* BitMap::reallocate(const Allocator& allocator, bm_word_t* old_map, idx_t old_size_in_bits, idx_t new_size_in_bits, bool clear) {
+  verify_max_size_limited(new_size_in_bits);
   size_t old_size_in_words = calc_size_in_words(old_size_in_bits);
   size_t new_size_in_words = calc_size_in_words(new_size_in_bits);
 
   bm_word_t* map = NULL;
 

@@ -172,18 +173,22 @@
 void CHeapBitMap::reinitialize(idx_t size_in_bits, bool clear) {
   BitMap::reinitialize(CHeapBitMapAllocator(_flags), size_in_bits, clear);
 }
 
 #ifdef ASSERT
+void BitMap::verify_max_size_limited(idx_t bit) {
+  assert(bit <= max_size_in_bits(), "out of bounds: " SIZE_FORMAT, bit);
+}
+
 void BitMap::verify_index(idx_t index) const {
   assert(index < _size, "BitMap index out of bounds");
 }
 
 void BitMap::verify_range(idx_t beg_index, idx_t end_index) const {
   assert(beg_index <= end_index, "BitMap range error");
   // Note that [0,0) and [size,size) are both valid ranges.
-  if (end_index != _size) verify_index(end_index);
+  assert(end_index <= _size, "BitMap range out of bounds");
 }
 #endif // #ifdef ASSERT
 
 void BitMap::pretouch() {
   os::pretouch_memory(word_addr(0), word_addr(size()));
< prev index next >