< prev index next >

src/share/vm/memory/metaspace.hpp

Print this page




  46 //               |       ||----------        |
  47 //               +------>||| block 0 |       |
  48 //                       ||----------        |
  49 //                       ||| block 1 |       |
  50 //                       ||----------        |
  51 //                       ||                  |
  52 //                       |-------------------|
  53 //                       |                   |
  54 //                       |                   |
  55 //                       +-------------------+
  56 //
  57 
  58 class ChunkManager;
  59 class ClassLoaderData;
  60 class Metablock;
  61 class Metachunk;
  62 class MetaspaceTracer;
  63 class MetaWord;
  64 class Mutex;
  65 class outputStream;

  66 class SpaceManager;
  67 class VirtualSpaceList;
  68 
  69 // Metaspaces each have a  SpaceManager and allocations
  70 // are done by the SpaceManager.  Allocations are done
  71 // out of the current Metachunk.  When the current Metachunk
  72 // is exhausted, the SpaceManager gets a new one from
  73 // the current VirtualSpace.  When the VirtualSpace is exhausted
  74 // the SpaceManager gets a new one.  The SpaceManager
  75 // also manages freelists of available Chunks.
  76 //
  77 // Currently the space manager maintains the list of
  78 // virtual spaces and the list of chunks in use.  Its
  79 // allocate() method returns a block for use as a
  80 // quantum of metadata.
  81 
  82 class Metaspace : public CHeapObj<mtClass> {
  83   friend class VMStructs;
  84   friend class SpaceManager;
  85   friend class VM_CollectForMetadataAllocation;
  86   friend class MetaspaceGC;
  87   friend class MetaspaceAux;
  88   friend class MetaspaceShared;
  89   friend class CollectorPolicy;

  90 
  91  public:
  92   enum MetadataType {
  93     ClassType,
  94     NonClassType,
  95     MetadataTypeCount
  96   };
  97   enum MetaspaceType {
  98     StandardMetaspaceType,
  99     BootMetaspaceType,
 100     AnonymousMetaspaceType,
 101     ReflectionMetaspaceType
 102   };
 103 
 104  private:
 105   static void verify_global_initialization();
 106 
 107   void initialize(Mutex* lock, MetaspaceType type);
 108 
 109   // Initialize the first chunk for a Metaspace.  Used for


 327 
 328   static size_t free_bytes();
 329   static size_t free_bytes(Metaspace::MetadataType mdtype);
 330 
 331   static size_t reserved_bytes(Metaspace::MetadataType mdtype);
 332   static size_t reserved_bytes() {
 333     return reserved_bytes(Metaspace::ClassType) +
 334            reserved_bytes(Metaspace::NonClassType);
 335   }
 336 
 337   static size_t committed_bytes(Metaspace::MetadataType mdtype);
 338   static size_t committed_bytes() {
 339     return committed_bytes(Metaspace::ClassType) +
 340            committed_bytes(Metaspace::NonClassType);
 341   }
 342 
 343   static size_t min_chunk_size_words();
 344   static size_t min_chunk_size_bytes() {
 345     return min_chunk_size_words() * BytesPerWord;
 346   }


 347 
 348   static bool has_chunk_free_list(Metaspace::MetadataType mdtype);
 349   static MetaspaceChunkFreeListSummary chunk_free_list_summary(Metaspace::MetadataType mdtype);
 350 
 351   // Print change in used metadata.
 352   static void print_metaspace_change(size_t prev_metadata_used);
 353   static void print_on(outputStream * out);
 354   static void print_on(outputStream * out, Metaspace::MetadataType mdtype);
 355 
 356   static void print_class_waste(outputStream* out);
 357   static void print_waste(outputStream* out);
 358   static void dump(outputStream* out);
 359   static void verify_free_chunks();
 360   // Checks that the values returned by allocated_capacity_bytes() and
 361   // capacity_bytes_slow() are the same.
 362   static void verify_capacity();
 363   static void verify_used();
 364   static void verify_metrics();
 365 };
 366 




  46 //               |       ||----------        |
  47 //               +------>||| block 0 |       |
  48 //                       ||----------        |
  49 //                       ||| block 1 |       |
  50 //                       ||----------        |
  51 //                       ||                  |
  52 //                       |-------------------|
  53 //                       |                   |
  54 //                       |                   |
  55 //                       +-------------------+
  56 //
  57 
  58 class ChunkManager;
  59 class ClassLoaderData;
  60 class Metablock;
  61 class Metachunk;
  62 class MetaspaceTracer;
  63 class MetaWord;
  64 class Mutex;
  65 class outputStream;
  66 class PrintCLDMetaspaceInfoClosure;
  67 class SpaceManager;
  68 class VirtualSpaceList;
  69 
  70 // Metaspaces each have a  SpaceManager and allocations
  71 // are done by the SpaceManager.  Allocations are done
  72 // out of the current Metachunk.  When the current Metachunk
  73 // is exhausted, the SpaceManager gets a new one from
  74 // the current VirtualSpace.  When the VirtualSpace is exhausted
  75 // the SpaceManager gets a new one.  The SpaceManager
  76 // also manages freelists of available Chunks.
  77 //
  78 // Currently the space manager maintains the list of
  79 // virtual spaces and the list of chunks in use.  Its
  80 // allocate() method returns a block for use as a
  81 // quantum of metadata.
  82 
  83 class Metaspace : public CHeapObj<mtClass> {
  84   friend class VMStructs;
  85   friend class SpaceManager;
  86   friend class VM_CollectForMetadataAllocation;
  87   friend class MetaspaceGC;
  88   friend class MetaspaceAux;
  89   friend class MetaspaceShared;
  90   friend class CollectorPolicy;
  91   friend class PrintCLDMetaspaceInfoClosure;
  92 
  93  public:
  94   enum MetadataType {
  95     ClassType,
  96     NonClassType,
  97     MetadataTypeCount
  98   };
  99   enum MetaspaceType {
 100     StandardMetaspaceType,
 101     BootMetaspaceType,
 102     AnonymousMetaspaceType,
 103     ReflectionMetaspaceType
 104   };
 105 
 106  private:
 107   static void verify_global_initialization();
 108 
 109   void initialize(Mutex* lock, MetaspaceType type);
 110 
 111   // Initialize the first chunk for a Metaspace.  Used for


 329 
 330   static size_t free_bytes();
 331   static size_t free_bytes(Metaspace::MetadataType mdtype);
 332 
 333   static size_t reserved_bytes(Metaspace::MetadataType mdtype);
 334   static size_t reserved_bytes() {
 335     return reserved_bytes(Metaspace::ClassType) +
 336            reserved_bytes(Metaspace::NonClassType);
 337   }
 338 
 339   static size_t committed_bytes(Metaspace::MetadataType mdtype);
 340   static size_t committed_bytes() {
 341     return committed_bytes(Metaspace::ClassType) +
 342            committed_bytes(Metaspace::NonClassType);
 343   }
 344 
 345   static size_t min_chunk_size_words();
 346   static size_t min_chunk_size_bytes() {
 347     return min_chunk_size_words() * BytesPerWord;
 348   }
 349 
 350   static void print_cld_metadata(outputStream* out);
 351 
 352   static bool has_chunk_free_list(Metaspace::MetadataType mdtype);
 353   static MetaspaceChunkFreeListSummary chunk_free_list_summary(Metaspace::MetadataType mdtype);
 354 
 355   // Print change in used metadata.
 356   static void print_metaspace_change(size_t prev_metadata_used);
 357   static void print_on(outputStream * out);
 358   static void print_on(outputStream * out, Metaspace::MetadataType mdtype);
 359 
 360   static void print_class_waste(outputStream* out);
 361   static void print_waste(outputStream* out);
 362   static void dump(outputStream* out);
 363   static void verify_free_chunks();
 364   // Checks that the values returned by allocated_capacity_bytes() and
 365   // capacity_bytes_slow() are the same.
 366   static void verify_capacity();
 367   static void verify_used();
 368   static void verify_metrics();
 369 };
 370 


< prev index next >