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 CollectedHeap;
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
157 static VirtualSpaceList* _class_space_list;
158
159 static ChunkManager* _chunk_manager_metadata;
160 static ChunkManager* _chunk_manager_class;
161
162 static const MetaspaceTracer* _tracer;
163
164 public:
165 static VirtualSpaceList* space_list() { return _space_list; }
166 static VirtualSpaceList* class_space_list() { return _class_space_list; }
167 static VirtualSpaceList* get_space_list(MetadataType mdtype) {
168 assert(mdtype != MetadataTypeCount, "MetadaTypeCount can't be used as mdtype");
169 return mdtype == ClassType ? class_space_list() : space_list();
170 }
171
172 static ChunkManager* chunk_manager_metadata() { return _chunk_manager_metadata; }
173 static ChunkManager* chunk_manager_class() { return _chunk_manager_class; }
174 static ChunkManager* get_chunk_manager(MetadataType mdtype) {
175 assert(mdtype != MetadataTypeCount, "MetadaTypeCount can't be used as mdtype");
176 return mdtype == ClassType ? chunk_manager_class() : chunk_manager_metadata();
177 }
178
179 static const MetaspaceTracer* tracer() { return _tracer; }
180 static void freeze() {
181 assert(DumpSharedSpaces, "sanity");
182 DEBUG_ONLY(_frozen = true;)
183 }
184 #ifdef _LP64
185 static void allocate_metaspace_compressed_klass_ptrs(char* requested_addr, address cds_base);
186 #endif
187
188 private:
189
190 #ifdef _LP64
191 static void set_narrow_klass_base_and_shift(address metaspace_base, address cds_base);
192
193 // Returns true if can use CDS with metaspace allocated as specified address.
194 static bool can_use_cds_with_metaspace_addr(char* metaspace_base, address cds_base);
195
196 static void initialize_class_space(ReservedSpace rs);
|
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 CollectedHeap;
91 friend class PrintCLDMetaspaceInfoClosure;
92 friend class MetaspaceAllocationTest;
93
94 public:
95 enum MetadataType {
96 ClassType,
97 NonClassType,
98 MetadataTypeCount
99 };
100 enum MetaspaceType {
101 StandardMetaspaceType,
102 BootMetaspaceType,
103 AnonymousMetaspaceType,
104 ReflectionMetaspaceType
105 };
106
107 private:
108 static void verify_global_initialization();
109
110 void initialize(Mutex* lock, MetaspaceType type);
111
112 // Initialize the first chunk for a Metaspace. Used for
158 static VirtualSpaceList* _class_space_list;
159
160 static ChunkManager* _chunk_manager_metadata;
161 static ChunkManager* _chunk_manager_class;
162
163 static const MetaspaceTracer* _tracer;
164
165 public:
166 static VirtualSpaceList* space_list() { return _space_list; }
167 static VirtualSpaceList* class_space_list() { return _class_space_list; }
168 static VirtualSpaceList* get_space_list(MetadataType mdtype) {
169 assert(mdtype != MetadataTypeCount, "MetadaTypeCount can't be used as mdtype");
170 return mdtype == ClassType ? class_space_list() : space_list();
171 }
172
173 static ChunkManager* chunk_manager_metadata() { return _chunk_manager_metadata; }
174 static ChunkManager* chunk_manager_class() { return _chunk_manager_class; }
175 static ChunkManager* get_chunk_manager(MetadataType mdtype) {
176 assert(mdtype != MetadataTypeCount, "MetadaTypeCount can't be used as mdtype");
177 return mdtype == ClassType ? chunk_manager_class() : chunk_manager_metadata();
178 }
179
180 // convenience function
181 static ChunkManager* get_chunk_manager(bool is_class) {
182 return is_class ? chunk_manager_class() : chunk_manager_metadata();
183 }
184
185 static const MetaspaceTracer* tracer() { return _tracer; }
186 static void freeze() {
187 assert(DumpSharedSpaces, "sanity");
188 DEBUG_ONLY(_frozen = true;)
189 }
190 #ifdef _LP64
191 static void allocate_metaspace_compressed_klass_ptrs(char* requested_addr, address cds_base);
192 #endif
193
194 private:
195
196 #ifdef _LP64
197 static void set_narrow_klass_base_and_shift(address metaspace_base, address cds_base);
198
199 // Returns true if can use CDS with metaspace allocated as specified address.
200 static bool can_use_cds_with_metaspace_addr(char* metaspace_base, address cds_base);
201
202 static void initialize_class_space(ReservedSpace rs);
|