src/hotspot/share/memory/metaspace/rootChunkArea.cpp
branchstuefe-new-metaspace-branch
changeset 58683 2d5dd194c65c
parent 58227 0e7d9a23261e
equal deleted inserted replaced
58651:a2d3074db7a9 58683:2d5dd194c65c
    28 #include "memory/allocation.hpp"
    28 #include "memory/allocation.hpp"
    29 #include "memory/metaspace/chunkHeaderPool.hpp"
    29 #include "memory/metaspace/chunkHeaderPool.hpp"
    30 #include "memory/metaspace/chunkManager.hpp"
    30 #include "memory/metaspace/chunkManager.hpp"
    31 #include "memory/metaspace/internStat.hpp"
    31 #include "memory/metaspace/internStat.hpp"
    32 #include "memory/metaspace/metachunk.hpp"
    32 #include "memory/metaspace/metachunk.hpp"
       
    33 #include "memory/metaspace/metaDebug.hpp"
    33 #include "memory/metaspace/metaspaceCommon.hpp"
    34 #include "memory/metaspace/metaspaceCommon.hpp"
    34 #include "memory/metaspace/rootChunkArea.hpp"
    35 #include "memory/metaspace/rootChunkArea.hpp"
    35 #include "runtime/mutexLocker.hpp"
    36 #include "runtime/mutexLocker.hpp"
    36 #include "utilities/debug.hpp"
    37 #include "utilities/debug.hpp"
    37 #include "utilities/globalDefinitions.hpp"
    38 #include "utilities/globalDefinitions.hpp"
    79 //  free chunks to the freelists.
    80 //  free chunks to the freelists.
    80 //
    81 //
    81 // Returns NULL if chunk cannot be split at least once.
    82 // Returns NULL if chunk cannot be split at least once.
    82 Metachunk* RootChunkArea::split(chklvl_t target_level, Metachunk* c, MetachunkListCluster* freelists) {
    83 Metachunk* RootChunkArea::split(chklvl_t target_level, Metachunk* c, MetachunkListCluster* freelists) {
    83 
    84 
    84   DEBUG_ONLY(c->verify(true);)
       
    85 
       
    86   // Splitting a chunk once works like this:
    85   // Splitting a chunk once works like this:
    87   //
    86   //
    88   // For a given chunk we want to split:
    87   // For a given chunk we want to split:
    89   // - increase the chunk level (which halves its size)
    88   // - increase the chunk level (which halves its size)
    90   // - (but leave base address as it is since it will be the leader of the newly
    89   // - (but leave base address as it is since it will be the leader of the newly
   116   DEBUG_ONLY(check_pointer(c->base());)
   115   DEBUG_ONLY(check_pointer(c->base());)
   117   assert(c->is_free(), "Can only split free chunks.");
   116   assert(c->is_free(), "Can only split free chunks.");
   118 
   117 
   119   DEBUG_ONLY(chklvl::check_valid_level(target_level));
   118   DEBUG_ONLY(chklvl::check_valid_level(target_level));
   120   assert(target_level > c->level(), "Wrong target level");
   119   assert(target_level > c->level(), "Wrong target level");
   121 
       
   122   DEBUG_ONLY(verify(true);)
       
   123 
   120 
   124   const chklvl_t starting_level = c->level();
   121   const chklvl_t starting_level = c->level();
   125 
   122 
   126   Metachunk* result = c;
   123   Metachunk* result = c;
   127 
   124 
   421     vmassert(cond, __VA_ARGS__); \
   418     vmassert(cond, __VA_ARGS__); \
   422   }
   419   }
   423 
   420 
   424 void RootChunkArea::verify(bool slow) const {
   421 void RootChunkArea::verify(bool slow) const {
   425 
   422 
       
   423 
   426   assert_lock_strong(MetaspaceExpand_lock);
   424   assert_lock_strong(MetaspaceExpand_lock);
   427 
       
   428   assert_is_aligned(_base, chklvl::MAX_CHUNK_BYTE_SIZE);
   425   assert_is_aligned(_base, chklvl::MAX_CHUNK_BYTE_SIZE);
   429 
   426 
   430   // Iterate thru all chunks in this area. They must be ordered correctly,
   427   // Iterate thru all chunks in this area. They must be ordered correctly,
   431   // being adjacent to each other, and cover the complete area
   428   // being adjacent to each other, and cover the complete area
   432   int num_chunk = 0;
   429   int num_chunk = 0;
   466 
   463 
   467 }
   464 }
   468 
   465 
   469 void RootChunkArea::verify_area_is_ideally_merged() const {
   466 void RootChunkArea::verify_area_is_ideally_merged() const {
   470 
   467 
   471   assert_lock_strong(MetaspaceExpand_lock);
   468   SOMETIMES(assert_lock_strong(MetaspaceExpand_lock);)
   472 
   469 
   473   int num_chunk = 0;
   470   int num_chunk = 0;
   474   for (const Metachunk* c = _first_chunk; c != NULL; c = c->next_in_vs()) {
   471   for (const Metachunk* c = _first_chunk; c != NULL; c = c->next_in_vs()) {
   475     if (!c->is_root_chunk() && c->is_free()) {
   472     if (!c->is_root_chunk() && c->is_free()) {
   476       // If a chunk is free, it must not have a buddy which is also free, because
   473       // If a chunk is free, it must not have a buddy which is also free, because