hotspot/src/share/vm/memory/metaspace.cpp
changeset 29800 fa5f7a2bf717
parent 29697 92501504191b
child 29806 64aa40385bdd
equal deleted inserted replaced
29799:3ad47a56094a 29800:fa5f7a2bf717
    47 #include "services/memoryService.hpp"
    47 #include "services/memoryService.hpp"
    48 #include "utilities/copy.hpp"
    48 #include "utilities/copy.hpp"
    49 #include "utilities/debug.hpp"
    49 #include "utilities/debug.hpp"
    50 #include "utilities/macros.hpp"
    50 #include "utilities/macros.hpp"
    51 
    51 
    52 PRAGMA_FORMAT_MUTE_WARNINGS_FOR_GCC
       
    53 
       
    54 typedef BinaryTreeDictionary<Metablock, FreeList<Metablock> > BlockTreeDictionary;
    52 typedef BinaryTreeDictionary<Metablock, FreeList<Metablock> > BlockTreeDictionary;
    55 typedef BinaryTreeDictionary<Metachunk, FreeList<Metachunk> > ChunkTreeDictionary;
    53 typedef BinaryTreeDictionary<Metachunk, FreeList<Metachunk> > ChunkTreeDictionary;
    56 
    54 
    57 // Set this constant to enable slow integrity checking of the free chunk lists
    55 // Set this constant to enable slow integrity checking of the free chunk lists
    58 const bool metaspace_slow_verify = false;
    56 const bool metaspace_slow_verify = false;
   386 };
   384 };
   387 
   385 
   388 #define assert_is_ptr_aligned(ptr, alignment) \
   386 #define assert_is_ptr_aligned(ptr, alignment) \
   389   assert(is_ptr_aligned(ptr, alignment),      \
   387   assert(is_ptr_aligned(ptr, alignment),      \
   390     err_msg(PTR_FORMAT " is not aligned to "  \
   388     err_msg(PTR_FORMAT " is not aligned to "  \
   391       SIZE_FORMAT, ptr, alignment))
   389       SIZE_FORMAT, p2i(ptr), alignment))
   392 
   390 
   393 #define assert_is_size_aligned(size, alignment) \
   391 #define assert_is_size_aligned(size, alignment) \
   394   assert(is_size_aligned(size, alignment),      \
   392   assert(is_size_aligned(size, alignment),      \
   395     err_msg(SIZE_FORMAT " is not aligned to "   \
   393     err_msg(SIZE_FORMAT " is not aligned to "   \
   396        SIZE_FORMAT, size, alignment))
   394        SIZE_FORMAT, size, alignment))
   798 void VirtualSpaceNode::inc_container_count() {
   796 void VirtualSpaceNode::inc_container_count() {
   799   assert_lock_strong(SpaceManager::expand_lock());
   797   assert_lock_strong(SpaceManager::expand_lock());
   800   _container_count++;
   798   _container_count++;
   801   assert(_container_count == container_count_slow(),
   799   assert(_container_count == container_count_slow(),
   802          err_msg("Inconsistency in container_count _container_count " SIZE_FORMAT
   800          err_msg("Inconsistency in container_count _container_count " SIZE_FORMAT
   803                  " container_count_slow() " SIZE_FORMAT,
   801                  " container_count_slow() %u",
   804                  _container_count, container_count_slow()));
   802                  _container_count, container_count_slow()));
   805 }
   803 }
   806 
   804 
   807 void VirtualSpaceNode::dec_container_count() {
   805 void VirtualSpaceNode::dec_container_count() {
   808   assert_lock_strong(SpaceManager::expand_lock());
   806   assert_lock_strong(SpaceManager::expand_lock());
   811 
   809 
   812 #ifdef ASSERT
   810 #ifdef ASSERT
   813 void VirtualSpaceNode::verify_container_count() {
   811 void VirtualSpaceNode::verify_container_count() {
   814   assert(_container_count == container_count_slow(),
   812   assert(_container_count == container_count_slow(),
   815     err_msg("Inconsistency in container_count _container_count " SIZE_FORMAT
   813     err_msg("Inconsistency in container_count _container_count " SIZE_FORMAT
   816             " container_count_slow() " SIZE_FORMAT, _container_count, container_count_slow()));
   814             " container_count_slow() %u", _container_count, container_count_slow()));
   817 }
   815 }
   818 #endif
   816 #endif
   819 
   817 
   820 // BlockFreelist methods
   818 // BlockFreelist methods
   821 
   819 
   914   assert(_virtual_space.committed_size() == _virtual_space.actual_committed_size(),
   912   assert(_virtual_space.committed_size() == _virtual_space.actual_committed_size(),
   915       "The committed memory doesn't match the expanded memory.");
   913       "The committed memory doesn't match the expanded memory.");
   916 
   914 
   917   if (!is_available(chunk_word_size)) {
   915   if (!is_available(chunk_word_size)) {
   918     if (TraceMetadataChunkAllocation) {
   916     if (TraceMetadataChunkAllocation) {
   919       gclog_or_tty->print("VirtualSpaceNode::take_from_committed() not available %d words ", chunk_word_size);
   917       gclog_or_tty->print("VirtualSpaceNode::take_from_committed() not available " SIZE_FORMAT " words ", chunk_word_size);
   920       // Dump some information about the virtual space that is nearly full
   918       // Dump some information about the virtual space that is nearly full
   921       print_on(gclog_or_tty);
   919       print_on(gclog_or_tty);
   922     }
   920     }
   923     return NULL;
   921     return NULL;
   924   }
   922   }
   987     set_reserved(MemRegion((HeapWord*)_rs.base(),
   985     set_reserved(MemRegion((HeapWord*)_rs.base(),
   988                  (HeapWord*)(_rs.base() + _rs.size())));
   986                  (HeapWord*)(_rs.base() + _rs.size())));
   989 
   987 
   990     assert(reserved()->start() == (HeapWord*) _rs.base(),
   988     assert(reserved()->start() == (HeapWord*) _rs.base(),
   991       err_msg("Reserved start was not set properly " PTR_FORMAT
   989       err_msg("Reserved start was not set properly " PTR_FORMAT
   992         " != " PTR_FORMAT, reserved()->start(), _rs.base()));
   990         " != " PTR_FORMAT, p2i(reserved()->start()), p2i(_rs.base())));
   993     assert(reserved()->word_size() == _rs.size() / BytesPerWord,
   991     assert(reserved()->word_size() == _rs.size() / BytesPerWord,
   994       err_msg("Reserved size was not set properly " SIZE_FORMAT
   992       err_msg("Reserved size was not set properly " SIZE_FORMAT
   995         " != " SIZE_FORMAT, reserved()->word_size(),
   993         " != " SIZE_FORMAT, reserved()->word_size(),
   996         _rs.size() / BytesPerWord));
   994         _rs.size() / BytesPerWord));
   997   }
   995   }
  1001 
   999 
  1002 void VirtualSpaceNode::print_on(outputStream* st) const {
  1000 void VirtualSpaceNode::print_on(outputStream* st) const {
  1003   size_t used = used_words_in_vs();
  1001   size_t used = used_words_in_vs();
  1004   size_t capacity = capacity_words_in_vs();
  1002   size_t capacity = capacity_words_in_vs();
  1005   VirtualSpace* vs = virtual_space();
  1003   VirtualSpace* vs = virtual_space();
  1006   st->print_cr("   space @ " PTR_FORMAT " " SIZE_FORMAT "K, %3d%% used "
  1004   st->print_cr("   space @ " PTR_FORMAT " " SIZE_FORMAT "K, " SIZE_FORMAT_W(3) "%% used "
  1007            "[" PTR_FORMAT ", " PTR_FORMAT ", "
  1005            "[" PTR_FORMAT ", " PTR_FORMAT ", "
  1008            PTR_FORMAT ", " PTR_FORMAT ")",
  1006            PTR_FORMAT ", " PTR_FORMAT ")",
  1009            vs, capacity / K,
  1007            p2i(vs), capacity / K,
  1010            capacity == 0 ? 0 : used * 100 / capacity,
  1008            capacity == 0 ? 0 : used * 100 / capacity,
  1011            bottom(), top(), end(),
  1009            p2i(bottom()), p2i(top()), p2i(end()),
  1012            vs->high_boundary());
  1010            p2i(vs->high_boundary()));
  1013 }
  1011 }
  1014 
  1012 
  1015 #ifdef ASSERT
  1013 #ifdef ASSERT
  1016 void VirtualSpaceNode::mangle() {
  1014 void VirtualSpaceNode::mangle() {
  1017   size_t word_size = capacity_words_in_vs();
  1015   size_t word_size = capacity_words_in_vs();
  1810     free_list->remove_chunk(chunk);
  1808     free_list->remove_chunk(chunk);
  1811 
  1809 
  1812     if (TraceMetadataChunkAllocation && Verbose) {
  1810     if (TraceMetadataChunkAllocation && Verbose) {
  1813       gclog_or_tty->print_cr("ChunkManager::free_chunks_get: free_list "
  1811       gclog_or_tty->print_cr("ChunkManager::free_chunks_get: free_list "
  1814                              PTR_FORMAT " head " PTR_FORMAT " size " SIZE_FORMAT,
  1812                              PTR_FORMAT " head " PTR_FORMAT " size " SIZE_FORMAT,
  1815                              free_list, chunk, chunk->word_size());
  1813                              p2i(free_list), p2i(chunk), chunk->word_size());
  1816     }
  1814     }
  1817   } else {
  1815   } else {
  1818     chunk = humongous_dictionary()->get_chunk(
  1816     chunk = humongous_dictionary()->get_chunk(
  1819       word_size,
  1817       word_size,
  1820       FreeBlockDictionary<Metachunk>::atLeast);
  1818       FreeBlockDictionary<Metachunk>::atLeast);
  1870     } else {
  1868     } else {
  1871       list_count = humongous_dictionary()->total_count();
  1869       list_count = humongous_dictionary()->total_count();
  1872     }
  1870     }
  1873     gclog_or_tty->print("ChunkManager::chunk_freelist_allocate: " PTR_FORMAT " chunk "
  1871     gclog_or_tty->print("ChunkManager::chunk_freelist_allocate: " PTR_FORMAT " chunk "
  1874                         PTR_FORMAT "  size " SIZE_FORMAT " count " SIZE_FORMAT " ",
  1872                         PTR_FORMAT "  size " SIZE_FORMAT " count " SIZE_FORMAT " ",
  1875                         this, chunk, chunk->word_size(), list_count);
  1873                         p2i(this), p2i(chunk), chunk->word_size(), list_count);
  1876     locked_print_free_chunks(gclog_or_tty);
  1874     locked_print_free_chunks(gclog_or_tty);
  1877   }
  1875   }
  1878 
  1876 
  1879   return chunk;
  1877   return chunk;
  1880 }
  1878 }
  2017 void SpaceManager::locked_print_chunks_in_use_on(outputStream* st) const {
  2015 void SpaceManager::locked_print_chunks_in_use_on(outputStream* st) const {
  2018 
  2016 
  2019   for (ChunkIndex i = ZeroIndex; i < NumberOfInUseLists; i = next_chunk_index(i)) {
  2017   for (ChunkIndex i = ZeroIndex; i < NumberOfInUseLists; i = next_chunk_index(i)) {
  2020     Metachunk* chunk = chunks_in_use(i);
  2018     Metachunk* chunk = chunks_in_use(i);
  2021     st->print("SpaceManager: %s " PTR_FORMAT,
  2019     st->print("SpaceManager: %s " PTR_FORMAT,
  2022                  chunk_size_name(i), chunk);
  2020                  chunk_size_name(i), p2i(chunk));
  2023     if (chunk != NULL) {
  2021     if (chunk != NULL) {
  2024       st->print_cr(" free " SIZE_FORMAT,
  2022       st->print_cr(" free " SIZE_FORMAT,
  2025                    chunk->free_word_size());
  2023                    chunk->free_word_size());
  2026     } else {
  2024     } else {
  2027       st->cr();
  2025       st->cr();
  2128 void SpaceManager::print_on(outputStream* st) const {
  2126 void SpaceManager::print_on(outputStream* st) const {
  2129 
  2127 
  2130   for (ChunkIndex i = ZeroIndex;
  2128   for (ChunkIndex i = ZeroIndex;
  2131        i < NumberOfInUseLists ;
  2129        i < NumberOfInUseLists ;
  2132        i = next_chunk_index(i) ) {
  2130        i = next_chunk_index(i) ) {
  2133     st->print_cr("  chunks_in_use " PTR_FORMAT " chunk size " PTR_FORMAT,
  2131     st->print_cr("  chunks_in_use " PTR_FORMAT " chunk size " SIZE_FORMAT,
  2134                  chunks_in_use(i),
  2132                  p2i(chunks_in_use(i)),
  2135                  chunks_in_use(i) == NULL ? 0 : chunks_in_use(i)->word_size());
  2133                  chunks_in_use(i) == NULL ? 0 : chunks_in_use(i)->word_size());
  2136   }
  2134   }
  2137   st->print_cr("    waste:  Small " SIZE_FORMAT " Medium " SIZE_FORMAT
  2135   st->print_cr("    waste:  Small " SIZE_FORMAT " Medium " SIZE_FORMAT
  2138                " Humongous " SIZE_FORMAT,
  2136                " Humongous " SIZE_FORMAT,
  2139                sum_waste_in_chunks_in_use(SmallIndex),
  2137                sum_waste_in_chunks_in_use(SmallIndex),
  2192   for (ChunkIndex i = ZeroIndex; i < NumberOfInUseLists; i = next_chunk_index(i)) {
  2190   for (ChunkIndex i = ZeroIndex; i < NumberOfInUseLists; i = next_chunk_index(i)) {
  2193     _chunks_in_use[i] = NULL;
  2191     _chunks_in_use[i] = NULL;
  2194   }
  2192   }
  2195   _current_chunk = NULL;
  2193   _current_chunk = NULL;
  2196   if (TraceMetadataChunkAllocation && Verbose) {
  2194   if (TraceMetadataChunkAllocation && Verbose) {
  2197     gclog_or_tty->print_cr("SpaceManager(): " PTR_FORMAT, this);
  2195     gclog_or_tty->print_cr("SpaceManager(): " PTR_FORMAT, p2i(this));
  2198   }
  2196   }
  2199 }
  2197 }
  2200 
  2198 
  2201 void ChunkManager::return_chunks(ChunkIndex index, Metachunk* chunks) {
  2199 void ChunkManager::return_chunks(ChunkIndex index, Metachunk* chunks) {
  2202   if (chunks == NULL) {
  2200   if (chunks == NULL) {
  2236   chunk_manager()->slow_locked_verify();
  2234   chunk_manager()->slow_locked_verify();
  2237 
  2235 
  2238   dec_total_from_size_metrics();
  2236   dec_total_from_size_metrics();
  2239 
  2237 
  2240   if (TraceMetadataChunkAllocation && Verbose) {
  2238   if (TraceMetadataChunkAllocation && Verbose) {
  2241     gclog_or_tty->print_cr("~SpaceManager(): " PTR_FORMAT, this);
  2239     gclog_or_tty->print_cr("~SpaceManager(): " PTR_FORMAT, p2i(this));
  2242     locked_print_chunks_in_use_on(gclog_or_tty);
  2240     locked_print_chunks_in_use_on(gclog_or_tty);
  2243   }
  2241   }
  2244 
  2242 
  2245   // Do not mangle freed Metachunks.  The chunk size inside Metachunks
  2243   // Do not mangle freed Metachunks.  The chunk size inside Metachunks
  2246   // is during the freeing of a VirtualSpaceNodes.
  2244   // is during the freeing of a VirtualSpaceNodes.
  2256   // Follow each list of chunks-in-use and add them to the
  2254   // Follow each list of chunks-in-use and add them to the
  2257   // free lists.  Each list is NULL terminated.
  2255   // free lists.  Each list is NULL terminated.
  2258 
  2256 
  2259   for (ChunkIndex i = ZeroIndex; i < HumongousIndex; i = next_chunk_index(i)) {
  2257   for (ChunkIndex i = ZeroIndex; i < HumongousIndex; i = next_chunk_index(i)) {
  2260     if (TraceMetadataChunkAllocation && Verbose) {
  2258     if (TraceMetadataChunkAllocation && Verbose) {
  2261       gclog_or_tty->print_cr("returned %d %s chunks to freelist",
  2259       gclog_or_tty->print_cr("returned " SIZE_FORMAT " %s chunks to freelist",
  2262                              sum_count_in_chunks_in_use(i),
  2260                              sum_count_in_chunks_in_use(i),
  2263                              chunk_size_name(i));
  2261                              chunk_size_name(i));
  2264     }
  2262     }
  2265     Metachunk* chunks = chunks_in_use(i);
  2263     Metachunk* chunks = chunks_in_use(i);
  2266     chunk_manager()->return_chunks(i, chunks);
  2264     chunk_manager()->return_chunks(i, chunks);
  2267     set_chunks_in_use(i, NULL);
  2265     set_chunks_in_use(i, NULL);
  2268     if (TraceMetadataChunkAllocation && Verbose) {
  2266     if (TraceMetadataChunkAllocation && Verbose) {
  2269       gclog_or_tty->print_cr("updated freelist count %d %s",
  2267       gclog_or_tty->print_cr("updated freelist count " SSIZE_FORMAT " %s",
  2270                              chunk_manager()->free_chunks(i)->count(),
  2268                              chunk_manager()->free_chunks(i)->count(),
  2271                              chunk_size_name(i));
  2269                              chunk_size_name(i));
  2272     }
  2270     }
  2273     assert(i != HumongousIndex, "Humongous chunks are handled explicitly later");
  2271     assert(i != HumongousIndex, "Humongous chunks are handled explicitly later");
  2274   }
  2272   }
  2277   // tail of the medium chunk list to add_at_head().  The tail is often
  2275   // tail of the medium chunk list to add_at_head().  The tail is often
  2278   // the current chunk but there are probably exceptions.
  2276   // the current chunk but there are probably exceptions.
  2279 
  2277 
  2280   // Humongous chunks
  2278   // Humongous chunks
  2281   if (TraceMetadataChunkAllocation && Verbose) {
  2279   if (TraceMetadataChunkAllocation && Verbose) {
  2282     gclog_or_tty->print_cr("returned %d %s humongous chunks to dictionary",
  2280     gclog_or_tty->print_cr("returned " SIZE_FORMAT " %s humongous chunks to dictionary",
  2283                             sum_count_in_chunks_in_use(HumongousIndex),
  2281                             sum_count_in_chunks_in_use(HumongousIndex),
  2284                             chunk_size_name(HumongousIndex));
  2282                             chunk_size_name(HumongousIndex));
  2285     gclog_or_tty->print("Humongous chunk dictionary: ");
  2283     gclog_or_tty->print("Humongous chunk dictionary: ");
  2286   }
  2284   }
  2287   // Humongous chunks are never the current chunk.
  2285   // Humongous chunks are never the current chunk.
  2291 #ifdef ASSERT
  2289 #ifdef ASSERT
  2292     humongous_chunks->set_is_tagged_free(true);
  2290     humongous_chunks->set_is_tagged_free(true);
  2293 #endif
  2291 #endif
  2294     if (TraceMetadataChunkAllocation && Verbose) {
  2292     if (TraceMetadataChunkAllocation && Verbose) {
  2295       gclog_or_tty->print(PTR_FORMAT " (" SIZE_FORMAT ") ",
  2293       gclog_or_tty->print(PTR_FORMAT " (" SIZE_FORMAT ") ",
  2296                           humongous_chunks,
  2294                           p2i(humongous_chunks),
  2297                           humongous_chunks->word_size());
  2295                           humongous_chunks->word_size());
  2298     }
  2296     }
  2299     assert(humongous_chunks->word_size() == (size_t)
  2297     assert(humongous_chunks->word_size() == (size_t)
  2300            align_size_up(humongous_chunks->word_size(),
  2298            align_size_up(humongous_chunks->word_size(),
  2301                              smallest_chunk_size()),
  2299                              smallest_chunk_size()),
  2302            err_msg("Humongous chunk size is wrong: word size " SIZE_FORMAT
  2300            err_msg("Humongous chunk size is wrong: word size " SIZE_FORMAT
  2303                    " granularity %d",
  2301                    " granularity " SIZE_FORMAT,
  2304                    humongous_chunks->word_size(), smallest_chunk_size()));
  2302                    humongous_chunks->word_size(), smallest_chunk_size()));
  2305     Metachunk* next_humongous_chunks = humongous_chunks->next();
  2303     Metachunk* next_humongous_chunks = humongous_chunks->next();
  2306     humongous_chunks->container()->dec_container_count();
  2304     humongous_chunks->container()->dec_container_count();
  2307     chunk_manager()->humongous_dictionary()->return_chunk(humongous_chunks);
  2305     chunk_manager()->humongous_dictionary()->return_chunk(humongous_chunks);
  2308     humongous_chunks = next_humongous_chunks;
  2306     humongous_chunks = next_humongous_chunks;
  2309   }
  2307   }
  2310   if (TraceMetadataChunkAllocation && Verbose) {
  2308   if (TraceMetadataChunkAllocation && Verbose) {
  2311     gclog_or_tty->cr();
  2309     gclog_or_tty->cr();
  2312     gclog_or_tty->print_cr("updated dictionary count %d %s",
  2310     gclog_or_tty->print_cr("updated dictionary count " SIZE_FORMAT " %s",
  2313                      chunk_manager()->humongous_dictionary()->total_count(),
  2311                      chunk_manager()->humongous_dictionary()->total_count(),
  2314                      chunk_size_name(HumongousIndex));
  2312                      chunk_size_name(HumongousIndex));
  2315   }
  2313   }
  2316   chunk_manager()->slow_locked_verify();
  2314   chunk_manager()->slow_locked_verify();
  2317 }
  2315 }
  2397   // Add to the running sum of capacity
  2395   // Add to the running sum of capacity
  2398   inc_size_metrics(new_chunk->word_size());
  2396   inc_size_metrics(new_chunk->word_size());
  2399 
  2397 
  2400   assert(new_chunk->is_empty(), "Not ready for reuse");
  2398   assert(new_chunk->is_empty(), "Not ready for reuse");
  2401   if (TraceMetadataChunkAllocation && Verbose) {
  2399   if (TraceMetadataChunkAllocation && Verbose) {
  2402     gclog_or_tty->print("SpaceManager::add_chunk: %d) ",
  2400     gclog_or_tty->print("SpaceManager::add_chunk: " SIZE_FORMAT ") ",
  2403                         sum_count_in_chunks_in_use());
  2401                         sum_count_in_chunks_in_use());
  2404     new_chunk->print_on(gclog_or_tty);
  2402     new_chunk->print_on(gclog_or_tty);
  2405     chunk_manager()->locked_print_free_chunks(gclog_or_tty);
  2403     chunk_manager()->locked_print_free_chunks(gclog_or_tty);
  2406   }
  2404   }
  2407 }
  2405 }
  3095     // So, UseCompressedClassPointers cannot be turned off at this point.
  3093     // So, UseCompressedClassPointers cannot be turned off at this point.
  3096     if (!metaspace_rs.is_reserved()) {
  3094     if (!metaspace_rs.is_reserved()) {
  3097       metaspace_rs = ReservedSpace(compressed_class_space_size(),
  3095       metaspace_rs = ReservedSpace(compressed_class_space_size(),
  3098                                    _reserve_alignment, large_pages);
  3096                                    _reserve_alignment, large_pages);
  3099       if (!metaspace_rs.is_reserved()) {
  3097       if (!metaspace_rs.is_reserved()) {
  3100         vm_exit_during_initialization(err_msg("Could not allocate metaspace: %d bytes",
  3098         vm_exit_during_initialization(err_msg("Could not allocate metaspace: " SIZE_FORMAT " bytes",
  3101                                               compressed_class_space_size()));
  3099                                               compressed_class_space_size()));
  3102       }
  3100       }
  3103     }
  3101     }
  3104   }
  3102   }
  3105 
  3103 
  3117                                   UseSharedSpaces ? (address)cds_base : 0);
  3115                                   UseSharedSpaces ? (address)cds_base : 0);
  3118 
  3116 
  3119   initialize_class_space(metaspace_rs);
  3117   initialize_class_space(metaspace_rs);
  3120 
  3118 
  3121   if (PrintCompressedOopsMode || (PrintMiscellaneous && Verbose)) {
  3119   if (PrintCompressedOopsMode || (PrintMiscellaneous && Verbose)) {
  3122     gclog_or_tty->print_cr("Narrow klass base: " PTR_FORMAT ", Narrow klass shift: " SIZE_FORMAT,
  3120     gclog_or_tty->print_cr("Narrow klass base: " PTR_FORMAT ", Narrow klass shift: %d",
  3123                             Universe::narrow_klass_base(), Universe::narrow_klass_shift());
  3121                             p2i(Universe::narrow_klass_base()), Universe::narrow_klass_shift());
  3124     gclog_or_tty->print_cr("Compressed class space size: " SIZE_FORMAT " Address: " PTR_FORMAT " Req Addr: " PTR_FORMAT,
  3122     gclog_or_tty->print_cr("Compressed class space size: " SIZE_FORMAT " Address: " PTR_FORMAT " Req Addr: " PTR_FORMAT,
  3125                            compressed_class_space_size(), metaspace_rs.base(), requested_addr);
  3123                            compressed_class_space_size(), p2i(metaspace_rs.base()), p2i(requested_addr));
  3126   }
  3124   }
  3127 }
  3125 }
  3128 
  3126 
  3129 // For UseCompressedClassPointers the class space is reserved above the top of
  3127 // For UseCompressedClassPointers the class space is reserved above the top of
  3130 // the Java heap.  The argument passed in is at the base of the compressed space.
  3128 // the Java heap.  The argument passed in is at the base of the compressed space.
  3249 #ifdef _LP64
  3247 #ifdef _LP64
  3250     if (cds_total + compressed_class_space_size() > UnscaledClassSpaceMax) {
  3248     if (cds_total + compressed_class_space_size() > UnscaledClassSpaceMax) {
  3251       vm_exit_during_initialization("Unable to dump shared archive.",
  3249       vm_exit_during_initialization("Unable to dump shared archive.",
  3252           err_msg("Size of archive (" SIZE_FORMAT ") + compressed class space ("
  3250           err_msg("Size of archive (" SIZE_FORMAT ") + compressed class space ("
  3253                   SIZE_FORMAT ") == total (" SIZE_FORMAT ") is larger than compressed "
  3251                   SIZE_FORMAT ") == total (" SIZE_FORMAT ") is larger than compressed "
  3254                   "klass limit: " SIZE_FORMAT, cds_total, compressed_class_space_size(),
  3252                   "klass limit: " UINT64_FORMAT, cds_total, compressed_class_space_size(),
  3255                   cds_total + compressed_class_space_size(), UnscaledClassSpaceMax));
  3253                   cds_total + compressed_class_space_size(), UnscaledClassSpaceMax));
  3256     }
  3254     }
  3257 
  3255 
  3258     // Set the compressed klass pointer base so that decoding of these pointers works
  3256     // Set the compressed klass pointer base so that decoding of these pointers works
  3259     // properly when creating the shared archive.
  3257     // properly when creating the shared archive.
  3260     assert(UseCompressedOops && UseCompressedClassPointers,
  3258     assert(UseCompressedOops && UseCompressedClassPointers,
  3261       "UseCompressedOops and UseCompressedClassPointers must be set");
  3259       "UseCompressedOops and UseCompressedClassPointers must be set");
  3262     Universe::set_narrow_klass_base((address)_space_list->current_virtual_space()->bottom());
  3260     Universe::set_narrow_klass_base((address)_space_list->current_virtual_space()->bottom());
  3263     if (TraceMetavirtualspaceAllocation && Verbose) {
  3261     if (TraceMetavirtualspaceAllocation && Verbose) {
  3264       gclog_or_tty->print_cr("Setting_narrow_klass_base to Address: " PTR_FORMAT,
  3262       gclog_or_tty->print_cr("Setting_narrow_klass_base to Address: " PTR_FORMAT,
  3265                              _space_list->current_virtual_space()->bottom());
  3263                              p2i(_space_list->current_virtual_space()->bottom()));
  3266     }
  3264     }
  3267 
  3265 
  3268     Universe::set_narrow_klass_shift(0);
  3266     Universe::set_narrow_klass_shift(0);
  3269 #endif // _LP64
  3267 #endif // _LP64
  3270 #endif // INCLUDE_CDS
  3268 #endif // INCLUDE_CDS
  3766     class_vsm()->verify();
  3764     class_vsm()->verify();
  3767   }
  3765   }
  3768 }
  3766 }
  3769 
  3767 
  3770 void Metaspace::dump(outputStream* const out) const {
  3768 void Metaspace::dump(outputStream* const out) const {
  3771   out->print_cr("\nVirtual space manager: " INTPTR_FORMAT, vsm());
  3769   out->print_cr("\nVirtual space manager: " INTPTR_FORMAT, p2i(vsm()));
  3772   vsm()->dump(out);
  3770   vsm()->dump(out);
  3773   if (using_class_space()) {
  3771   if (using_class_space()) {
  3774     out->print_cr("\nClass space manager: " INTPTR_FORMAT, class_vsm());
  3772     out->print_cr("\nClass space manager: " INTPTR_FORMAT, p2i(class_vsm()));
  3775     class_vsm()->dump(out);
  3773     class_vsm()->dump(out);
  3776   }
  3774   }
  3777 }
  3775 }
  3778 
  3776 
  3779 /////////////// Unit tests ///////////////
  3777 /////////////// Unit tests ///////////////
  3930 
  3928 
  3931 #define assert_is_available_positive(word_size) \
  3929 #define assert_is_available_positive(word_size) \
  3932   assert(vsn.is_available(word_size), \
  3930   assert(vsn.is_available(word_size), \
  3933     err_msg(#word_size ": " PTR_FORMAT " bytes were not available in " \
  3931     err_msg(#word_size ": " PTR_FORMAT " bytes were not available in " \
  3934             "VirtualSpaceNode [" PTR_FORMAT ", " PTR_FORMAT ")", \
  3932             "VirtualSpaceNode [" PTR_FORMAT ", " PTR_FORMAT ")", \
  3935             (uintptr_t)(word_size * BytesPerWord), vsn.bottom(), vsn.end()));
  3933             (uintptr_t)(word_size * BytesPerWord), p2i(vsn.bottom()), p2i(vsn.end())));
  3936 
  3934 
  3937 #define assert_is_available_negative(word_size) \
  3935 #define assert_is_available_negative(word_size) \
  3938   assert(!vsn.is_available(word_size), \
  3936   assert(!vsn.is_available(word_size), \
  3939     err_msg(#word_size ": " PTR_FORMAT " bytes should not be available in " \
  3937     err_msg(#word_size ": " PTR_FORMAT " bytes should not be available in " \
  3940             "VirtualSpaceNode [" PTR_FORMAT ", " PTR_FORMAT ")", \
  3938             "VirtualSpaceNode [" PTR_FORMAT ", " PTR_FORMAT ")", \
  3941             (uintptr_t)(word_size * BytesPerWord), vsn.bottom(), vsn.end()));
  3939             (uintptr_t)(word_size * BytesPerWord), p2i(vsn.bottom()), p2i(vsn.end())));
  3942 
  3940 
  3943   static void test_is_available_positive() {
  3941   static void test_is_available_positive() {
  3944     // Reserve some memory.
  3942     // Reserve some memory.
  3945     VirtualSpaceNode vsn(os::vm_allocation_granularity());
  3943     VirtualSpaceNode vsn(os::vm_allocation_granularity());
  3946     assert(vsn.initialize(), "Failed to setup VirtualSpaceNode");
  3944     assert(vsn.initialize(), "Failed to setup VirtualSpaceNode");