< prev index next >

src/share/vm/memory/metaspace.cpp

Print this page
rev 12854 : [mq]: gcinterface.patch


3356         if (using_class_space()) {
3357           char* cds_end = (char*)(cds_address + cds_total);
3358           cds_end = (char *)align_ptr_up(cds_end, _reserve_alignment);
3359           // If UseCompressedClassPointers is set then allocate the metaspace area
3360           // above the heap and above the CDS area (if it exists).
3361           allocate_metaspace_compressed_klass_ptrs(cds_end, cds_address);
3362           // Map the shared string space after compressed pointers
3363           // because it relies on compressed class pointers setting to work
3364           mapinfo->map_string_regions();
3365         }
3366 #endif // _LP64
3367       } else {
3368         assert(!mapinfo->is_open() && !UseSharedSpaces,
3369                "archive file not closed or shared spaces not disabled.");
3370       }
3371     }
3372 #endif // INCLUDE_CDS
3373 
3374 #ifdef _LP64
3375     if (!UseSharedSpaces && using_class_space()) {
3376       char* base = (char*)align_ptr_up(Universe::heap()->reserved_region().end(), _reserve_alignment);
3377       allocate_metaspace_compressed_klass_ptrs(base, 0);
3378     }
3379 #endif // _LP64
3380 
3381     // Initialize these before initializing the VirtualSpaceList
3382     _first_chunk_word_size = InitialBootClassLoaderMetaspaceSize / BytesPerWord;
3383     _first_chunk_word_size = align_word_size_up(_first_chunk_word_size);
3384     // Make the first class chunk bigger than a medium chunk so it's not put
3385     // on the medium chunk list.   The next chunk will be small and progress
3386     // from there.  This size calculated by -version.
3387     _first_class_chunk_word_size = MIN2((size_t)MediumChunk*6,
3388                                        (CompressedClassSpaceSize/BytesPerWord)*2);
3389     _first_class_chunk_word_size = align_word_size_up(_first_class_chunk_word_size);
3390     // Arbitrarily set the initial virtual space to a multiple
3391     // of the boot class loader size.
3392     size_t word_size = VIRTUALSPACEMULTIPLIER * _first_chunk_word_size;
3393     word_size = align_size_up(word_size, Metaspace::reserve_alignment_words());
3394 
3395     // Initialize the list of virtual spaces.
3396     _space_list = new VirtualSpaceList(word_size);


3609 
3610     // Zero initialize.
3611     Copy::fill_to_words((HeapWord*)result, word_size, 0);
3612 
3613     return result;
3614   }
3615 
3616   MetadataType mdtype = (type == MetaspaceObj::ClassType) ? ClassType : NonClassType;
3617 
3618   // Try to allocate metadata.
3619   MetaWord* result = loader_data->metaspace_non_null()->allocate(word_size, mdtype);
3620 
3621   if (result == NULL) {
3622     tracer()->report_metaspace_allocation_failure(loader_data, word_size, type, mdtype);
3623 
3624     // Allocation failed.
3625     if (is_init_completed()) {
3626       // Only start a GC if the bootstrapping has completed.
3627 
3628       // Try to clean out some memory and retry.
3629       result = Universe::heap()->collector_policy()->satisfy_failed_metadata_allocation(
3630           loader_data, word_size, mdtype);
3631     }
3632   }
3633 
3634   if (result == NULL) {
3635     SpaceManager* sm;
3636     if (is_class_space_allocation(mdtype)) {
3637       sm = loader_data->metaspace_non_null()->class_vsm();
3638     } else {
3639       sm = loader_data->metaspace_non_null()->vsm();
3640     }
3641 
3642     result = sm->get_small_chunk_and_allocate(word_size);
3643 
3644     if (result == NULL) {
3645       report_metadata_oome(loader_data, word_size, type, mdtype, CHECK_NULL);
3646     }
3647   }
3648 
3649   // Zero initialize.




3356         if (using_class_space()) {
3357           char* cds_end = (char*)(cds_address + cds_total);
3358           cds_end = (char *)align_ptr_up(cds_end, _reserve_alignment);
3359           // If UseCompressedClassPointers is set then allocate the metaspace area
3360           // above the heap and above the CDS area (if it exists).
3361           allocate_metaspace_compressed_klass_ptrs(cds_end, cds_address);
3362           // Map the shared string space after compressed pointers
3363           // because it relies on compressed class pointers setting to work
3364           mapinfo->map_string_regions();
3365         }
3366 #endif // _LP64
3367       } else {
3368         assert(!mapinfo->is_open() && !UseSharedSpaces,
3369                "archive file not closed or shared spaces not disabled.");
3370       }
3371     }
3372 #endif // INCLUDE_CDS
3373 
3374 #ifdef _LP64
3375     if (!UseSharedSpaces && using_class_space()) {
3376       char* base = (char*)align_ptr_up(GC::gc()->heap()->reserved_region().end(), _reserve_alignment);
3377       allocate_metaspace_compressed_klass_ptrs(base, 0);
3378     }
3379 #endif // _LP64
3380 
3381     // Initialize these before initializing the VirtualSpaceList
3382     _first_chunk_word_size = InitialBootClassLoaderMetaspaceSize / BytesPerWord;
3383     _first_chunk_word_size = align_word_size_up(_first_chunk_word_size);
3384     // Make the first class chunk bigger than a medium chunk so it's not put
3385     // on the medium chunk list.   The next chunk will be small and progress
3386     // from there.  This size calculated by -version.
3387     _first_class_chunk_word_size = MIN2((size_t)MediumChunk*6,
3388                                        (CompressedClassSpaceSize/BytesPerWord)*2);
3389     _first_class_chunk_word_size = align_word_size_up(_first_class_chunk_word_size);
3390     // Arbitrarily set the initial virtual space to a multiple
3391     // of the boot class loader size.
3392     size_t word_size = VIRTUALSPACEMULTIPLIER * _first_chunk_word_size;
3393     word_size = align_size_up(word_size, Metaspace::reserve_alignment_words());
3394 
3395     // Initialize the list of virtual spaces.
3396     _space_list = new VirtualSpaceList(word_size);


3609 
3610     // Zero initialize.
3611     Copy::fill_to_words((HeapWord*)result, word_size, 0);
3612 
3613     return result;
3614   }
3615 
3616   MetadataType mdtype = (type == MetaspaceObj::ClassType) ? ClassType : NonClassType;
3617 
3618   // Try to allocate metadata.
3619   MetaWord* result = loader_data->metaspace_non_null()->allocate(word_size, mdtype);
3620 
3621   if (result == NULL) {
3622     tracer()->report_metaspace_allocation_failure(loader_data, word_size, type, mdtype);
3623 
3624     // Allocation failed.
3625     if (is_init_completed()) {
3626       // Only start a GC if the bootstrapping has completed.
3627 
3628       // Try to clean out some memory and retry.
3629       result = GC::gc()->heap()->collector_policy()->satisfy_failed_metadata_allocation(
3630           loader_data, word_size, mdtype);
3631     }
3632   }
3633 
3634   if (result == NULL) {
3635     SpaceManager* sm;
3636     if (is_class_space_allocation(mdtype)) {
3637       sm = loader_data->metaspace_non_null()->class_vsm();
3638     } else {
3639       sm = loader_data->metaspace_non_null()->vsm();
3640     }
3641 
3642     result = sm->get_small_chunk_and_allocate(word_size);
3643 
3644     if (result == NULL) {
3645       report_metadata_oome(loader_data, word_size, type, mdtype, CHECK_NULL);
3646     }
3647   }
3648 
3649   // Zero initialize.


< prev index next >