3928 } 3929 } 3930 3931 MetaWord* Metaspace::allocate(ClassLoaderData* loader_data, size_t word_size, 3932 MetaspaceObj::Type type, TRAPS) { 3933 assert(!_frozen, "sanity"); 3934 if (HAS_PENDING_EXCEPTION) { 3935 assert(false, "Should not allocate with exception pending"); 3936 return NULL; // caller does a CHECK_NULL too 3937 } 3938 3939 assert(loader_data != NULL, "Should never pass around a NULL loader_data. " 3940 "ClassLoaderData::the_null_class_loader_data() should have been used."); 3941 3942 MetadataType mdtype = (type == MetaspaceObj::ClassType) ? ClassType : NonClassType; 3943 3944 // Try to allocate metadata. 3945 MetaWord* result = loader_data->metaspace_non_null()->allocate(word_size, mdtype); 3946 3947 if (result == NULL) { 3948 tracer()->report_metaspace_allocation_failure(loader_data, word_size, type, mdtype); 3949 3950 // Allocation failed. 3951 if (is_init_completed()) { 3952 // Only start a GC if the bootstrapping has completed. 3953 3954 // Try to clean out some memory and retry. 3955 result = Universe::heap()->satisfy_failed_metadata_allocation(loader_data, word_size, mdtype); 3956 } 3957 } 3958 3959 if (result == NULL) { 3960 SpaceManager* sm; 3961 if (is_class_space_allocation(mdtype)) { 3962 sm = loader_data->metaspace_non_null()->class_vsm(); 3963 } else { 3964 sm = loader_data->metaspace_non_null()->vsm(); 3965 } 3966 3967 result = sm->get_small_chunk_and_allocate(word_size); | 3928 } 3929 } 3930 3931 MetaWord* Metaspace::allocate(ClassLoaderData* loader_data, size_t word_size, 3932 MetaspaceObj::Type type, TRAPS) { 3933 assert(!_frozen, "sanity"); 3934 if (HAS_PENDING_EXCEPTION) { 3935 assert(false, "Should not allocate with exception pending"); 3936 return NULL; // caller does a CHECK_NULL too 3937 } 3938 3939 assert(loader_data != NULL, "Should never pass around a NULL loader_data. " 3940 "ClassLoaderData::the_null_class_loader_data() should have been used."); 3941 3942 MetadataType mdtype = (type == MetaspaceObj::ClassType) ? ClassType : NonClassType; 3943 3944 // Try to allocate metadata. 3945 MetaWord* result = loader_data->metaspace_non_null()->allocate(word_size, mdtype); 3946 3947 if (result == NULL) { 3948 if (DumpSharedSpaces && THREAD->is_VM_thread()) { 3949 tty->print_cr("Failed allocating metaspace object type %s of size " SIZE_FORMAT ". CDS dump aborted.", 3950 MetaspaceObj::type_name(type), word_size * BytesPerWord); 3951 vm_exit(1); 3952 } 3953 3954 tracer()->report_metaspace_allocation_failure(loader_data, word_size, type, mdtype); 3955 3956 // Allocation failed. 3957 if (is_init_completed()) { 3958 // Only start a GC if the bootstrapping has completed. 3959 3960 // Try to clean out some memory and retry. 3961 result = Universe::heap()->satisfy_failed_metadata_allocation(loader_data, word_size, mdtype); 3962 } 3963 } 3964 3965 if (result == NULL) { 3966 SpaceManager* sm; 3967 if (is_class_space_allocation(mdtype)) { 3968 sm = loader_data->metaspace_non_null()->class_vsm(); 3969 } else { 3970 sm = loader_data->metaspace_non_null()->vsm(); 3971 } 3972 3973 result = sm->get_small_chunk_and_allocate(word_size); |