< prev index next >

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

Print this page
rev 50187 : imported patch metaspace-split

@@ -22,61 +22,20 @@
  *
  */
 #ifndef SHARE_VM_MEMORY_METACHUNK_HPP
 #define SHARE_VM_MEMORY_METACHUNK_HPP
 
+#include "memory/metaspace/metabase.hpp"
+#include "memory/metaspace/metaspaceCommon.hpp"
 #include "utilities/debug.hpp"
 #include "utilities/globalDefinitions.hpp"
 
-class VirtualSpaceNode;
-
-// Super class of Metablock and Metachunk to allow them to
-// be put on the FreeList and in the BinaryTreeDictionary.
-template <class T>
-class Metabase {
-  size_t _word_size;
-  T*     _next;
-  T*     _prev;
-
- protected:
-  Metabase(size_t word_size) : _word_size(word_size), _next(NULL), _prev(NULL) {}
-
- public:
-  T* next() const         { return _next; }
-  T* prev() const         { return _prev; }
-  void set_next(T* v)     { _next = v; assert(v != this, "Boom");}
-  void set_prev(T* v)     { _prev = v; assert(v != this, "Boom");}
-  void clear_next()       { set_next(NULL); }
-  void clear_prev()       { set_prev(NULL); }
-
-  size_t size() const volatile { return _word_size; }
-  void set_size(size_t v) { _word_size = v; }
-
-  void link_next(T* ptr)  { set_next(ptr); }
-  void link_prev(T* ptr)  { set_prev(ptr); }
-  void link_after(T* ptr) {
-    link_next(ptr);
-    if (ptr != NULL) ptr->link_prev((T*)this);
-  }
-
-  uintptr_t* end() const        { return ((uintptr_t*) this) + size(); }
-
-  bool cantCoalesce() const     { return false; }
-
-  // Debug support
-#ifdef ASSERT
-  void* prev_addr() const { return (void*)&_prev; }
-  void* next_addr() const { return (void*)&_next; }
-  void* size_addr() const { return (void*)&_word_size; }
-#endif
-  bool verify_chunk_in_free_list(T* tc) const { return true; }
-  bool verify_par_locked() { return true; }
+class MetachunkTest;
 
-  void assert_is_mangled() const {/* Don't check "\*/}
+namespace metaspace {
 
-  bool is_free()                 { return true; }
-};
+class VirtualSpaceNode;
 
 //  Metachunk - Quantum of allocation from a Virtualspace
 //    Metachunks are reused (when freed are put on a global freelist) and
 //    have no permanent association to a SpaceManager.
 

@@ -91,43 +50,10 @@
 //            |              |             | used    |
 //            |              |             |         |
 //            |              |             |         |
 //            +--------------+ <- bottom --+       --+
 
-// ChunkIndex defines the type of chunk.
-// Chunk types differ by size: specialized < small < medium, chunks
-// larger than medium are humongous chunks of varying size.
-enum ChunkIndex {
-  ZeroIndex = 0,
-  SpecializedIndex = ZeroIndex,
-  SmallIndex = SpecializedIndex + 1,
-  MediumIndex = SmallIndex + 1,
-  HumongousIndex = MediumIndex + 1,
-  NumberOfFreeLists = 3,
-  NumberOfInUseLists = 4
-};
-
-// Utility functions.
-size_t get_size_for_nonhumongous_chunktype(ChunkIndex chunk_type, bool is_class);
-ChunkIndex get_chunk_type_by_size(size_t size, bool is_class);
-
-ChunkIndex next_chunk_index(ChunkIndex i);
-ChunkIndex prev_chunk_index(ChunkIndex i);
-
-// Returns a descriptive name for a chunk type.
-const char* chunk_size_name(ChunkIndex index);
-
-// Verify chunk type.
-inline bool is_valid_chunktype(ChunkIndex index) {
-  return index == SpecializedIndex || index == SmallIndex ||
-         index == MediumIndex || index == HumongousIndex;
-}
-
-inline bool is_valid_nonhumongous_chunktype(ChunkIndex index) {
-  return is_valid_chunktype(index) && index != HumongousIndex;
-}
-
 enum ChunkOrigin {
   // Chunk normally born (via take_from_committed)
   origin_normal = 1,
   // Chunk was born as padding chunk
   origin_pad = 2,

@@ -150,11 +76,13 @@
     origin == origin_merge ||
     origin == origin_split;
 }
 
 class Metachunk : public Metabase<Metachunk> {
-  friend class MetachunkTest;
+
+  friend class ::MetachunkTest;
+
   // The VirtualSpaceNode containing this chunk.
   VirtualSpaceNode* const _container;
 
   // Current allocation top.
   MetaWord* _top;

@@ -230,21 +158,16 @@
   DEBUG_ONLY(void mangle(juint word_value);)
   DEBUG_ONLY(void verify() const;)
 
 };
 
-// Metablock is the unit of allocation from a Chunk.
-//
-// A Metablock may be reused by its SpaceManager but are never moved between
-// SpaceManagers.  There is no explicit link to the Metachunk
-// from which it was allocated.  Metablock may be deallocated and
-// put on a freelist but the space is never freed, rather
-// the Metachunk it is a part of will be deallocated when it's
-// associated class loader is collected.
 
-class Metablock : public Metabase<Metablock> {
-  friend class VMStructs;
- public:
-  Metablock(size_t word_size) : Metabase<Metablock>(word_size) {}
-};
+// Helper function that does a bunch of checks for a chunk.
+DEBUG_ONLY(void do_verify_chunk(Metachunk* chunk);)
+
+// Given a Metachunk, update its in-use information (both in the
+// chunk and the occupancy map).
+void do_update_in_use_info_for_chunk(Metachunk* chunk, bool inuse);
+
+} // namespace metaspace
 
 #endif  // SHARE_VM_MEMORY_METACHUNK_HPP
< prev index next >