< prev index next >

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

Print this page

35   if (word_size > MaxSmallBlocksWordSize) {
36     _tree.add_block(p, word_size);
37   } else {
38     _small_blocks.add_block(p, word_size);
39   }
40 }
41 
42 MetaWord* FreeBlocks::remove_block(size_t requested_word_size) {
43   assert(requested_word_size >= MinWordSize,
44       "requested_word_size too small (" SIZE_FORMAT ")", requested_word_size);
45   size_t real_size = 0;
46   MetaWord* p = NULL;
47   if (requested_word_size > MaxSmallBlocksWordSize) {
48     p = _tree.remove_block(requested_word_size, &real_size);
49   } else {
50     p = _small_blocks.remove_block(requested_word_size, &real_size);
51   }
52   if (p != NULL) {
53     // Blocks which are larger than a certain threshold are split and
54     //  the remainder is handed back to the manager.





55     const size_t waste = real_size - requested_word_size;
56     if (waste > MinWordSize) {
57       add_block(p + requested_word_size, waste);
58     }
59   }
60   return p;
61 }
62 
63 } // namespace metaspace
64 

35   if (word_size > MaxSmallBlocksWordSize) {
36     _tree.add_block(p, word_size);
37   } else {
38     _small_blocks.add_block(p, word_size);
39   }
40 }
41 
42 MetaWord* FreeBlocks::remove_block(size_t requested_word_size) {
43   assert(requested_word_size >= MinWordSize,
44       "requested_word_size too small (" SIZE_FORMAT ")", requested_word_size);
45   size_t real_size = 0;
46   MetaWord* p = NULL;
47   if (requested_word_size > MaxSmallBlocksWordSize) {
48     p = _tree.remove_block(requested_word_size, &real_size);
49   } else {
50     p = _small_blocks.remove_block(requested_word_size, &real_size);
51   }
52   if (p != NULL) {
53     // Blocks which are larger than a certain threshold are split and
54     //  the remainder is handed back to the manager.
55     // Attention alignment: the resulting block must have the right alignment
56     //  for the enclosing arena. ATM this works, since the arena aligns allocated block
57     //  size. If we ever switch to a different model (e.g. aligning the start
58     //  address of allocated blocks instead of the request size) this should be
59     //  rewritten).
60     const size_t waste = real_size - requested_word_size;
61     if (waste > MinWordSize) {
62       add_block(p + requested_word_size, waste);
63     }
64   }
65   return p;
66 }
67 
68 } // namespace metaspace
69 
< prev index next >