src/share/vm/utilities/bitMap.hpp

Print this page


   1 /*
   2  * Copyright (c) 1997, 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 // Forward decl;
  26 class BitMapClosure;
  27 
  28 // Operations for bitmaps represented as arrays of unsigned integers.
  29 // Bit offsets are numbered from 0 to size-1.
  30 
  31 class BitMap VALUE_OBJ_CLASS_SPEC {
  32   friend class BitMap2D;
  33 
  34  public:
  35   typedef size_t idx_t;         // Type used for bit and word indices.
  36   typedef uintptr_t bm_word_t;  // Element type of array that represents
  37                                 // the bitmap.
  38 
  39   // Hints for range sizes.
  40   typedef enum {
  41     unknown_range, small_range, large_range
  42   } RangeSizeHint;
  43 
  44  private:


 348     verify_bit_within_slot_index(bit_within_slot_index);
 349     _map.at_put(bit_index(slot_index, bit_within_slot_index), value);
 350   }
 351 
 352   void at_put_grow(idx_t slot_index, idx_t bit_within_slot_index, bool value) {
 353     verify_bit_within_slot_index(bit_within_slot_index);
 354     _map.at_put_grow(bit_index(slot_index, bit_within_slot_index), value);
 355   }
 356 
 357   void clear();
 358 };
 359 
 360 // Closure for iterating over BitMaps
 361 
 362 class BitMapClosure VALUE_OBJ_CLASS_SPEC {
 363  public:
 364   // Callback when bit in map is set.  Should normally return "true";
 365   // return of false indicates that the bitmap iteration should terminate.
 366   virtual bool do_bit(BitMap::idx_t offset) = 0;
 367 };


   1 /*
   2  * Copyright (c) 1997, 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_HPP
  26 #define SHARE_VM_UTILITIES_BITMAP_HPP
  27 
  28 #include "memory/allocation.hpp"
  29 #include "utilities/top.hpp"
  30 
  31 // Forward decl;
  32 class BitMapClosure;
  33 
  34 // Operations for bitmaps represented as arrays of unsigned integers.
  35 // Bit offsets are numbered from 0 to size-1.
  36 
  37 class BitMap VALUE_OBJ_CLASS_SPEC {
  38   friend class BitMap2D;
  39 
  40  public:
  41   typedef size_t idx_t;         // Type used for bit and word indices.
  42   typedef uintptr_t bm_word_t;  // Element type of array that represents
  43                                 // the bitmap.
  44 
  45   // Hints for range sizes.
  46   typedef enum {
  47     unknown_range, small_range, large_range
  48   } RangeSizeHint;
  49 
  50  private:


 354     verify_bit_within_slot_index(bit_within_slot_index);
 355     _map.at_put(bit_index(slot_index, bit_within_slot_index), value);
 356   }
 357 
 358   void at_put_grow(idx_t slot_index, idx_t bit_within_slot_index, bool value) {
 359     verify_bit_within_slot_index(bit_within_slot_index);
 360     _map.at_put_grow(bit_index(slot_index, bit_within_slot_index), value);
 361   }
 362 
 363   void clear();
 364 };
 365 
 366 // Closure for iterating over BitMaps
 367 
 368 class BitMapClosure VALUE_OBJ_CLASS_SPEC {
 369  public:
 370   // Callback when bit in map is set.  Should normally return "true";
 371   // return of false indicates that the bitmap iteration should terminate.
 372   virtual bool do_bit(BitMap::idx_t offset) = 0;
 373 };
 374 
 375 #endif // SHARE_VM_UTILITIES_BITMAP_HPP