comparison src/share/vm/memory/metaspace.cpp @ 7187:5fafdef522c6

Merge
author johnc
date Fri, 30 Nov 2012 12:01:34 -0800
parents 59c790074993 90273fc0a981
children eade6b2e4782
comparison
equal deleted inserted replaced
7184:5505fbbae3d3 7187:5fafdef522c6
107 Chunk::aligned_overhead_size(sizeof(Metablock)) / BytesPerWord; 107 Chunk::aligned_overhead_size(sizeof(Metablock)) / BytesPerWord;
108 #else 108 #else
109 size_t Metablock::_overhead = 0; 109 size_t Metablock::_overhead = 0;
110 #endif 110 #endif
111 111
112
113 // Pointer to list of Metachunks. 112 // Pointer to list of Metachunks.
114 class ChunkList VALUE_OBJ_CLASS_SPEC { 113 class ChunkList VALUE_OBJ_CLASS_SPEC {
115 // List of free chunks 114 // List of free chunks
116 Metachunk* _head; 115 Metachunk* _head;
117 116
324 // Expands/shrinks the committed space in a virtual space. Delegates 323 // Expands/shrinks the committed space in a virtual space. Delegates
325 // to Virtualspace 324 // to Virtualspace
326 bool expand_by(size_t words, bool pre_touch = false); 325 bool expand_by(size_t words, bool pre_touch = false);
327 bool shrink_by(size_t words); 326 bool shrink_by(size_t words);
328 327
328 #ifdef ASSERT
329 // Debug support 329 // Debug support
330 static void verify_virtual_space_total(); 330 static void verify_virtual_space_total();
331 static void verify_virtual_space_count(); 331 static void verify_virtual_space_count();
332 void mangle(); 332 void mangle();
333 #endif
333 334
334 void print_on(outputStream* st) const; 335 void print_on(outputStream* st) const;
335 }; 336 };
336 337
337 // byte_size is the size of the associated virtualspace. 338 // byte_size is the size of the associated virtualspace.
620 void dump(outputStream* const out) const; 621 void dump(outputStream* const out) const;
621 void print_on(outputStream* st) const; 622 void print_on(outputStream* st) const;
622 void locked_print_chunks_in_use_on(outputStream* st) const; 623 void locked_print_chunks_in_use_on(outputStream* st) const;
623 624
624 void verify(); 625 void verify();
626 NOT_PRODUCT(void mangle_freed_chunks();)
625 #ifdef ASSERT 627 #ifdef ASSERT
626 void mangle_freed_chunks();
627 void verify_allocation_total(); 628 void verify_allocation_total();
628 #endif 629 #endif
629 }; 630 };
630 631
631 uint const SpaceManager::_small_chunk_limit = 4; 632 uint const SpaceManager::_small_chunk_limit = 4;
710 " bottom " PTR_FORMAT " top " PTR_FORMAT 711 " bottom " PTR_FORMAT " top " PTR_FORMAT
711 " end " PTR_FORMAT " size " SIZE_FORMAT, 712 " end " PTR_FORMAT " size " SIZE_FORMAT,
712 bottom(), top(), end(), word_size()); 713 bottom(), top(), end(), word_size());
713 } 714 }
714 715
715 #ifdef ASSERT 716 #ifndef PRODUCT
716 void Metachunk::mangle() { 717 void Metachunk::mangle() {
717 // Mangle the payload of the chunk and not the links that 718 // Mangle the payload of the chunk and not the links that
718 // maintain list of chunks. 719 // maintain list of chunks.
719 HeapWord* start = (HeapWord*)(bottom() + overhead()); 720 HeapWord* start = (HeapWord*)(bottom() + overhead());
720 size_t word_size = capacity_word_size() - overhead(); 721 size_t word_size = capacity_word_size() - overhead();
721 Copy::fill_to_words(start, word_size, metadata_chunk_initialize); 722 Copy::fill_to_words(start, word_size, metadata_chunk_initialize);
722 } 723 }
723 #endif // ASSERT 724 #endif // PRODUCT
724 725
725 void Metachunk::verify() { 726 void Metachunk::verify() {
726 #ifdef ASSERT 727 #ifdef ASSERT
727 // Cannot walk through the blocks unless the blocks have 728 // Cannot walk through the blocks unless the blocks have
728 // headers with sizes. 729 // headers with sizes.
916 vs, capacity / K, used * 100 / capacity, 917 vs, capacity / K, used * 100 / capacity,
917 bottom(), top(), end(), 918 bottom(), top(), end(),
918 vs->high_boundary()); 919 vs->high_boundary());
919 } 920 }
920 921
922 #ifdef ASSERT
921 void VirtualSpaceNode::mangle() { 923 void VirtualSpaceNode::mangle() {
922 size_t word_size = capacity_words_in_vs(); 924 size_t word_size = capacity_words_in_vs();
923 Copy::fill_to_words((HeapWord*) low(), word_size, 0xf1f1f1f1); 925 Copy::fill_to_words((HeapWord*) low(), word_size, 0xf1f1f1f1);
924 } 926 }
927 #endif // ASSERT
925 928
926 // VirtualSpaceList methods 929 // VirtualSpaceList methods
927 // Space allocated from the VirtualSpace 930 // Space allocated from the VirtualSpace
928 931
929 VirtualSpaceList::~VirtualSpaceList() { 932 VirtualSpaceList::~VirtualSpaceList() {
1984 if (TraceMetadataChunkAllocation && Verbose) { 1987 if (TraceMetadataChunkAllocation && Verbose) {
1985 gclog_or_tty->print_cr("~SpaceManager(): " PTR_FORMAT, this); 1988 gclog_or_tty->print_cr("~SpaceManager(): " PTR_FORMAT, this);
1986 locked_print_chunks_in_use_on(gclog_or_tty); 1989 locked_print_chunks_in_use_on(gclog_or_tty);
1987 } 1990 }
1988 1991
1992 // Mangle freed memory.
1993 NOT_PRODUCT(mangle_freed_chunks();)
1994
1989 // Have to update before the chunks_in_use lists are emptied 1995 // Have to update before the chunks_in_use lists are emptied
1990 // below. 1996 // below.
1991 chunk_manager->inc_free_chunks_total(sum_capacity_in_chunks_in_use(), 1997 chunk_manager->inc_free_chunks_total(sum_capacity_in_chunks_in_use(),
1992 sum_count_in_chunks_in_use()); 1998 sum_count_in_chunks_in_use());
1993
1994 #ifdef ASSERT
1995 // Mangle freed memory.
1996 mangle_freed_chunks();
1997 #endif // ASSERT
1998 1999
1999 // Add all the chunks in use by this space manager 2000 // Add all the chunks in use by this space manager
2000 // to the global list of free chunks. 2001 // to the global list of free chunks.
2001 2002
2002 // Small chunks. There is one _current_chunk for each 2003 // Small chunks. There is one _current_chunk for each
2272 out->print_cr("total of all chunks " SIZE_FORMAT " used " SIZE_FORMAT 2273 out->print_cr("total of all chunks " SIZE_FORMAT " used " SIZE_FORMAT
2273 " free " SIZE_FORMAT " capacity " SIZE_FORMAT 2274 " free " SIZE_FORMAT " capacity " SIZE_FORMAT
2274 " waste " SIZE_FORMAT, curr_total, used, free, capacity, waste); 2275 " waste " SIZE_FORMAT, curr_total, used, free, capacity, waste);
2275 } 2276 }
2276 2277
2277 #ifdef ASSERT 2278 #ifndef PRODUCT
2278 void SpaceManager::mangle_freed_chunks() { 2279 void SpaceManager::mangle_freed_chunks() {
2279 for (ChunkIndex index = SmallIndex; 2280 for (ChunkIndex index = SmallIndex;
2280 index < NumberOfInUseLists; 2281 index < NumberOfInUseLists;
2281 index = next_chunk_index(index)) { 2282 index = next_chunk_index(index)) {
2282 for (Metachunk* curr = chunks_in_use(index); 2283 for (Metachunk* curr = chunks_in_use(index);
2290 curr, chunks_in_use(MediumIndex))); 2291 curr, chunks_in_use(MediumIndex)));
2291 curr->mangle(); 2292 curr->mangle();
2292 } 2293 }
2293 } 2294 }
2294 } 2295 }
2295 #endif // ASSERT 2296 #endif // PRODUCT
2296 2297
2297 2298
2298 // MetaspaceAux 2299 // MetaspaceAux
2300
2301 size_t MetaspaceAux::used_in_bytes() {
2302 return (Metaspace::class_space_list()->used_words_sum() +
2303 Metaspace::space_list()->used_words_sum()) * BytesPerWord;
2304 }
2299 2305
2300 size_t MetaspaceAux::used_in_bytes(Metaspace::MetadataType mdtype) { 2306 size_t MetaspaceAux::used_in_bytes(Metaspace::MetadataType mdtype) {
2301 size_t used = 0; 2307 size_t used = 0;
2302 ClassLoaderDataGraphMetaspaceIterator iter; 2308 ClassLoaderDataGraphMetaspaceIterator iter;
2303 while (iter.repeat()) { 2309 while (iter.repeat()) {
2323 } 2329 }
2324 2330
2325 // The total words available for metadata allocation. This 2331 // The total words available for metadata allocation. This
2326 // uses Metaspace capacity_words() which is the total words 2332 // uses Metaspace capacity_words() which is the total words
2327 // in chunks allocated for a Metaspace. 2333 // in chunks allocated for a Metaspace.
2334 size_t MetaspaceAux::capacity_in_bytes() {
2335 return (Metaspace::class_space_list()->capacity_words_sum() +
2336 Metaspace::space_list()->capacity_words_sum()) * BytesPerWord;
2337 }
2338
2328 size_t MetaspaceAux::capacity_in_bytes(Metaspace::MetadataType mdtype) { 2339 size_t MetaspaceAux::capacity_in_bytes(Metaspace::MetadataType mdtype) {
2329 size_t capacity = free_chunks_total(mdtype); 2340 size_t capacity = free_chunks_total(mdtype);
2330 ClassLoaderDataGraphMetaspaceIterator iter; 2341 ClassLoaderDataGraphMetaspaceIterator iter;
2331 while (iter.repeat()) { 2342 while (iter.repeat()) {
2332 Metaspace* msp = iter.get_next(); 2343 Metaspace* msp = iter.get_next();
2333 if (msp != NULL) { 2344 if (msp != NULL) {
2334 capacity += msp->capacity_words(mdtype); 2345 capacity += msp->capacity_words(mdtype);
2335 } 2346 }
2336 } 2347 }
2337 return capacity * BytesPerWord; 2348 return capacity * BytesPerWord;
2349 }
2350
2351 size_t MetaspaceAux::reserved_in_bytes() {
2352 return (Metaspace::class_space_list()->virtual_space_total() +
2353 Metaspace::space_list()->virtual_space_total()) * BytesPerWord;
2338 } 2354 }
2339 2355
2340 size_t MetaspaceAux::reserved_in_bytes(Metaspace::MetadataType mdtype) { 2356 size_t MetaspaceAux::reserved_in_bytes(Metaspace::MetadataType mdtype) {
2341 size_t reserved = (mdtype == Metaspace::ClassType) ? 2357 size_t reserved = (mdtype == Metaspace::ClassType) ?
2342 Metaspace::class_space_list()->virtual_space_total() : 2358 Metaspace::class_space_list()->virtual_space_total() :