src/share/vm/memory/metaspace.cpp

Print this page




 676       _dictionary->print_free_lists(gclog_or_tty);
 677     }
 678     delete _dictionary;
 679   }
 680 }
 681 
 682 Metablock* BlockFreelist::initialize_free_chunk(MetaWord* p, size_t word_size) {
 683   Metablock* block = (Metablock*) p;
 684   block->set_word_size(word_size);
 685   block->set_prev(NULL);
 686   block->set_next(NULL);
 687 
 688   return block;
 689 }
 690 
 691 void BlockFreelist::return_block(MetaWord* p, size_t word_size) {
 692   Metablock* free_chunk = initialize_free_chunk(p, word_size);
 693   if (dictionary() == NULL) {
 694    _dictionary = new BlockTreeDictionary();
 695   }
 696   dictionary()->return_chunk(free_chunk);
 697 }
 698 
 699 MetaWord* BlockFreelist::get_block(size_t word_size) {
 700   if (dictionary() == NULL) {
 701     return NULL;
 702   }
 703 
 704   if (word_size < TreeChunk<Metablock, FreeList>::min_size()) {
 705     // Dark matter.  Too small for dictionary.
 706     return NULL;
 707   }
 708 
 709   Metablock* free_block =
 710     dictionary()->get_chunk(word_size, FreeBlockDictionary<Metablock>::exactly);
 711   if (free_block == NULL) {
 712     return NULL;
 713   }
 714 
 715   return (MetaWord*) free_block;
 716 }


2026   }
2027   // Humongous chunks are never the current chunk.
2028   Metachunk* humongous_chunks = chunks_in_use(HumongousIndex);
2029 
2030   while (humongous_chunks != NULL) {
2031 #ifdef ASSERT
2032     humongous_chunks->set_is_free(true);
2033 #endif
2034     if (TraceMetadataChunkAllocation && Verbose) {
2035       gclog_or_tty->print(PTR_FORMAT " (" SIZE_FORMAT ") ",
2036                           humongous_chunks,
2037                           humongous_chunks->word_size());
2038     }
2039     assert(humongous_chunks->word_size() == (size_t)
2040            align_size_up(humongous_chunks->word_size(),
2041                              HumongousChunkGranularity),
2042            err_msg("Humongous chunk size is wrong: word size " SIZE_FORMAT
2043                    " granularity " SIZE_FORMAT,
2044                    humongous_chunks->word_size(), HumongousChunkGranularity));
2045     Metachunk* next_humongous_chunks = humongous_chunks->next();
2046     chunk_manager->humongous_dictionary()->return_chunk(humongous_chunks);
2047     humongous_chunks = next_humongous_chunks;
2048   }
2049   if (TraceMetadataChunkAllocation && Verbose) {
2050     gclog_or_tty->print_cr("");
2051     gclog_or_tty->print_cr("updated dictionary count %d %s",
2052                      chunk_manager->humongous_dictionary()->total_count(),
2053                      chunk_size_name(HumongousIndex));
2054   }
2055   set_chunks_in_use(HumongousIndex, NULL);
2056   chunk_manager->slow_locked_verify();
2057 }
2058 
2059 const char* SpaceManager::chunk_size_name(ChunkIndex index) const {
2060   switch (index) {
2061     case SpecializedIndex:
2062       return "Specialized";
2063     case SmallIndex:
2064       return "Small";
2065     case MediumIndex:
2066       return "Medium";




 676       _dictionary->print_free_lists(gclog_or_tty);
 677     }
 678     delete _dictionary;
 679   }
 680 }
 681 
 682 Metablock* BlockFreelist::initialize_free_chunk(MetaWord* p, size_t word_size) {
 683   Metablock* block = (Metablock*) p;
 684   block->set_word_size(word_size);
 685   block->set_prev(NULL);
 686   block->set_next(NULL);
 687 
 688   return block;
 689 }
 690 
 691 void BlockFreelist::return_block(MetaWord* p, size_t word_size) {
 692   Metablock* free_chunk = initialize_free_chunk(p, word_size);
 693   if (dictionary() == NULL) {
 694    _dictionary = new BlockTreeDictionary();
 695   }
 696   dictionary()->return_chunk(free_chunk, false);
 697 }
 698 
 699 MetaWord* BlockFreelist::get_block(size_t word_size) {
 700   if (dictionary() == NULL) {
 701     return NULL;
 702   }
 703 
 704   if (word_size < TreeChunk<Metablock, FreeList>::min_size()) {
 705     // Dark matter.  Too small for dictionary.
 706     return NULL;
 707   }
 708 
 709   Metablock* free_block =
 710     dictionary()->get_chunk(word_size, FreeBlockDictionary<Metablock>::exactly);
 711   if (free_block == NULL) {
 712     return NULL;
 713   }
 714 
 715   return (MetaWord*) free_block;
 716 }


2026   }
2027   // Humongous chunks are never the current chunk.
2028   Metachunk* humongous_chunks = chunks_in_use(HumongousIndex);
2029 
2030   while (humongous_chunks != NULL) {
2031 #ifdef ASSERT
2032     humongous_chunks->set_is_free(true);
2033 #endif
2034     if (TraceMetadataChunkAllocation && Verbose) {
2035       gclog_or_tty->print(PTR_FORMAT " (" SIZE_FORMAT ") ",
2036                           humongous_chunks,
2037                           humongous_chunks->word_size());
2038     }
2039     assert(humongous_chunks->word_size() == (size_t)
2040            align_size_up(humongous_chunks->word_size(),
2041                              HumongousChunkGranularity),
2042            err_msg("Humongous chunk size is wrong: word size " SIZE_FORMAT
2043                    " granularity " SIZE_FORMAT,
2044                    humongous_chunks->word_size(), HumongousChunkGranularity));
2045     Metachunk* next_humongous_chunks = humongous_chunks->next();
2046     chunk_manager->humongous_dictionary()->return_chunk(humongous_chunks, false);
2047     humongous_chunks = next_humongous_chunks;
2048   }
2049   if (TraceMetadataChunkAllocation && Verbose) {
2050     gclog_or_tty->print_cr("");
2051     gclog_or_tty->print_cr("updated dictionary count %d %s",
2052                      chunk_manager->humongous_dictionary()->total_count(),
2053                      chunk_size_name(HumongousIndex));
2054   }
2055   set_chunks_in_use(HumongousIndex, NULL);
2056   chunk_manager->slow_locked_verify();
2057 }
2058 
2059 const char* SpaceManager::chunk_size_name(ChunkIndex index) const {
2060   switch (index) {
2061     case SpecializedIndex:
2062       return "Specialized";
2063     case SmallIndex:
2064       return "Small";
2065     case MediumIndex:
2066       return "Medium";