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_MEMORY_METASPACE_BLOCKFREELIST_HPP_
26 #define SHARE_MEMORY_METASPACE_BLOCKFREELIST_HPP_
27
28 #include "memory/allocation.hpp"
29 #include "memory/binaryTreeDictionary.hpp"
30 #include "memory/freeList.hpp"
31 #include "memory/metaspace/smallBlocks.hpp"
32 #include "memory/metaspace/metablock.hpp"
33 #include "utilities/globalDefinitions.hpp"
34
35 namespace metaspace {
36 namespace internals {
37
38 typedef BinaryTreeDictionary<Metablock, FreeList<Metablock> > BlockTreeDictionary;
39
40 // Used to manage the free list of Metablocks (a block corresponds
41 // to the allocation of a quantum of metadata).
42 class BlockFreelist : public CHeapObj<mtClass> {
43
44 BlockTreeDictionary* const _dictionary;
45 SmallBlocks* _small_blocks;
46
47 // Only allocate and split from freelist if the size of the allocation
48 // is at least 1/4th the size of the available block.
49 const static int WasteMultiplier = 4;
50
51 // Accessors
52 BlockTreeDictionary* dictionary() const { return _dictionary; }
53 SmallBlocks* small_blocks() {
54 if (_small_blocks == NULL) {
55 _small_blocks = new SmallBlocks();
56 }
72 if (_small_blocks != NULL) {
73 result = result + _small_blocks->total_size();
74 }
75 return result;
76 }
77
78 // Returns the number of all blocks kept in this structure.
79 uintx num_blocks() const {
80 uintx result = dictionary()->total_free_blocks();
81 if (_small_blocks != NULL) {
82 result = result + _small_blocks->total_num_blocks();
83 }
84 return result;
85 }
86
87 static size_t min_dictionary_size() { return TreeChunk<Metablock, FreeList<Metablock> >::min_size(); }
88 void print_on(outputStream* st) const;
89 };
90
91 } // namespace metaspace
92 } // namespace internals
93
94 #endif /* SHARE_MEMORY_METASPACE_BLOCKFREELIST_HPP_ */
|
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_MEMORY_METASPACE_BLOCKFREELIST_HPP_
26 #define SHARE_MEMORY_METASPACE_BLOCKFREELIST_HPP_
27
28 #include "memory/allocation.hpp"
29 #include "memory/binaryTreeDictionary.hpp"
30 #include "memory/freeList.hpp"
31 #include "memory/metaspace/smallBlocks.hpp"
32 #include "memory/metaspace/metablock.hpp"
33 #include "utilities/globalDefinitions.hpp"
34
35 namespace metaspace {
36
37 typedef BinaryTreeDictionary<Metablock, FreeList<Metablock> > BlockTreeDictionary;
38
39 // Used to manage the free list of Metablocks (a block corresponds
40 // to the allocation of a quantum of metadata).
41 class BlockFreelist : public CHeapObj<mtClass> {
42
43 BlockTreeDictionary* const _dictionary;
44 SmallBlocks* _small_blocks;
45
46 // Only allocate and split from freelist if the size of the allocation
47 // is at least 1/4th the size of the available block.
48 const static int WasteMultiplier = 4;
49
50 // Accessors
51 BlockTreeDictionary* dictionary() const { return _dictionary; }
52 SmallBlocks* small_blocks() {
53 if (_small_blocks == NULL) {
54 _small_blocks = new SmallBlocks();
55 }
71 if (_small_blocks != NULL) {
72 result = result + _small_blocks->total_size();
73 }
74 return result;
75 }
76
77 // Returns the number of all blocks kept in this structure.
78 uintx num_blocks() const {
79 uintx result = dictionary()->total_free_blocks();
80 if (_small_blocks != NULL) {
81 result = result + _small_blocks->total_num_blocks();
82 }
83 return result;
84 }
85
86 static size_t min_dictionary_size() { return TreeChunk<Metablock, FreeList<Metablock> >::min_size(); }
87 void print_on(outputStream* st) const;
88 };
89
90 } // namespace metaspace
91
92 #endif /* SHARE_MEMORY_METASPACE_BLOCKFREELIST_HPP_ */
93
|