Mercurial > hg > truffle
comparison src/share/vm/memory/metaspace.hpp @ 12235:d6c266999345
8023476: Metaspace capacity > reserved
Reviewed-by: stefank, hseigel, mgerdin
author | ehelin |
---|---|
date | Thu, 12 Sep 2013 10:15:30 +0200 |
parents | 7944aba7ba41 |
children | c4c768305a8f |
comparison
equal
deleted
inserted
replaced
12234:b82260e84582 | 12235:d6c266999345 |
---|---|
180 static size_t first_chunk_word_size() { return _first_chunk_word_size; } | 180 static size_t first_chunk_word_size() { return _first_chunk_word_size; } |
181 static size_t first_class_chunk_word_size() { return _first_class_chunk_word_size; } | 181 static size_t first_class_chunk_word_size() { return _first_class_chunk_word_size; } |
182 | 182 |
183 char* bottom() const; | 183 char* bottom() const; |
184 size_t used_words_slow(MetadataType mdtype) const; | 184 size_t used_words_slow(MetadataType mdtype) const; |
185 size_t free_words(MetadataType mdtype) const; | 185 size_t free_words_slow(MetadataType mdtype) const; |
186 size_t capacity_words_slow(MetadataType mdtype) const; | 186 size_t capacity_words_slow(MetadataType mdtype) const; |
187 size_t waste_words(MetadataType mdtype) const; | |
188 | 187 |
189 size_t used_bytes_slow(MetadataType mdtype) const; | 188 size_t used_bytes_slow(MetadataType mdtype) const; |
190 size_t capacity_bytes_slow(MetadataType mdtype) const; | 189 size_t capacity_bytes_slow(MetadataType mdtype) const; |
191 | 190 |
192 static Metablock* allocate(ClassLoaderData* loader_data, size_t word_size, | 191 static Metablock* allocate(ClassLoaderData* loader_data, size_t word_size, |
219 } | 218 } |
220 | 219 |
221 }; | 220 }; |
222 | 221 |
223 class MetaspaceAux : AllStatic { | 222 class MetaspaceAux : AllStatic { |
224 static size_t free_chunks_total(Metaspace::MetadataType mdtype); | 223 static size_t free_chunks_total_words(Metaspace::MetadataType mdtype); |
225 | |
226 public: | |
227 // Statistics for class space and data space in metaspace. | |
228 | 224 |
229 // These methods iterate over the classloader data graph | 225 // These methods iterate over the classloader data graph |
230 // for the given Metaspace type. These are slow. | 226 // for the given Metaspace type. These are slow. |
231 static size_t used_bytes_slow(Metaspace::MetadataType mdtype); | 227 static size_t used_bytes_slow(Metaspace::MetadataType mdtype); |
232 static size_t free_in_bytes(Metaspace::MetadataType mdtype); | 228 static size_t free_bytes_slow(Metaspace::MetadataType mdtype); |
233 static size_t capacity_bytes_slow(Metaspace::MetadataType mdtype); | 229 static size_t capacity_bytes_slow(Metaspace::MetadataType mdtype); |
234 | 230 static size_t capacity_bytes_slow(); |
235 // Iterates over the virtual space list. | |
236 static size_t reserved_in_bytes(Metaspace::MetadataType mdtype); | |
237 | 231 |
238 // Running sum of space in all Metachunks that has been | 232 // Running sum of space in all Metachunks that has been |
239 // allocated to a Metaspace. This is used instead of | 233 // allocated to a Metaspace. This is used instead of |
240 // iterating over all the classloaders. One for each | 234 // iterating over all the classloaders. One for each |
241 // type of Metadata | 235 // type of Metadata |
261 return used_bytes_slow(Metaspace::ClassType) + | 255 return used_bytes_slow(Metaspace::ClassType) + |
262 used_bytes_slow(Metaspace::NonClassType); | 256 used_bytes_slow(Metaspace::NonClassType); |
263 } | 257 } |
264 | 258 |
265 // Used by MetaspaceCounters | 259 // Used by MetaspaceCounters |
266 static size_t free_chunks_total(); | 260 static size_t free_chunks_total_words(); |
267 static size_t free_chunks_total_in_bytes(); | 261 static size_t free_chunks_total_bytes(); |
268 static size_t free_chunks_total_in_bytes(Metaspace::MetadataType mdtype); | 262 static size_t free_chunks_total_bytes(Metaspace::MetadataType mdtype); |
269 | 263 |
270 static size_t allocated_capacity_words(Metaspace::MetadataType mdtype) { | 264 static size_t allocated_capacity_words(Metaspace::MetadataType mdtype) { |
271 return _allocated_capacity_words[mdtype]; | 265 return _allocated_capacity_words[mdtype]; |
272 } | 266 } |
273 static size_t allocated_capacity_words() { | 267 static size_t allocated_capacity_words() { |
274 return _allocated_capacity_words[Metaspace::NonClassType] + | 268 return allocated_capacity_words(Metaspace::NonClassType) + |
275 (Metaspace::using_class_space() ? | 269 allocated_capacity_words(Metaspace::ClassType); |
276 _allocated_capacity_words[Metaspace::ClassType] : 0); | |
277 } | 270 } |
278 static size_t allocated_capacity_bytes(Metaspace::MetadataType mdtype) { | 271 static size_t allocated_capacity_bytes(Metaspace::MetadataType mdtype) { |
279 return allocated_capacity_words(mdtype) * BytesPerWord; | 272 return allocated_capacity_words(mdtype) * BytesPerWord; |
280 } | 273 } |
281 static size_t allocated_capacity_bytes() { | 274 static size_t allocated_capacity_bytes() { |
284 | 277 |
285 static size_t allocated_used_words(Metaspace::MetadataType mdtype) { | 278 static size_t allocated_used_words(Metaspace::MetadataType mdtype) { |
286 return _allocated_used_words[mdtype]; | 279 return _allocated_used_words[mdtype]; |
287 } | 280 } |
288 static size_t allocated_used_words() { | 281 static size_t allocated_used_words() { |
289 return _allocated_used_words[Metaspace::NonClassType] + | 282 return allocated_used_words(Metaspace::NonClassType) + |
290 (Metaspace::using_class_space() ? | 283 allocated_used_words(Metaspace::ClassType); |
291 _allocated_used_words[Metaspace::ClassType] : 0); | |
292 } | 284 } |
293 static size_t allocated_used_bytes(Metaspace::MetadataType mdtype) { | 285 static size_t allocated_used_bytes(Metaspace::MetadataType mdtype) { |
294 return allocated_used_words(mdtype) * BytesPerWord; | 286 return allocated_used_words(mdtype) * BytesPerWord; |
295 } | 287 } |
296 static size_t allocated_used_bytes() { | 288 static size_t allocated_used_bytes() { |
299 | 291 |
300 static size_t free_bytes(); | 292 static size_t free_bytes(); |
301 static size_t free_bytes(Metaspace::MetadataType mdtype); | 293 static size_t free_bytes(Metaspace::MetadataType mdtype); |
302 | 294 |
303 // Total capacity in all Metaspaces | 295 // Total capacity in all Metaspaces |
304 static size_t capacity_bytes_slow() { | 296 static size_t reserved_bytes(Metaspace::MetadataType mdtype); |
305 #ifdef PRODUCT | 297 static size_t reserved_bytes() { |
306 // Use allocated_capacity_bytes() in PRODUCT instead of this function. | 298 return reserved_bytes(Metaspace::ClassType) + |
307 guarantee(false, "Should not call capacity_bytes_slow() in the PRODUCT"); | 299 reserved_bytes(Metaspace::NonClassType); |
308 #endif | 300 } |
309 size_t class_capacity = capacity_bytes_slow(Metaspace::ClassType); | 301 |
310 size_t non_class_capacity = capacity_bytes_slow(Metaspace::NonClassType); | 302 static size_t min_chunk_size_words(); |
311 assert(allocated_capacity_bytes() == class_capacity + non_class_capacity, | 303 static size_t min_chunk_size_bytes() { |
312 err_msg("bad accounting: allocated_capacity_bytes() " SIZE_FORMAT | 304 return min_chunk_size_words() * BytesPerWord; |
313 " class_capacity + non_class_capacity " SIZE_FORMAT | 305 } |
314 " class_capacity " SIZE_FORMAT " non_class_capacity " SIZE_FORMAT, | |
315 allocated_capacity_bytes(), class_capacity + non_class_capacity, | |
316 class_capacity, non_class_capacity)); | |
317 | |
318 return class_capacity + non_class_capacity; | |
319 } | |
320 | |
321 // Total space reserved in all Metaspaces | |
322 static size_t reserved_in_bytes() { | |
323 return reserved_in_bytes(Metaspace::ClassType) + | |
324 reserved_in_bytes(Metaspace::NonClassType); | |
325 } | |
326 | |
327 static size_t min_chunk_size(); | |
328 | 306 |
329 // Print change in used metadata. | 307 // Print change in used metadata. |
330 static void print_metaspace_change(size_t prev_metadata_used); | 308 static void print_metaspace_change(size_t prev_metadata_used); |
331 static void print_on(outputStream * out); | 309 static void print_on(outputStream * out); |
332 static void print_on(outputStream * out, Metaspace::MetadataType mdtype); | 310 static void print_on(outputStream * out, Metaspace::MetadataType mdtype); |