comparison src/share/vm/memory/metaspace.hpp @ 10330:2b1a9d972fc2

8014862: Add fast Metasapce capacity and used per MetadataType Reviewed-by: ehelin, stefank
author jmasa
date Mon, 20 May 2013 22:34:24 -0700
parents 868d87ed63c8
children a1ebd310d5c1
comparison
equal deleted inserted replaced
10329:10f759898d40 10330:2b1a9d972fc2
84 friend class VM_CollectForMetadataAllocation; 84 friend class VM_CollectForMetadataAllocation;
85 friend class MetaspaceGC; 85 friend class MetaspaceGC;
86 friend class MetaspaceAux; 86 friend class MetaspaceAux;
87 87
88 public: 88 public:
89 enum MetadataType {ClassType, NonClassType}; 89 enum MetadataType {ClassType = 0,
90 NonClassType = ClassType + 1,
91 MetadataTypeCount = ClassType + 2
92 };
90 enum MetaspaceType { 93 enum MetaspaceType {
91 StandardMetaspaceType, 94 StandardMetaspaceType,
92 BootMetaspaceType, 95 BootMetaspaceType,
93 ROMetaspaceType, 96 ROMetaspaceType,
94 ReadWriteMetaspaceType, 97 ReadWriteMetaspaceType,
182 static size_t free_chunks_total_in_bytes(Metaspace::MetadataType mdtype); 185 static size_t free_chunks_total_in_bytes(Metaspace::MetadataType mdtype);
183 186
184 public: 187 public:
185 // Running sum of space in all Metachunks that has been 188 // Running sum of space in all Metachunks that has been
186 // allocated to a Metaspace. This is used instead of 189 // allocated to a Metaspace. This is used instead of
187 // iterating over all the classloaders 190 // iterating over all the classloaders. One for each
188 static size_t _allocated_capacity_words; 191 // type of Metadata
192 static size_t _allocated_capacity_words[Metaspace:: MetadataTypeCount];
189 // Running sum of space in all Metachunks that have 193 // Running sum of space in all Metachunks that have
190 // are being used for metadata. 194 // are being used for metadata. One for each
191 static size_t _allocated_used_words; 195 // type of Metadata.
196 static size_t _allocated_used_words[Metaspace:: MetadataTypeCount];
192 197
193 public: 198 public:
194 // Decrement and increment _allocated_capacity_words 199 // Decrement and increment _allocated_capacity_words
195 static void dec_capacity(size_t words); 200 static void dec_capacity(Metaspace::MetadataType type, size_t words);
196 static void inc_capacity(size_t words); 201 static void inc_capacity(Metaspace::MetadataType type, size_t words);
197 202
198 // Decrement and increment _allocated_used_words 203 // Decrement and increment _allocated_used_words
199 static void dec_used(size_t words); 204 static void dec_used(Metaspace::MetadataType type, size_t words);
200 static void inc_used(size_t words); 205 static void inc_used(Metaspace::MetadataType type, size_t words);
201 206
202 // Total of space allocated to metadata in all Metaspaces. 207 // Total of space allocated to metadata in all Metaspaces.
203 // This sums the space used in each Metachunk by 208 // This sums the space used in each Metachunk by
204 // iterating over the classloader data graph 209 // iterating over the classloader data graph
205 static size_t used_bytes_slow() { 210 static size_t used_bytes_slow() {
209 214
210 // Used by MetaspaceCounters 215 // Used by MetaspaceCounters
211 static size_t free_chunks_total(); 216 static size_t free_chunks_total();
212 static size_t free_chunks_total_in_bytes(); 217 static size_t free_chunks_total_in_bytes();
213 218
219 static size_t allocated_capacity_words(Metaspace::MetadataType mdtype) {
220 return _allocated_capacity_words[mdtype];
221 }
214 static size_t allocated_capacity_words() { 222 static size_t allocated_capacity_words() {
215 return _allocated_capacity_words; 223 return _allocated_capacity_words[Metaspace::ClassType] +
224 _allocated_capacity_words[Metaspace::NonClassType];
225 }
226 static size_t allocated_capacity_bytes(Metaspace::MetadataType mdtype) {
227 return allocated_capacity_words(mdtype) * BytesPerWord;
216 } 228 }
217 static size_t allocated_capacity_bytes() { 229 static size_t allocated_capacity_bytes() {
218 return _allocated_capacity_words * BytesPerWord; 230 return allocated_capacity_words() * BytesPerWord;
219 } 231 }
220 232
233 static size_t allocated_used_words(Metaspace::MetadataType mdtype) {
234 return _allocated_used_words[mdtype];
235 }
221 static size_t allocated_used_words() { 236 static size_t allocated_used_words() {
222 return _allocated_used_words; 237 return _allocated_used_words[Metaspace::ClassType] +
238 _allocated_used_words[Metaspace::NonClassType];
239 }
240 static size_t allocated_used_bytes(Metaspace::MetadataType mdtype) {
241 return allocated_used_words(mdtype) * BytesPerWord;
223 } 242 }
224 static size_t allocated_used_bytes() { 243 static size_t allocated_used_bytes() {
225 return _allocated_used_words * BytesPerWord; 244 return allocated_used_words() * BytesPerWord;
226 } 245 }
227 246
228 static size_t free_bytes(); 247 static size_t free_bytes();
229 248
230 // Total capacity in all Metaspaces 249 // Total capacity in all Metaspaces