< prev index next >

src/hotspot/share/memory/metaspace/freeBlocks.hpp

Print this page

 56 //  leftover space from retired chunks, see MetaspaceArena::retire_current_chunk().
 57 //
 58 // Since the vast majority of blocks are small or very small, FreeBlocks consists
 59 //  internally of two separate structures to keep very small blocks and other blocks.
 60 //  Very small blocks are kept in a bin list (see binlist.hpp) and larger blocks in
 61 //  a BST (see blocktree.hpp).
 62 
 63 class FreeBlocks : public CHeapObj<mtMetaspace> {
 64 
 65   // _small_blocks takes care of small to very small blocks.
 66   BinList32 _small_blocks;
 67 
 68   // A BST for larger blocks, only for blocks which are too large
 69   // to fit into _smallblocks.
 70   BlockTree _tree;
 71 
 72   // This verifies that blocks too large to go into the binlist can be
 73   // kept in the blocktree.
 74   STATIC_ASSERT(BinList32::MaxWordSize >= BlockTree::MinWordSize);
 75 
 76   // Cutoff point: blocks larger than this size are kept in the
 77   // tree, blocks smaller than or equal to this size in the bin list.
 78   const size_t MaxSmallBlocksWordSize = BinList32::MaxWordSize;
 79 
 80 public:
 81 
 82   // Smallest blocks we can keep in this structure.
 83   const static size_t MinWordSize = BinList32::MinWordSize;
 84 
 85   // Add a block to the deallocation management.
 86   void add_block(MetaWord* p, size_t word_size);
 87 
 88   // Retrieve a block of at least requested_word_size.
 89   MetaWord* remove_block(size_t requested_word_size);
 90 
 91 #ifdef ASSERT
 92   void verify() const {
 93     _tree.verify();
 94     _small_blocks.verify();
 95   };
 96 #endif
 97 
 98   // Returns number of blocks.
 99   int count() const {
100     return _small_blocks.count() + _tree.count();
101   }
102 
103   // Returns total size, in words, of all elements.
104   size_t total_size() const {
105     return _small_blocks.total_size() + _tree.total_size();
106   }
107 
108   // Returns true if empty.
109   bool is_empty() const {

 56 //  leftover space from retired chunks, see MetaspaceArena::retire_current_chunk().
 57 //
 58 // Since the vast majority of blocks are small or very small, FreeBlocks consists
 59 //  internally of two separate structures to keep very small blocks and other blocks.
 60 //  Very small blocks are kept in a bin list (see binlist.hpp) and larger blocks in
 61 //  a BST (see blocktree.hpp).
 62 
 63 class FreeBlocks : public CHeapObj<mtMetaspace> {
 64 
 65   // _small_blocks takes care of small to very small blocks.
 66   BinList32 _small_blocks;
 67 
 68   // A BST for larger blocks, only for blocks which are too large
 69   // to fit into _smallblocks.
 70   BlockTree _tree;
 71 
 72   // This verifies that blocks too large to go into the binlist can be
 73   // kept in the blocktree.
 74   STATIC_ASSERT(BinList32::MaxWordSize >= BlockTree::MinWordSize);
 75 




 76 public:
 77 
 78   // Smallest blocks we can keep in this structure.
 79   const static size_t MinWordSize = BinList32::MinWordSize;
 80 
 81   // Add a block to the deallocation management.
 82   void add_block(MetaBlock bl);
 83 
 84   // Retrieve a block of at least requested_word_size. May be larger.
 85   MetaBlock remove_block(size_t requested_word_size);
 86 
 87 #ifdef ASSERT
 88   void verify() const {
 89     _tree.verify();
 90     _small_blocks.verify();
 91   };
 92 #endif
 93 
 94   // Returns number of blocks.
 95   int count() const {
 96     return _small_blocks.count() + _tree.count();
 97   }
 98 
 99   // Returns total size, in words, of all elements.
100   size_t total_size() const {
101     return _small_blocks.total_size() + _tree.total_size();
102   }
103 
104   // Returns true if empty.
105   bool is_empty() const {
< prev index next >