< prev index next >
src/hotspot/share/memory/metaspace.hpp
Print this page
rev 49170 : imported patch meta-coal-0301
rev 49171 : imported patch 8185034-metaspace-cleanup-1-rename-metaspaceaux
rev 49172 : [mq]: 8185034-metaspace-cleanup-2-split-Metaspace-class
@@ -78,20 +78,25 @@
// Currently the space manager maintains the list of
// virtual spaces and the list of chunks in use. Its
// allocate() method returns a block for use as a
// quantum of metadata.
-class Metaspace : public CHeapObj<mtClass> {
- friend class VMStructs;
+// Namespace for important central static functions
+// (auxiliary stuff goes into MetaspaceUtils)
+class Metaspace : public AllStatic {
+/* friend class VMStructs;
friend class SpaceManager;
friend class VM_CollectForMetadataAllocation;
friend class MetaspaceGC;
friend class MetaspaceUtils;
- friend class MetaspaceShared;
+
friend class CollectedHeap;
friend class PrintCLDMetaspaceInfoClosure;
friend class MetaspaceAllocationTest;
+*/
+ friend class MetaspaceShared;
+
public:
enum MetadataType {
ClassType,
NonClassType,
@@ -103,19 +108,10 @@
AnonymousMetaspaceType,
ReflectionMetaspaceType
};
private:
- static void verify_global_initialization();
-
- void initialize(Mutex* lock, MetaspaceType type);
-
- // Initialize the first chunk for a Metaspace. Used for
- // special cases such as the boot class loader, reflection
- // class loader and anonymous class loader.
- void initialize_first_chunk(MetaspaceType type, MetadataType mdtype);
- Metachunk* get_initialization_chunk(MetaspaceType type, MetadataType mdtype);
// Align up the word size to the allocation word size
static size_t align_word_size_up(size_t);
// Aligned size of the metaspace.
@@ -134,27 +130,10 @@
static size_t _commit_alignment;
static size_t _reserve_alignment;
DEBUG_ONLY(static bool _frozen;)
- SpaceManager* _vsm;
- SpaceManager* vsm() const { return _vsm; }
-
- SpaceManager* _class_vsm;
- SpaceManager* class_vsm() const { return _class_vsm; }
- SpaceManager* get_space_manager(MetadataType mdtype) {
- assert(mdtype != MetadataTypeCount, "MetadaTypeCount can't be used as mdtype");
- return mdtype == ClassType ? class_vsm() : vsm();
- }
-
- // Allocate space for metadata of type mdtype. This is space
- // within a Metachunk and is used by
- // allocate(ClassLoaderData*, size_t, bool, MetadataType, TRAPS)
- MetaWord* allocate(size_t word_size, MetadataType mdtype);
-
- MetaWord* expand_and_allocate(size_t size, MetadataType mdtype);
-
// Virtual Space lists for both classes and other metadata
static VirtualSpaceList* _space_list;
static VirtualSpaceList* _class_space_list;
static ChunkManager* _chunk_manager_metadata;
@@ -185,10 +164,13 @@
static const MetaspaceTracer* tracer() { return _tracer; }
static void freeze() {
assert(DumpSharedSpaces, "sanity");
DEBUG_ONLY(_frozen = true;)
}
+ static void assert_not_frozen() {
+ assert(!_frozen, "sanity");
+ }
#ifdef _LP64
static void allocate_metaspace_compressed_klass_ptrs(char* requested_addr, address cds_base);
#endif
private:
@@ -199,61 +181,43 @@
// Returns true if can use CDS with metaspace allocated as specified address.
static bool can_use_cds_with_metaspace_addr(char* metaspace_base, address cds_base);
static void initialize_class_space(ReservedSpace rs);
#endif
- size_t class_chunk_size(size_t word_size);
public:
- Metaspace(Mutex* lock, MetaspaceType type);
- ~Metaspace();
-
static void ergo_initialize();
static void global_initialize();
static void post_initialize();
+ static void verify_global_initialization();
+
static size_t first_chunk_word_size() { return _first_chunk_word_size; }
static size_t first_class_chunk_word_size() { return _first_class_chunk_word_size; }
static size_t reserve_alignment() { return _reserve_alignment; }
static size_t reserve_alignment_words() { return _reserve_alignment / BytesPerWord; }
static size_t commit_alignment() { return _commit_alignment; }
static size_t commit_alignment_words() { return _commit_alignment / BytesPerWord; }
- size_t used_words_slow(MetadataType mdtype) const;
- size_t free_words_slow(MetadataType mdtype) const;
- size_t capacity_words_slow(MetadataType mdtype) const;
-
- size_t used_bytes_slow(MetadataType mdtype) const;
- size_t capacity_bytes_slow(MetadataType mdtype) const;
-
- size_t allocated_blocks_bytes() const;
- size_t allocated_chunks_bytes() const;
-
static MetaWord* allocate(ClassLoaderData* loader_data, size_t word_size,
MetaspaceObj::Type type, TRAPS);
void deallocate(MetaWord* ptr, size_t byte_size, bool is_class);
static bool contains(const void* ptr);
static bool contains_non_shared(const void* ptr);
- void dump(outputStream* const out) const;
-
// Free empty virtualspaces
static void purge(MetadataType mdtype);
static void purge();
static void report_metadata_oome(ClassLoaderData* loader_data, size_t word_size,
MetaspaceObj::Type type, MetadataType mdtype, TRAPS);
static const char* metadata_type_name(Metaspace::MetadataType mdtype);
- void print_on(outputStream* st) const;
- // Debugging support
- void verify();
-
static void print_compressed_class_space(outputStream* st, const char* requested_addr = 0) NOT_LP64({});
// Return TRUE only if UseCompressedClassPointers is True.
static bool using_class_space() {
return NOT_LP64(false) LP64_ONLY(UseCompressedClassPointers);
@@ -263,10 +227,84 @@
return mdType == ClassType && using_class_space();
}
};
+// Manages the metaspace portion belonging to a class loader
+class ClassLoaderMetaspace : public CHeapObj<mtClass> {
+/* friend class VMStructs;
+ friend class SpaceManager;
+ friend class VM_CollectForMetadataAllocation;
+ friend class MetaspaceGC;
+
+ friend class MetaspaceShared;
+
+ friend class PrintCLDMetaspaceInfoClosure;
+ friend class MetaspaceAllocationTest;
+*/
+
+ friend class CollectedHeap; // For expand_and_allocate()
+ friend class Metaspace;
+ friend class MetaspaceUtils;
+ friend class PrintCLDMetaspaceInfoClosure;
+ friend class VM_CollectForMetadataAllocation; // For expand_and_allocate()
+
+ private:
+
+ void initialize(Mutex* lock, Metaspace::MetaspaceType type);
+
+ // Initialize the first chunk for a Metaspace. Used for
+ // special cases such as the boot class loader, reflection
+ // class loader and anonymous class loader.
+ void initialize_first_chunk(Metaspace::MetaspaceType type, Metaspace::MetadataType mdtype);
+ Metachunk* get_initialization_chunk(Metaspace::MetaspaceType type, Metaspace::MetadataType mdtype);
+
+ SpaceManager* _vsm;
+ SpaceManager* vsm() const { return _vsm; }
+
+ SpaceManager* _class_vsm;
+ SpaceManager* class_vsm() const { return _class_vsm; }
+ SpaceManager* get_space_manager(Metaspace::MetadataType mdtype) {
+ assert(mdtype != Metaspace::MetadataTypeCount, "MetadaTypeCount can't be used as mdtype");
+ return mdtype == Metaspace::ClassType ? class_vsm() : vsm();
+ }
+
+ MetaWord* expand_and_allocate(size_t size, Metaspace::MetadataType mdtype);
+
+ size_t class_chunk_size(size_t word_size);
+
+ public:
+
+ ClassLoaderMetaspace(Mutex* lock, Metaspace::MetaspaceType type);
+ ~ClassLoaderMetaspace();
+
+ // Allocate space for metadata of type mdtype. This is space
+ // within a Metachunk and is used by
+ // allocate(ClassLoaderData*, size_t, bool, MetadataType, TRAPS)
+ MetaWord* allocate(size_t word_size, Metaspace::MetadataType mdtype);
+
+ size_t used_words_slow(Metaspace::MetadataType mdtype) const;
+ size_t free_words_slow(Metaspace::MetadataType mdtype) const;
+ size_t capacity_words_slow(Metaspace::MetadataType mdtype) const;
+
+ size_t used_bytes_slow(Metaspace::MetadataType mdtype) const;
+ size_t capacity_bytes_slow(Metaspace::MetadataType mdtype) const;
+
+ size_t allocated_blocks_bytes() const;
+ size_t allocated_chunks_bytes() const;
+
+ void deallocate(MetaWord* ptr, size_t byte_size, bool is_class);
+
+ void dump(outputStream* const out) const;
+
+ void print_on(outputStream* st) const;
+ // Debugging support
+ void verify();
+
+}; // ClassLoaderMetaspace
+
+
class MetaspaceUtils : AllStatic {
static size_t free_chunks_total_words(Metaspace::MetadataType mdtype);
// These methods iterate over the classloader data graph
// for the given Metaspace type. These are slow.
< prev index next >