719 // class loaders and not anonymous. |
719 // class loaders and not anonymous. |
720 bool ClassLoaderData::is_permanent_class_loader_data() const { |
720 bool ClassLoaderData::is_permanent_class_loader_data() const { |
721 return is_builtin_class_loader_data() && !is_anonymous(); |
721 return is_builtin_class_loader_data() && !is_anonymous(); |
722 } |
722 } |
723 |
723 |
724 Metaspace* ClassLoaderData::metaspace_non_null() { |
724 ClassLoaderMetaspace* ClassLoaderData::metaspace_non_null() { |
725 // If the metaspace has not been allocated, create a new one. Might want |
725 // If the metaspace has not been allocated, create a new one. Might want |
726 // to create smaller arena for Reflection class loaders also. |
726 // to create smaller arena for Reflection class loaders also. |
727 // The reason for the delayed allocation is because some class loaders are |
727 // The reason for the delayed allocation is because some class loaders are |
728 // simply for delegating with no metadata of their own. |
728 // simply for delegating with no metadata of their own. |
729 // Lock-free access requires load_acquire. |
729 // Lock-free access requires load_acquire. |
730 Metaspace* metaspace = OrderAccess::load_acquire(&_metaspace); |
730 ClassLoaderMetaspace* metaspace = OrderAccess::load_acquire(&_metaspace); |
731 if (metaspace == NULL) { |
731 if (metaspace == NULL) { |
732 MutexLockerEx ml(_metaspace_lock, Mutex::_no_safepoint_check_flag); |
732 MutexLockerEx ml(_metaspace_lock, Mutex::_no_safepoint_check_flag); |
733 // Check if _metaspace got allocated while we were waiting for this lock. |
733 // Check if _metaspace got allocated while we were waiting for this lock. |
734 if ((metaspace = _metaspace) == NULL) { |
734 if ((metaspace = _metaspace) == NULL) { |
735 if (this == the_null_class_loader_data()) { |
735 if (this == the_null_class_loader_data()) { |
736 assert (class_loader() == NULL, "Must be"); |
736 assert (class_loader() == NULL, "Must be"); |
737 metaspace = new Metaspace(_metaspace_lock, Metaspace::BootMetaspaceType); |
737 metaspace = new ClassLoaderMetaspace(_metaspace_lock, Metaspace::BootMetaspaceType); |
738 } else if (is_anonymous()) { |
738 } else if (is_anonymous()) { |
739 metaspace = new Metaspace(_metaspace_lock, Metaspace::AnonymousMetaspaceType); |
739 metaspace = new ClassLoaderMetaspace(_metaspace_lock, Metaspace::AnonymousMetaspaceType); |
740 } else if (class_loader()->is_a(SystemDictionary::reflect_DelegatingClassLoader_klass())) { |
740 } else if (class_loader()->is_a(SystemDictionary::reflect_DelegatingClassLoader_klass())) { |
741 metaspace = new Metaspace(_metaspace_lock, Metaspace::ReflectionMetaspaceType); |
741 metaspace = new ClassLoaderMetaspace(_metaspace_lock, Metaspace::ReflectionMetaspaceType); |
742 } else { |
742 } else { |
743 metaspace = new Metaspace(_metaspace_lock, Metaspace::StandardMetaspaceType); |
743 metaspace = new ClassLoaderMetaspace(_metaspace_lock, Metaspace::StandardMetaspaceType); |
744 } |
744 } |
745 // Ensure _metaspace is stable, since it is examined without a lock |
745 // Ensure _metaspace is stable, since it is examined without a lock |
746 OrderAccess::release_store(&_metaspace, metaspace); |
746 OrderAccess::release_store(&_metaspace, metaspace); |
747 } |
747 } |
748 } |
748 } |