< prev index next >

src/hotspot/share/memory/metachunk.cpp

Print this page
rev 47755 : 8189864: Provide an ascii map to visualize metaspace fragmentation
Reviewed-by: goetz, coleenp


  38 
  39   // Make sure that the Klass alignment also agree.
  40   STATIC_ASSERT(alignment == (size_t)KlassAlignmentInBytes);
  41 
  42   return alignment;
  43 }
  44 
  45 size_t Metachunk::overhead() {
  46   return align_up(sizeof(Metachunk), object_alignment()) / BytesPerWord;
  47 }
  48 
  49 // Metachunk methods
  50 
  51 Metachunk::Metachunk(size_t word_size,
  52                      VirtualSpaceNode* container)
  53     : Metabase<Metachunk>(word_size),
  54     _top(NULL),
  55     _container(container)
  56 {
  57   _top = initial_top();
  58 #ifdef ASSERT
  59   set_is_tagged_free(false);

  60   mangle(uninitMetaWordVal);
  61 #endif
  62 }
  63 
  64 MetaWord* Metachunk::allocate(size_t word_size) {
  65   MetaWord* result = NULL;
  66   // If available, bump the pointer to allocate.
  67   if (free_word_size() >= word_size) {
  68     result = _top;
  69     _top = _top + word_size;
  70   }
  71   return result;
  72 }
  73 
  74 // _bottom points to the start of the chunk including the overhead.
  75 size_t Metachunk::used_word_size() const {
  76   return pointer_delta(_top, bottom(), sizeof(MetaWord));
  77 }
  78 
  79 size_t Metachunk::free_word_size() const {




  38 
  39   // Make sure that the Klass alignment also agree.
  40   STATIC_ASSERT(alignment == (size_t)KlassAlignmentInBytes);
  41 
  42   return alignment;
  43 }
  44 
  45 size_t Metachunk::overhead() {
  46   return align_up(sizeof(Metachunk), object_alignment()) / BytesPerWord;
  47 }
  48 
  49 // Metachunk methods
  50 
  51 Metachunk::Metachunk(size_t word_size,
  52                      VirtualSpaceNode* container)
  53     : Metabase<Metachunk>(word_size),
  54     _top(NULL),
  55     _container(container)
  56 {
  57   _top = initial_top();

  58   set_is_tagged_free(false);
  59 #ifdef ASSERT
  60   mangle(uninitMetaWordVal);
  61 #endif
  62 }
  63 
  64 MetaWord* Metachunk::allocate(size_t word_size) {
  65   MetaWord* result = NULL;
  66   // If available, bump the pointer to allocate.
  67   if (free_word_size() >= word_size) {
  68     result = _top;
  69     _top = _top + word_size;
  70   }
  71   return result;
  72 }
  73 
  74 // _bottom points to the start of the chunk including the overhead.
  75 size_t Metachunk::used_word_size() const {
  76   return pointer_delta(_top, bottom(), sizeof(MetaWord));
  77 }
  78 
  79 size_t Metachunk::free_word_size() const {


< prev index next >