src/hotspot/share/memory/metaspace/blockListArray.hpp
branchstuefe-new-metaspace-branch
changeset 59257 990b1fed3b47
parent 59238 6ce12ce00d3e
child 59271 1558266946de
equal deleted inserted replaced
59238:6ce12ce00d3e 59257:990b1fed3b47
    45   int num_blocks;
    45   int num_blocks;
    46 };
    46 };
    47 
    47 
    48 // A bitmap keeping track of which list is occupied. Smallest list corresponds to lowest order bit.
    48 // A bitmap keeping track of which list is occupied. Smallest list corresponds to lowest order bit.
    49 // 1 means list is not empty, 0 means list is empty.
    49 // 1 means list is not empty, 0 means list is empty.
    50 class BlockListFreeMap {
    50 class BlockListArrayMask {
    51 
    51 
    52   typedef uint32_t mask_type;
    52   typedef uint32_t mask_type;
    53   mask_type _mask;
    53   mask_type _mask;
    54 
    54 
    55   static mask_type mask_for_pos(int pos) { return 1 << pos; }
    55   static mask_type mask_for_pos(int pos) { return 1 << pos; }
    56 
    56 
    57 public:
    57 public:
    58 
    58 
    59   BlockListFreeMap() : _mask(0) {}
    59   BlockListArrayMask() : _mask(0) {}
    60 
    60 
    61   bool all_zero() const          { return _mask == 0; }
    61   bool all_zero() const          { return _mask == 0; }
    62 
    62 
    63   bool get_bit(int pos) const    { return (_mask & mask_for_pos(pos)) != 0 ? true : false; }
    63   bool get_bit(int pos) const    { return (_mask & mask_for_pos(pos)) != 0 ? true : false; }
    64   void set_bit(int pos)          { _mask |= mask_for_pos(pos); }
    64   void set_bit(int pos)          { _mask |= mask_for_pos(pos); }
    81 
    81 
    82   STATIC_ASSERT(sizeof(block_t) <= (min_word_size * BytesPerWord));
    82   STATIC_ASSERT(sizeof(block_t) <= (min_word_size * BytesPerWord));
    83 
    83 
    84   block_t* _bins[num_bins];
    84   block_t* _bins[num_bins];
    85 
    85 
    86   BlockListFreeMap _map;
    86   BlockListArrayMask _map;
    87 
    87 
    88   // e.g. spread = 4
    88   // e.g. spread = 4
    89   //
    89   //
    90   // sz    bno (put)  bno (get)
    90   // sz    bno (put)  bno (get)
    91   //         (guarant)
    91   //         (guarant)
   124   }
   124   }
   125 
   125 
   126 public:
   126 public:
   127 
   127 
   128   BlockListArray() : _map() {
   128   BlockListArray() : _map() {
   129     assert(BlockListFreeMap::size() >= num_bins, "Map too small.");
   129     assert(BlockListArrayMask::size() >= num_bins, "Map too small.");
   130     ::memset(_bins, 0, sizeof(_bins));
   130     ::memset(_bins, 0, sizeof(_bins));
   131   }
   131   }
   132 
   132 
   133   // [min, max) word size
   133   // [min, max) word size
   134   static size_t minimal_word_size() { return min_word_size; }
   134   static size_t minimal_word_size() { return min_word_size; }