src/share/vm/utilities/bitMap.inline.hpp

Print this page


   1 /*
   2  * Copyright (c) 2005, 2009, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.
   8  *
   9  * This code is distributed in the hope that it will be useful, but WITHOUT
  10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  12  * version 2 for more details (a copy is included in the LICENSE file that
  13  * accompanied this code).
  14  *
  15  * You should have received a copy of the GNU General Public License version
  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 #ifdef ASSERT
  26 inline void BitMap::verify_index(idx_t index) const {
  27   assert(index < _size, "BitMap index out of bounds");
  28 }
  29 
  30 inline void BitMap::verify_range(idx_t beg_index, idx_t end_index) const {
  31   assert(beg_index <= end_index, "BitMap range error");
  32   // Note that [0,0) and [size,size) are both valid ranges.
  33   if (end_index != _size) verify_index(end_index);
  34 }
  35 #endif // #ifdef ASSERT
  36 
  37 inline void BitMap::set_bit(idx_t bit) {
  38   verify_index(bit);
  39   *word_addr(bit) |= bit_mask(bit);
  40 }
  41 
  42 inline void BitMap::clear_bit(idx_t bit) {
  43   verify_index(bit);
  44   *word_addr(bit) &= ~bit_mask(bit);


 302 
 303 inline BitMap::idx_t BitMap::word_index_round_up(idx_t bit) const {
 304   idx_t bit_rounded_up = bit + (BitsPerWord - 1);
 305   // Check for integer arithmetic overflow.
 306   return bit_rounded_up > bit ? word_index(bit_rounded_up) : size_in_words();
 307 }
 308 
 309 inline BitMap::idx_t BitMap::get_next_one_offset(idx_t l_offset,
 310                                           idx_t r_offset) const {
 311   return get_next_one_offset_inline(l_offset, r_offset);
 312 }
 313 
 314 inline BitMap::idx_t BitMap::get_next_zero_offset(idx_t l_offset,
 315                                            idx_t r_offset) const {
 316   return get_next_zero_offset_inline(l_offset, r_offset);
 317 }
 318 
 319 inline void BitMap2D::clear() {
 320   _map.clear();
 321 }


   1 /*
   2  * Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.
   8  *
   9  * This code is distributed in the hope that it will be useful, but WITHOUT
  10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  12  * version 2 for more details (a copy is included in the LICENSE file that
  13  * accompanied this code).
  14  *
  15  * You should have received a copy of the GNU General Public License version
  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 #ifndef SHARE_VM_UTILITIES_BITMAP_INLINE_HPP
  26 #define SHARE_VM_UTILITIES_BITMAP_INLINE_HPP
  27 
  28 #include "runtime/atomic.hpp"
  29 #include "utilities/bitMap.hpp"
  30 
  31 #ifdef ASSERT
  32 inline void BitMap::verify_index(idx_t index) const {
  33   assert(index < _size, "BitMap index out of bounds");
  34 }
  35 
  36 inline void BitMap::verify_range(idx_t beg_index, idx_t end_index) const {
  37   assert(beg_index <= end_index, "BitMap range error");
  38   // Note that [0,0) and [size,size) are both valid ranges.
  39   if (end_index != _size) verify_index(end_index);
  40 }
  41 #endif // #ifdef ASSERT
  42 
  43 inline void BitMap::set_bit(idx_t bit) {
  44   verify_index(bit);
  45   *word_addr(bit) |= bit_mask(bit);
  46 }
  47 
  48 inline void BitMap::clear_bit(idx_t bit) {
  49   verify_index(bit);
  50   *word_addr(bit) &= ~bit_mask(bit);


 308 
 309 inline BitMap::idx_t BitMap::word_index_round_up(idx_t bit) const {
 310   idx_t bit_rounded_up = bit + (BitsPerWord - 1);
 311   // Check for integer arithmetic overflow.
 312   return bit_rounded_up > bit ? word_index(bit_rounded_up) : size_in_words();
 313 }
 314 
 315 inline BitMap::idx_t BitMap::get_next_one_offset(idx_t l_offset,
 316                                           idx_t r_offset) const {
 317   return get_next_one_offset_inline(l_offset, r_offset);
 318 }
 319 
 320 inline BitMap::idx_t BitMap::get_next_zero_offset(idx_t l_offset,
 321                                            idx_t r_offset) const {
 322   return get_next_zero_offset_inline(l_offset, r_offset);
 323 }
 324 
 325 inline void BitMap2D::clear() {
 326   _map.clear();
 327 }
 328 
 329 #endif // SHARE_VM_UTILITIES_BITMAP_INLINE_HPP