< prev index next >

src/share/vm/memory/metaspace.cpp

Print this page

        

@@ -250,34 +250,28 @@
 };
 
 // Used to manage the free list of Metablocks (a block corresponds
 // to the allocation of a quantum of metadata).
 class BlockFreelist VALUE_OBJ_CLASS_SPEC {
-  BlockTreeDictionary* _dictionary;
+  BlockTreeDictionary _dictionary;
 
   // Only allocate and split from freelist if the size of the allocation
   // is at least 1/4th the size of the available block.
   const static int WasteMultiplier = 4;
 
   // Accessors
-  BlockTreeDictionary* dictionary() const { return _dictionary; }
+  BlockTreeDictionary* dictionary() { return &_dictionary; }
 
  public:
   BlockFreelist();
   ~BlockFreelist();
 
   // Get and return a block to the free list
   MetaWord* get_block(size_t word_size);
   void return_block(MetaWord* p, size_t word_size);
 
-  size_t total_size() {
-  if (dictionary() == NULL) {
-    return 0;
-  } else {
-    return dictionary()->total_size();
-  }
-}
+  size_t total_size() { return dictionary()->total_size(); }
 
   void print_on(outputStream* st) const;
 };
 
 // A VirtualSpaceList node.

@@ -812,34 +806,24 @@
 }
 #endif
 
 // BlockFreelist methods
 
-BlockFreelist::BlockFreelist() : _dictionary(NULL) {}
+BlockFreelist::BlockFreelist() : _dictionary() {}
 
 BlockFreelist::~BlockFreelist() {
-  if (_dictionary != NULL) {
     if (Verbose && TraceMetadataChunkAllocation) {
-      _dictionary->print_free_lists(gclog_or_tty);
-    }
-    delete _dictionary;
+    dictionary()->print_free_lists(gclog_or_tty);
   }
 }
 
 void BlockFreelist::return_block(MetaWord* p, size_t word_size) {
   Metablock* free_chunk = ::new (p) Metablock(word_size);
-  if (dictionary() == NULL) {
-   _dictionary = new BlockTreeDictionary();
-  }
   dictionary()->return_chunk(free_chunk);
 }
 
 MetaWord* BlockFreelist::get_block(size_t word_size) {
-  if (dictionary() == NULL) {
-    return NULL;
-  }
-
   if (word_size < TreeChunk<Metablock, FreeList<Metablock> >::min_size()) {
     // Dark matter.  Too small for dictionary.
     return NULL;
   }
 

@@ -864,14 +848,11 @@
 
   return new_block;
 }
 
 void BlockFreelist::print_on(outputStream* st) const {
-  if (dictionary() == NULL) {
-    return;
-  }
-  dictionary()->print_free_lists(st);
+  const_cast<BlockFreelist *>(this)->dictionary()->print_free_lists(st);
 }
 
 // VirtualSpaceNode methods
 
 VirtualSpaceNode::~VirtualSpaceNode() {
< prev index next >