Mercurial > hg > truffle
comparison src/share/vm/memory/metaspace.cpp @ 12226:7944aba7ba41
8015107: NPG: Use consistent naming for metaspace concepts
Reviewed-by: coleenp, mgerdin, hseigel
author | ehelin |
---|---|
date | Mon, 12 Aug 2013 17:37:02 +0200 |
parents | 4c84d351cca9 |
children | 24e87613ee58 |
comparison
equal
deleted
inserted
replaced
12186:313b724f8911 | 12226:7944aba7ba41 |
---|---|
421 ChunkManager _chunk_manager; | 421 ChunkManager _chunk_manager; |
422 | 422 |
423 // Can this virtual list allocate >1 spaces? Also, used to determine | 423 // Can this virtual list allocate >1 spaces? Also, used to determine |
424 // whether to allocate unlimited small chunks in this virtual space | 424 // whether to allocate unlimited small chunks in this virtual space |
425 bool _is_class; | 425 bool _is_class; |
426 bool can_grow() const { return !is_class() || !UseCompressedKlassPointers; } | 426 bool can_grow() const { return !is_class() || !UseCompressedClassPointers; } |
427 | 427 |
428 // Sum of space in all virtual spaces and number of virtual spaces | 428 // Sum of space in all virtual spaces and number of virtual spaces |
429 size_t _virtual_space_total; | 429 size_t _virtual_space_total; |
430 size_t _virtual_space_count; | 430 size_t _virtual_space_count; |
431 | 431 |
2834 | 2834 |
2835 // Return TRUE if the specified metaspace_base and cds_base are close enough | 2835 // Return TRUE if the specified metaspace_base and cds_base are close enough |
2836 // to work with compressed klass pointers. | 2836 // to work with compressed klass pointers. |
2837 bool Metaspace::can_use_cds_with_metaspace_addr(char* metaspace_base, address cds_base) { | 2837 bool Metaspace::can_use_cds_with_metaspace_addr(char* metaspace_base, address cds_base) { |
2838 assert(cds_base != 0 && UseSharedSpaces, "Only use with CDS"); | 2838 assert(cds_base != 0 && UseSharedSpaces, "Only use with CDS"); |
2839 assert(UseCompressedKlassPointers, "Only use with CompressedKlassPtrs"); | 2839 assert(UseCompressedClassPointers, "Only use with CompressedKlassPtrs"); |
2840 address lower_base = MIN2((address)metaspace_base, cds_base); | 2840 address lower_base = MIN2((address)metaspace_base, cds_base); |
2841 address higher_address = MAX2((address)(cds_base + FileMapInfo::shared_spaces_size()), | 2841 address higher_address = MAX2((address)(cds_base + FileMapInfo::shared_spaces_size()), |
2842 (address)(metaspace_base + class_metaspace_size())); | 2842 (address)(metaspace_base + class_metaspace_size())); |
2843 return ((uint64_t)(higher_address - lower_base) < (uint64_t)max_juint); | 2843 return ((uint64_t)(higher_address - lower_base) < (uint64_t)max_juint); |
2844 } | 2844 } |
2845 | 2845 |
2846 // Try to allocate the metaspace at the requested addr. | 2846 // Try to allocate the metaspace at the requested addr. |
2847 void Metaspace::allocate_metaspace_compressed_klass_ptrs(char* requested_addr, address cds_base) { | 2847 void Metaspace::allocate_metaspace_compressed_klass_ptrs(char* requested_addr, address cds_base) { |
2848 assert(using_class_space(), "called improperly"); | 2848 assert(using_class_space(), "called improperly"); |
2849 assert(UseCompressedKlassPointers, "Only use with CompressedKlassPtrs"); | 2849 assert(UseCompressedClassPointers, "Only use with CompressedKlassPtrs"); |
2850 assert(class_metaspace_size() < KlassEncodingMetaspaceMax, | 2850 assert(class_metaspace_size() < KlassEncodingMetaspaceMax, |
2851 "Metaspace size is too big"); | 2851 "Metaspace size is too big"); |
2852 | 2852 |
2853 ReservedSpace metaspace_rs = ReservedSpace(class_metaspace_size(), | 2853 ReservedSpace metaspace_rs = ReservedSpace(class_metaspace_size(), |
2854 os::vm_allocation_granularity(), | 2854 os::vm_allocation_granularity(), |
2867 } | 2867 } |
2868 } | 2868 } |
2869 | 2869 |
2870 // If no successful allocation then try to allocate the space anywhere. If | 2870 // If no successful allocation then try to allocate the space anywhere. If |
2871 // that fails then OOM doom. At this point we cannot try allocating the | 2871 // that fails then OOM doom. At this point we cannot try allocating the |
2872 // metaspace as if UseCompressedKlassPointers is off because too much | 2872 // metaspace as if UseCompressedClassPointers is off because too much |
2873 // initialization has happened that depends on UseCompressedKlassPointers. | 2873 // initialization has happened that depends on UseCompressedClassPointers. |
2874 // So, UseCompressedKlassPointers cannot be turned off at this point. | 2874 // So, UseCompressedClassPointers cannot be turned off at this point. |
2875 if (!metaspace_rs.is_reserved()) { | 2875 if (!metaspace_rs.is_reserved()) { |
2876 metaspace_rs = ReservedSpace(class_metaspace_size(), | 2876 metaspace_rs = ReservedSpace(class_metaspace_size(), |
2877 os::vm_allocation_granularity(), false); | 2877 os::vm_allocation_granularity(), false); |
2878 if (!metaspace_rs.is_reserved()) { | 2878 if (!metaspace_rs.is_reserved()) { |
2879 vm_exit_during_initialization(err_msg("Could not allocate metaspace: %d bytes", | 2879 vm_exit_during_initialization(err_msg("Could not allocate metaspace: %d bytes", |
2902 gclog_or_tty->print_cr("Metaspace Size: " SIZE_FORMAT " Address: " PTR_FORMAT " Req Addr: " PTR_FORMAT, | 2902 gclog_or_tty->print_cr("Metaspace Size: " SIZE_FORMAT " Address: " PTR_FORMAT " Req Addr: " PTR_FORMAT, |
2903 class_metaspace_size(), metaspace_rs.base(), requested_addr); | 2903 class_metaspace_size(), metaspace_rs.base(), requested_addr); |
2904 } | 2904 } |
2905 } | 2905 } |
2906 | 2906 |
2907 // For UseCompressedKlassPointers the class space is reserved above the top of | 2907 // For UseCompressedClassPointers the class space is reserved above the top of |
2908 // the Java heap. The argument passed in is at the base of the compressed space. | 2908 // the Java heap. The argument passed in is at the base of the compressed space. |
2909 void Metaspace::initialize_class_space(ReservedSpace rs) { | 2909 void Metaspace::initialize_class_space(ReservedSpace rs) { |
2910 // The reserved space size may be bigger because of alignment, esp with UseLargePages | 2910 // The reserved space size may be bigger because of alignment, esp with UseLargePages |
2911 assert(rs.size() >= ClassMetaspaceSize, | 2911 assert(rs.size() >= CompressedClassSpaceSize, |
2912 err_msg(SIZE_FORMAT " != " UINTX_FORMAT, rs.size(), ClassMetaspaceSize)); | 2912 err_msg(SIZE_FORMAT " != " UINTX_FORMAT, rs.size(), CompressedClassSpaceSize)); |
2913 assert(using_class_space(), "Must be using class space"); | 2913 assert(using_class_space(), "Must be using class space"); |
2914 _class_space_list = new VirtualSpaceList(rs); | 2914 _class_space_list = new VirtualSpaceList(rs); |
2915 } | 2915 } |
2916 | 2916 |
2917 #endif | 2917 #endif |
2919 void Metaspace::global_initialize() { | 2919 void Metaspace::global_initialize() { |
2920 // Initialize the alignment for shared spaces. | 2920 // Initialize the alignment for shared spaces. |
2921 int max_alignment = os::vm_page_size(); | 2921 int max_alignment = os::vm_page_size(); |
2922 size_t cds_total = 0; | 2922 size_t cds_total = 0; |
2923 | 2923 |
2924 set_class_metaspace_size(align_size_up(ClassMetaspaceSize, | 2924 set_class_metaspace_size(align_size_up(CompressedClassSpaceSize, |
2925 os::vm_allocation_granularity())); | 2925 os::vm_allocation_granularity())); |
2926 | 2926 |
2927 MetaspaceShared::set_max_alignment(max_alignment); | 2927 MetaspaceShared::set_max_alignment(max_alignment); |
2928 | 2928 |
2929 if (DumpSharedSpaces) { | 2929 if (DumpSharedSpaces) { |
2939 _space_list = new VirtualSpaceList(cds_total/wordSize); | 2939 _space_list = new VirtualSpaceList(cds_total/wordSize); |
2940 | 2940 |
2941 #ifdef _LP64 | 2941 #ifdef _LP64 |
2942 // Set the compressed klass pointer base so that decoding of these pointers works | 2942 // Set the compressed klass pointer base so that decoding of these pointers works |
2943 // properly when creating the shared archive. | 2943 // properly when creating the shared archive. |
2944 assert(UseCompressedOops && UseCompressedKlassPointers, | 2944 assert(UseCompressedOops && UseCompressedClassPointers, |
2945 "UseCompressedOops and UseCompressedKlassPointers must be set"); | 2945 "UseCompressedOops and UseCompressedClassPointers must be set"); |
2946 Universe::set_narrow_klass_base((address)_space_list->current_virtual_space()->bottom()); | 2946 Universe::set_narrow_klass_base((address)_space_list->current_virtual_space()->bottom()); |
2947 if (TraceMetavirtualspaceAllocation && Verbose) { | 2947 if (TraceMetavirtualspaceAllocation && Verbose) { |
2948 gclog_or_tty->print_cr("Setting_narrow_klass_base to Address: " PTR_FORMAT, | 2948 gclog_or_tty->print_cr("Setting_narrow_klass_base to Address: " PTR_FORMAT, |
2949 _space_list->current_virtual_space()->bottom()); | 2949 _space_list->current_virtual_space()->bottom()); |
2950 } | 2950 } |
2977 cds_total = FileMapInfo::shared_spaces_size(); | 2977 cds_total = FileMapInfo::shared_spaces_size(); |
2978 cds_address = (address)mapinfo->region_base(0); | 2978 cds_address = (address)mapinfo->region_base(0); |
2979 } | 2979 } |
2980 | 2980 |
2981 #ifdef _LP64 | 2981 #ifdef _LP64 |
2982 // If UseCompressedKlassPointers is set then allocate the metaspace area | 2982 // If UseCompressedClassPointers is set then allocate the metaspace area |
2983 // above the heap and above the CDS area (if it exists). | 2983 // above the heap and above the CDS area (if it exists). |
2984 if (using_class_space()) { | 2984 if (using_class_space()) { |
2985 if (UseSharedSpaces) { | 2985 if (UseSharedSpaces) { |
2986 allocate_metaspace_compressed_klass_ptrs((char *)(cds_address + cds_total), cds_address); | 2986 allocate_metaspace_compressed_klass_ptrs((char *)(cds_address + cds_total), cds_address); |
2987 } else { | 2987 } else { |
2995 _first_chunk_word_size = align_word_size_up(_first_chunk_word_size); | 2995 _first_chunk_word_size = align_word_size_up(_first_chunk_word_size); |
2996 // Make the first class chunk bigger than a medium chunk so it's not put | 2996 // Make the first class chunk bigger than a medium chunk so it's not put |
2997 // on the medium chunk list. The next chunk will be small and progress | 2997 // on the medium chunk list. The next chunk will be small and progress |
2998 // from there. This size calculated by -version. | 2998 // from there. This size calculated by -version. |
2999 _first_class_chunk_word_size = MIN2((size_t)MediumChunk*6, | 2999 _first_class_chunk_word_size = MIN2((size_t)MediumChunk*6, |
3000 (ClassMetaspaceSize/BytesPerWord)*2); | 3000 (CompressedClassSpaceSize/BytesPerWord)*2); |
3001 _first_class_chunk_word_size = align_word_size_up(_first_class_chunk_word_size); | 3001 _first_class_chunk_word_size = align_word_size_up(_first_class_chunk_word_size); |
3002 // Arbitrarily set the initial virtual space to a multiple | 3002 // Arbitrarily set the initial virtual space to a multiple |
3003 // of the boot class loader size. | 3003 // of the boot class loader size. |
3004 size_t word_size = VIRTUALSPACEMULTIPLIER * first_chunk_word_size(); | 3004 size_t word_size = VIRTUALSPACEMULTIPLIER * first_chunk_word_size(); |
3005 // Initialize the list of virtual spaces. | 3005 // Initialize the list of virtual spaces. |
3062 return ReservedSpace::allocation_align_size_up(byte_size) / wordSize; | 3062 return ReservedSpace::allocation_align_size_up(byte_size) / wordSize; |
3063 } | 3063 } |
3064 | 3064 |
3065 MetaWord* Metaspace::allocate(size_t word_size, MetadataType mdtype) { | 3065 MetaWord* Metaspace::allocate(size_t word_size, MetadataType mdtype) { |
3066 // DumpSharedSpaces doesn't use class metadata area (yet) | 3066 // DumpSharedSpaces doesn't use class metadata area (yet) |
3067 // Also, don't use class_vsm() unless UseCompressedKlassPointers is true. | 3067 // Also, don't use class_vsm() unless UseCompressedClassPointers is true. |
3068 if (mdtype == ClassType && using_class_space()) { | 3068 if (mdtype == ClassType && using_class_space()) { |
3069 return class_vsm()->allocate(word_size); | 3069 return class_vsm()->allocate(word_size); |
3070 } else { | 3070 } else { |
3071 return vsm()->allocate(word_size); | 3071 return vsm()->allocate(word_size); |
3072 } | 3072 } |
3211 SIZE_FORMAT, word_size); | 3211 SIZE_FORMAT, word_size); |
3212 if (loader_data->metaspace_or_null() != NULL) loader_data->dump(gclog_or_tty); | 3212 if (loader_data->metaspace_or_null() != NULL) loader_data->dump(gclog_or_tty); |
3213 MetaspaceAux::dump(gclog_or_tty); | 3213 MetaspaceAux::dump(gclog_or_tty); |
3214 } | 3214 } |
3215 // -XX:+HeapDumpOnOutOfMemoryError and -XX:OnOutOfMemoryError support | 3215 // -XX:+HeapDumpOnOutOfMemoryError and -XX:OnOutOfMemoryError support |
3216 const char* space_string = (mdtype == ClassType) ? "Class Metadata space" : | 3216 const char* space_string = (mdtype == ClassType) ? "Compressed class space" : |
3217 "Metadata space"; | 3217 "Metadata space"; |
3218 report_java_out_of_memory(space_string); | 3218 report_java_out_of_memory(space_string); |
3219 | 3219 |
3220 if (JvmtiExport::should_post_resource_exhausted()) { | 3220 if (JvmtiExport::should_post_resource_exhausted()) { |
3221 JvmtiExport::post_resource_exhausted( | 3221 JvmtiExport::post_resource_exhausted( |