< prev index next >

src/share/vm/memory/metaspace.cpp

Print this page




3155     // Set the compressed klass pointer base so that decoding of these pointers works
3156     // properly when creating the shared archive.
3157     assert(UseCompressedOops && UseCompressedClassPointers,
3158       "UseCompressedOops and UseCompressedClassPointers must be set");
3159     Universe::set_narrow_klass_base((address)_space_list->current_virtual_space()->bottom());
3160     log_develop_trace(gc, metaspace)("Setting_narrow_klass_base to Address: " PTR_FORMAT,
3161                                      p2i(_space_list->current_virtual_space()->bottom()));
3162 
3163     Universe::set_narrow_klass_shift(0);
3164 #endif // _LP64
3165 #endif // INCLUDE_CDS
3166   } else {
3167 #if INCLUDE_CDS
3168     if (UseSharedSpaces) {
3169       // If using shared space, open the file that contains the shared space
3170       // and map in the memory before initializing the rest of metaspace (so
3171       // the addresses don't conflict)
3172       address cds_address = NULL;
3173       FileMapInfo* mapinfo = new FileMapInfo();
3174 
3175       if (JvmtiExport::should_post_class_file_load_hook()) {
3176         // Currently CDS does not support JVMTI CFLH when loading shared class.
3177         // If JvmtiExport::should_post_class_file_load_hook is already enabled,
3178         // just disable UseSharedSpaces.
3179         FileMapInfo::fail_continue("Tool agent requires sharing to be disabled.");
3180         delete mapinfo;
3181       } else {
3182         // Open the shared archive file, read and validate the header. If
3183         // initialization fails, shared spaces [UseSharedSpaces] are
3184         // disabled and the file is closed.
3185         // Map in spaces now also
3186         if (mapinfo->initialize() && MetaspaceShared::map_shared_spaces(mapinfo)) {
3187           cds_total = FileMapInfo::shared_spaces_size();
3188           cds_address = (address)mapinfo->header()->region_addr(0);
3189 #ifdef _LP64
3190           if (using_class_space()) {
3191             char* cds_end = (char*)(cds_address + cds_total);
3192             cds_end = (char *)align_ptr_up(cds_end, _reserve_alignment);
3193             // If UseCompressedClassPointers is set then allocate the metaspace area
3194             // above the heap and above the CDS area (if it exists).
3195             allocate_metaspace_compressed_klass_ptrs(cds_end, cds_address);
3196             // Map the shared string space after compressed pointers
3197             // because it relies on compressed class pointers setting to work
3198             mapinfo->map_string_regions();
3199           }
3200 #endif // _LP64
3201         } else {
3202           assert(!mapinfo->is_open() && !UseSharedSpaces,
3203                  "archive file not closed or shared spaces not disabled.");
3204         }
3205       }
3206     }
3207 #endif // INCLUDE_CDS
3208 
3209 #ifdef _LP64
3210     if (!UseSharedSpaces && using_class_space()) {
3211       char* base = (char*)align_ptr_up(Universe::heap()->reserved_region().end(), _reserve_alignment);
3212       allocate_metaspace_compressed_klass_ptrs(base, 0);
3213     }
3214 #endif // _LP64
3215 
3216     // Initialize these before initializing the VirtualSpaceList
3217     _first_chunk_word_size = InitialBootClassLoaderMetaspaceSize / BytesPerWord;
3218     _first_chunk_word_size = align_word_size_up(_first_chunk_word_size);
3219     // Make the first class chunk bigger than a medium chunk so it's not put
3220     // on the medium chunk list.   The next chunk will be small and progress
3221     // from there.  This size calculated by -version.
3222     _first_class_chunk_word_size = MIN2((size_t)MediumChunk*6,
3223                                        (CompressedClassSpaceSize/BytesPerWord)*2);
3224     _first_class_chunk_word_size = align_word_size_up(_first_class_chunk_word_size);




3155     // Set the compressed klass pointer base so that decoding of these pointers works
3156     // properly when creating the shared archive.
3157     assert(UseCompressedOops && UseCompressedClassPointers,
3158       "UseCompressedOops and UseCompressedClassPointers must be set");
3159     Universe::set_narrow_klass_base((address)_space_list->current_virtual_space()->bottom());
3160     log_develop_trace(gc, metaspace)("Setting_narrow_klass_base to Address: " PTR_FORMAT,
3161                                      p2i(_space_list->current_virtual_space()->bottom()));
3162 
3163     Universe::set_narrow_klass_shift(0);
3164 #endif // _LP64
3165 #endif // INCLUDE_CDS
3166   } else {
3167 #if INCLUDE_CDS
3168     if (UseSharedSpaces) {
3169       // If using shared space, open the file that contains the shared space
3170       // and map in the memory before initializing the rest of metaspace (so
3171       // the addresses don't conflict)
3172       address cds_address = NULL;
3173       FileMapInfo* mapinfo = new FileMapInfo();
3174 







3175       // Open the shared archive file, read and validate the header. If
3176       // initialization fails, shared spaces [UseSharedSpaces] are
3177       // disabled and the file is closed.
3178       // Map in spaces now also
3179       if (mapinfo->initialize() && MetaspaceShared::map_shared_spaces(mapinfo)) {
3180         cds_total = FileMapInfo::shared_spaces_size();
3181         cds_address = (address)mapinfo->header()->region_addr(0);
3182 #ifdef _LP64
3183         if (using_class_space()) {
3184           char* cds_end = (char*)(cds_address + cds_total);
3185           cds_end = (char *)align_ptr_up(cds_end, _reserve_alignment);
3186           // If UseCompressedClassPointers is set then allocate the metaspace area
3187           // above the heap and above the CDS area (if it exists).
3188           allocate_metaspace_compressed_klass_ptrs(cds_end, cds_address);
3189           // Map the shared string space after compressed pointers
3190           // because it relies on compressed class pointers setting to work
3191           mapinfo->map_string_regions();
3192         }
3193 #endif // _LP64
3194       } else {
3195         assert(!mapinfo->is_open() && !UseSharedSpaces,
3196                "archive file not closed or shared spaces not disabled.");

3197       }
3198     }
3199 #endif // INCLUDE_CDS
3200 
3201 #ifdef _LP64
3202     if (!UseSharedSpaces && using_class_space()) {
3203       char* base = (char*)align_ptr_up(Universe::heap()->reserved_region().end(), _reserve_alignment);
3204       allocate_metaspace_compressed_klass_ptrs(base, 0);
3205     }
3206 #endif // _LP64
3207 
3208     // Initialize these before initializing the VirtualSpaceList
3209     _first_chunk_word_size = InitialBootClassLoaderMetaspaceSize / BytesPerWord;
3210     _first_chunk_word_size = align_word_size_up(_first_chunk_word_size);
3211     // Make the first class chunk bigger than a medium chunk so it's not put
3212     // on the medium chunk list.   The next chunk will be small and progress
3213     // from there.  This size calculated by -version.
3214     _first_class_chunk_word_size = MIN2((size_t)MediumChunk*6,
3215                                        (CompressedClassSpaceSize/BytesPerWord)*2);
3216     _first_class_chunk_word_size = align_word_size_up(_first_class_chunk_word_size);


< prev index next >