< prev index next >

src/share/vm/memory/metaspace.cpp

Print this page


3326 #if INCLUDE_CDS
3327   if (DumpSharedSpaces) {
3328     MetaspaceShared::initialize_shared_rs();
3329   } else if (UseSharedSpaces) {
3330     // If using shared space, open the file that contains the shared space
3331     // and map in the memory before initializing the rest of metaspace (so
3332     // the addresses don't conflict)
3333     address cds_address = NULL;
3334     FileMapInfo* mapinfo = new FileMapInfo();
3335 
3336     // Open the shared archive file, read and validate the header. If
3337     // initialization fails, shared spaces [UseSharedSpaces] are
3338     // disabled and the file is closed.
3339     // Map in spaces now also
3340     if (mapinfo->initialize() && MetaspaceShared::map_shared_spaces(mapinfo)) {
3341       size_t cds_total = MetaspaceShared::core_spaces_size();
3342       cds_address = (address)mapinfo->header()->region_addr(0);
3343 #ifdef _LP64
3344       if (using_class_space()) {
3345         char* cds_end = (char*)(cds_address + cds_total);
3346         cds_end = (char *)align_ptr_up(cds_end, _reserve_alignment);
3347         // If UseCompressedClassPointers is set then allocate the metaspace area
3348         // above the heap and above the CDS area (if it exists).
3349         allocate_metaspace_compressed_klass_ptrs(cds_end, cds_address);
3350         // Map the shared string space after compressed pointers
3351         // because it relies on compressed class pointers setting to work
3352         mapinfo->map_string_regions();
3353       }
3354 #endif // _LP64
3355     } else {
3356       assert(!mapinfo->is_open() && !UseSharedSpaces,
3357              "archive file not closed or shared spaces not disabled.");
3358     }
3359   }
3360 #endif // INCLUDE_CDS
3361 
3362 #ifdef _LP64
3363   if (!UseSharedSpaces && using_class_space()) {
3364     if (DumpSharedSpaces) {
3365       // Already initialized inside MetaspaceShared::initialize_shared_rs()
3366     } else {

3367       allocate_metaspace_compressed_klass_ptrs(base, 0);
3368     }
3369   }
3370 #endif // _LP64
3371 
3372   // Initialize these before initializing the VirtualSpaceList
3373   _first_chunk_word_size = InitialBootClassLoaderMetaspaceSize / BytesPerWord;
3374   _first_chunk_word_size = align_word_size_up(_first_chunk_word_size);
3375   // Make the first class chunk bigger than a medium chunk so it's not put
3376   // on the medium chunk list.   The next chunk will be small and progress
3377   // from there.  This size calculated by -version.
3378   _first_class_chunk_word_size = MIN2((size_t)MediumChunk*6,
3379                                      (CompressedClassSpaceSize/BytesPerWord)*2);
3380   _first_class_chunk_word_size = align_word_size_up(_first_class_chunk_word_size);
3381   // Arbitrarily set the initial virtual space to a multiple
3382   // of the boot class loader size.
3383   size_t word_size = VIRTUALSPACEMULTIPLIER * _first_chunk_word_size;
3384   word_size = align_size_up(word_size, Metaspace::reserve_alignment_words());
3385 
3386   // Initialize the list of virtual spaces.
3387   _space_list = new VirtualSpaceList(word_size);
3388   _chunk_manager_metadata = new ChunkManager(SpecializedChunk, SmallChunk, MediumChunk);
3389 
3390   if (!_space_list->initialization_succeeded()) {
3391     vm_exit_during_initialization("Unable to setup metadata virtual space list.", NULL);
3392   }
3393 
3394   _tracer = new MetaspaceTracer();
3395 }
3396 
3397 void Metaspace::post_initialize() {
3398   MetaspaceGC::post_initialize();
3399 }
3400 
3401 void Metaspace::initialize_first_chunk(MetaspaceType type, MetadataType mdtype) {
3402   Metachunk* chunk = get_initialization_chunk(type, mdtype);
3403   if (chunk != NULL) {
3404     // Add to this manager's list of chunks in use and current_chunk().




3326 #if INCLUDE_CDS
3327   if (DumpSharedSpaces) {
3328     MetaspaceShared::initialize_shared_rs();
3329   } else if (UseSharedSpaces) {
3330     // If using shared space, open the file that contains the shared space
3331     // and map in the memory before initializing the rest of metaspace (so
3332     // the addresses don't conflict)
3333     address cds_address = NULL;
3334     FileMapInfo* mapinfo = new FileMapInfo();
3335 
3336     // Open the shared archive file, read and validate the header. If
3337     // initialization fails, shared spaces [UseSharedSpaces] are
3338     // disabled and the file is closed.
3339     // Map in spaces now also
3340     if (mapinfo->initialize() && MetaspaceShared::map_shared_spaces(mapinfo)) {
3341       size_t cds_total = MetaspaceShared::core_spaces_size();
3342       cds_address = (address)mapinfo->header()->region_addr(0);
3343 #ifdef _LP64
3344       if (using_class_space()) {
3345         char* cds_end = (char*)(cds_address + cds_total);
3346         cds_end = (char *)align_up(cds_end, _reserve_alignment);
3347         // If UseCompressedClassPointers is set then allocate the metaspace area
3348         // above the heap and above the CDS area (if it exists).
3349         allocate_metaspace_compressed_klass_ptrs(cds_end, cds_address);
3350         // Map the shared string space after compressed pointers
3351         // because it relies on compressed class pointers setting to work
3352         mapinfo->map_string_regions();
3353       }
3354 #endif // _LP64
3355     } else {
3356       assert(!mapinfo->is_open() && !UseSharedSpaces,
3357              "archive file not closed or shared spaces not disabled.");
3358     }
3359   }
3360 #endif // INCLUDE_CDS
3361 
3362 #ifdef _LP64
3363   if (!UseSharedSpaces && using_class_space()) {
3364     if (DumpSharedSpaces) {
3365       // Already initialized inside MetaspaceShared::initialize_shared_rs()
3366     } else {
3367       char* base = (char*)align_up(Universe::heap()->reserved_region().end(), _reserve_alignment);
3368       allocate_metaspace_compressed_klass_ptrs(base, 0);
3369     }
3370   }
3371 #endif // _LP64
3372 
3373   // Initialize these before initializing the VirtualSpaceList
3374   _first_chunk_word_size = InitialBootClassLoaderMetaspaceSize / BytesPerWord;
3375   _first_chunk_word_size = align_word_size_up(_first_chunk_word_size);
3376   // Make the first class chunk bigger than a medium chunk so it's not put
3377   // on the medium chunk list.   The next chunk will be small and progress
3378   // from there.  This size calculated by -version.
3379   _first_class_chunk_word_size = MIN2((size_t)MediumChunk*6,
3380                                      (CompressedClassSpaceSize/BytesPerWord)*2);
3381   _first_class_chunk_word_size = align_word_size_up(_first_class_chunk_word_size);
3382   // Arbitrarily set the initial virtual space to a multiple
3383   // of the boot class loader size.
3384   size_t word_size = VIRTUALSPACEMULTIPLIER * _first_chunk_word_size;
3385   word_size = align_up(word_size, Metaspace::reserve_alignment_words());
3386 
3387   // Initialize the list of virtual spaces.
3388   _space_list = new VirtualSpaceList(word_size);
3389   _chunk_manager_metadata = new ChunkManager(SpecializedChunk, SmallChunk, MediumChunk);
3390 
3391   if (!_space_list->initialization_succeeded()) {
3392     vm_exit_during_initialization("Unable to setup metadata virtual space list.", NULL);
3393   }
3394 
3395   _tracer = new MetaspaceTracer();
3396 }
3397 
3398 void Metaspace::post_initialize() {
3399   MetaspaceGC::post_initialize();
3400 }
3401 
3402 void Metaspace::initialize_first_chunk(MetaspaceType type, MetadataType mdtype) {
3403   Metachunk* chunk = get_initialization_chunk(type, mdtype);
3404   if (chunk != NULL) {
3405     // Add to this manager's list of chunks in use and current_chunk().


< prev index next >