src/hotspot/share/classfile/classLoaderData.cpp
changeset 49401 0c71baee49a7
parent 49393 93fe2fc5c093
child 49403 58fdb6c2a274
equal deleted inserted replaced
49400:d2dd7e7d2044 49401:0c71baee49a7
   665     _unnamed_module->delete_unnamed_module();
   665     _unnamed_module->delete_unnamed_module();
   666     _unnamed_module = NULL;
   666     _unnamed_module = NULL;
   667   }
   667   }
   668 
   668 
   669   // release the metaspace
   669   // release the metaspace
   670   Metaspace *m = _metaspace;
   670   ClassLoaderMetaspace *m = _metaspace;
   671   if (m != NULL) {
   671   if (m != NULL) {
   672     _metaspace = NULL;
   672     _metaspace = NULL;
   673     delete m;
   673     delete m;
   674   }
   674   }
   675   // Clear all the JNI handles for methods
   675   // Clear all the JNI handles for methods
   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   }
  1178 }
  1178 }
  1179 
  1179 
  1180 bool ClassLoaderDataGraph::unload_list_contains(const void* x) {
  1180 bool ClassLoaderDataGraph::unload_list_contains(const void* x) {
  1181   assert(SafepointSynchronize::is_at_safepoint(), "only safe to call at safepoint");
  1181   assert(SafepointSynchronize::is_at_safepoint(), "only safe to call at safepoint");
  1182   for (ClassLoaderData* cld = _unloading; cld != NULL; cld = cld->next()) {
  1182   for (ClassLoaderData* cld = _unloading; cld != NULL; cld = cld->next()) {
  1183     if (cld->metaspace_or_null() != NULL && cld->metaspace_or_null()->contains(x)) {
  1183     // Needs fixing, see JDK-8199007.
       
  1184     if (cld->metaspace_or_null() != NULL && Metaspace::contains(x)) {
  1184       return true;
  1185       return true;
  1185     }
  1186     }
  1186   }
  1187   }
  1187   return false;
  1188   return false;
  1188 }
  1189 }