< prev index next >

src/hotspot/share/classfile/systemDictionaryShared.cpp

Print this page

  42 #include "classfile/classLoaderExt.hpp"
  43 #include "classfile/dictionary.hpp"
  44 #include "classfile/javaClasses.hpp"
  45 #include "classfile/javaClasses.inline.hpp"
  46 #include "classfile/symbolTable.hpp"
  47 #include "classfile/systemDictionary.hpp"
  48 #include "classfile/systemDictionaryShared.hpp"
  49 #include "classfile/verificationType.hpp"
  50 #include "classfile/vmClasses.hpp"
  51 #include "classfile/vmSymbols.hpp"
  52 #include "interpreter/bootstrapInfo.hpp"
  53 #include "jfr/jfrEvents.hpp"
  54 #include "logging/log.hpp"
  55 #include "logging/logStream.hpp"
  56 #include "memory/allocation.hpp"
  57 #include "memory/metadataFactory.hpp"
  58 #include "memory/metaspaceClosure.hpp"
  59 #include "memory/oopFactory.hpp"
  60 #include "memory/resourceArea.hpp"
  61 #include "memory/universe.hpp"

  62 #include "oops/instanceKlass.hpp"
  63 #include "oops/klass.inline.hpp"
  64 #include "oops/objArrayKlass.hpp"
  65 #include "oops/objArrayOop.inline.hpp"
  66 #include "oops/oop.inline.hpp"
  67 #include "oops/oopHandle.inline.hpp"
  68 #include "oops/typeArrayOop.inline.hpp"
  69 #include "runtime/arguments.hpp"
  70 #include "runtime/handles.inline.hpp"
  71 #include "runtime/java.hpp"
  72 #include "runtime/javaCalls.hpp"
  73 #include "runtime/mutexLocker.hpp"
  74 #include "utilities/resourceHash.hpp"
  75 #include "utilities/stringUtils.hpp"
  76 
  77 SystemDictionaryShared::ArchiveInfo SystemDictionaryShared::_static_archive;
  78 SystemDictionaryShared::ArchiveInfo SystemDictionaryShared::_dynamic_archive;
  79 
  80 DumpTimeSharedClassTable* SystemDictionaryShared::_dumptime_table = nullptr;
  81 DumpTimeLambdaProxyClassDictionary* SystemDictionaryShared::_dumptime_lambda_proxy_class_dictionary = nullptr;

 404 
 405       // Note: currently, find_or_load_shared_class is called only from
 406       // JVM_FindLoadedClass and used for PlatformClassLoader and AppClassLoader,
 407       // which are parallel-capable loaders, so a lock here is NOT taken.
 408       assert(get_loader_lock_or_null(class_loader) == nullptr, "ObjectLocker not required");
 409       {
 410         MutexLocker mu(THREAD, SystemDictionary_lock);
 411         InstanceKlass* check = dictionary->find_class(THREAD, name);
 412         if (check != nullptr) {
 413           return check;
 414         }
 415       }
 416 
 417       k = load_shared_class_for_builtin_loader(name, class_loader, THREAD);
 418       if (k != nullptr) {
 419         SharedClassLoadingMark slm(THREAD, k);
 420         k = find_or_define_instance_class(name, class_loader, k, CHECK_NULL);
 421       }
 422     }
 423   }







 424   return k;
 425 }
 426 
 427 class UnregisteredClassesTable : public ResourceHashtable<
 428   Symbol*, InstanceKlass*,
 429   15889, // prime number
 430   AnyObj::C_HEAP> {};
 431 
 432 static UnregisteredClassesTable* _unregistered_classes_table = nullptr;
 433 
 434 // true == class was successfully added; false == a duplicated class (with the same name) already exists.
 435 bool SystemDictionaryShared::add_unregistered_class(Thread* current, InstanceKlass* klass) {
 436   // We don't allow duplicated unregistered classes with the same name.
 437   // We only archive the first class with that name that succeeds putting
 438   // itself into the table.
 439   assert(CDSConfig::is_dumping_archive() || ClassListWriter::is_enabled(), "sanity");
 440   MutexLocker ml(current, UnregisteredClassesTable_lock, Mutex::_no_safepoint_check_flag);
 441   Symbol* name = klass->name();
 442   if (_unregistered_classes_table == nullptr) {
 443     _unregistered_classes_table = new (mtClass)UnregisteredClassesTable();

1313 
1314   if (!MetaspaceShared::is_shared_dynamic(name)) {
1315     // The names of all shared classes in the static dict must also be in the
1316     // static archive
1317     record = static_dict->lookup(name, hash, 0);
1318   }
1319 
1320   if (record == nullptr && DynamicArchive::is_mapped()) {
1321     record = dynamic_dict->lookup(name, hash, 0);
1322   }
1323 
1324   return record;
1325 }
1326 
1327 InstanceKlass* SystemDictionaryShared::find_builtin_class(Symbol* name) {
1328   const RunTimeClassInfo* record = find_record(&_static_archive._builtin_dictionary,
1329                                                &_dynamic_archive._builtin_dictionary,
1330                                                name);
1331   if (record != nullptr) {
1332     assert(!record->_klass->is_hidden(), "hidden class cannot be looked up by name");
1333     assert(check_alignment(record->_klass), "Address not aligned");




1334     // We did not save the classfile data of the generated LambdaForm invoker classes,
1335     // so we cannot support CLFH for such classes.
1336     if (record->_klass->is_generated_shared_class() && JvmtiExport::should_post_class_file_load_hook()) {
1337        return nullptr;
1338     }
1339     return record->_klass;
1340   } else {
1341     return nullptr;
1342   }
1343 }
1344 
1345 void SystemDictionaryShared::update_shared_entry(InstanceKlass* k, int id) {
1346   assert(CDSConfig::is_dumping_static_archive(), "class ID is used only for static dump (from classlist)");
1347   DumpTimeClassInfo* info = get_info(k);
1348   info->_id = id;
1349 }
1350 
1351 static const char* class_loader_name_for_shared(Klass* k) {
1352   assert(k != nullptr, "Sanity");
1353   assert(k->is_shared(), "Must be");

  42 #include "classfile/classLoaderExt.hpp"
  43 #include "classfile/dictionary.hpp"
  44 #include "classfile/javaClasses.hpp"
  45 #include "classfile/javaClasses.inline.hpp"
  46 #include "classfile/symbolTable.hpp"
  47 #include "classfile/systemDictionary.hpp"
  48 #include "classfile/systemDictionaryShared.hpp"
  49 #include "classfile/verificationType.hpp"
  50 #include "classfile/vmClasses.hpp"
  51 #include "classfile/vmSymbols.hpp"
  52 #include "interpreter/bootstrapInfo.hpp"
  53 #include "jfr/jfrEvents.hpp"
  54 #include "logging/log.hpp"
  55 #include "logging/logStream.hpp"
  56 #include "memory/allocation.hpp"
  57 #include "memory/metadataFactory.hpp"
  58 #include "memory/metaspaceClosure.hpp"
  59 #include "memory/oopFactory.hpp"
  60 #include "memory/resourceArea.hpp"
  61 #include "memory/universe.hpp"
  62 #include "oops/compressedKlass.inline.hpp"
  63 #include "oops/instanceKlass.hpp"
  64 #include "oops/klass.inline.hpp"
  65 #include "oops/objArrayKlass.hpp"
  66 #include "oops/objArrayOop.inline.hpp"
  67 #include "oops/oop.inline.hpp"
  68 #include "oops/oopHandle.inline.hpp"
  69 #include "oops/typeArrayOop.inline.hpp"
  70 #include "runtime/arguments.hpp"
  71 #include "runtime/handles.inline.hpp"
  72 #include "runtime/java.hpp"
  73 #include "runtime/javaCalls.hpp"
  74 #include "runtime/mutexLocker.hpp"
  75 #include "utilities/resourceHash.hpp"
  76 #include "utilities/stringUtils.hpp"
  77 
  78 SystemDictionaryShared::ArchiveInfo SystemDictionaryShared::_static_archive;
  79 SystemDictionaryShared::ArchiveInfo SystemDictionaryShared::_dynamic_archive;
  80 
  81 DumpTimeSharedClassTable* SystemDictionaryShared::_dumptime_table = nullptr;
  82 DumpTimeLambdaProxyClassDictionary* SystemDictionaryShared::_dumptime_lambda_proxy_class_dictionary = nullptr;

 405 
 406       // Note: currently, find_or_load_shared_class is called only from
 407       // JVM_FindLoadedClass and used for PlatformClassLoader and AppClassLoader,
 408       // which are parallel-capable loaders, so a lock here is NOT taken.
 409       assert(get_loader_lock_or_null(class_loader) == nullptr, "ObjectLocker not required");
 410       {
 411         MutexLocker mu(THREAD, SystemDictionary_lock);
 412         InstanceKlass* check = dictionary->find_class(THREAD, name);
 413         if (check != nullptr) {
 414           return check;
 415         }
 416       }
 417 
 418       k = load_shared_class_for_builtin_loader(name, class_loader, THREAD);
 419       if (k != nullptr) {
 420         SharedClassLoadingMark slm(THREAD, k);
 421         k = find_or_define_instance_class(name, class_loader, k, CHECK_NULL);
 422       }
 423     }
 424   }
 425 
 426 #ifdef ASSERT
 427     if (UseCompressedClassPointers && k != nullptr) {
 428       CompressedKlassPointers::check_valid_klass(k);
 429     }
 430 #endif
 431 
 432   return k;
 433 }
 434 
 435 class UnregisteredClassesTable : public ResourceHashtable<
 436   Symbol*, InstanceKlass*,
 437   15889, // prime number
 438   AnyObj::C_HEAP> {};
 439 
 440 static UnregisteredClassesTable* _unregistered_classes_table = nullptr;
 441 
 442 // true == class was successfully added; false == a duplicated class (with the same name) already exists.
 443 bool SystemDictionaryShared::add_unregistered_class(Thread* current, InstanceKlass* klass) {
 444   // We don't allow duplicated unregistered classes with the same name.
 445   // We only archive the first class with that name that succeeds putting
 446   // itself into the table.
 447   assert(CDSConfig::is_dumping_archive() || ClassListWriter::is_enabled(), "sanity");
 448   MutexLocker ml(current, UnregisteredClassesTable_lock, Mutex::_no_safepoint_check_flag);
 449   Symbol* name = klass->name();
 450   if (_unregistered_classes_table == nullptr) {
 451     _unregistered_classes_table = new (mtClass)UnregisteredClassesTable();

1321 
1322   if (!MetaspaceShared::is_shared_dynamic(name)) {
1323     // The names of all shared classes in the static dict must also be in the
1324     // static archive
1325     record = static_dict->lookup(name, hash, 0);
1326   }
1327 
1328   if (record == nullptr && DynamicArchive::is_mapped()) {
1329     record = dynamic_dict->lookup(name, hash, 0);
1330   }
1331 
1332   return record;
1333 }
1334 
1335 InstanceKlass* SystemDictionaryShared::find_builtin_class(Symbol* name) {
1336   const RunTimeClassInfo* record = find_record(&_static_archive._builtin_dictionary,
1337                                                &_dynamic_archive._builtin_dictionary,
1338                                                name);
1339   if (record != nullptr) {
1340     assert(!record->_klass->is_hidden(), "hidden class cannot be looked up by name");
1341 #ifdef _LP64
1342     if (UseCompressedClassPointers) {
1343       DEBUG_ONLY(CompressedKlassPointers::check_valid_klass(record->_klass);)
1344     }
1345 #endif
1346     // We did not save the classfile data of the generated LambdaForm invoker classes,
1347     // so we cannot support CLFH for such classes.
1348     if (record->_klass->is_generated_shared_class() && JvmtiExport::should_post_class_file_load_hook()) {
1349        return nullptr;
1350     }
1351     return record->_klass;
1352   } else {
1353     return nullptr;
1354   }
1355 }
1356 
1357 void SystemDictionaryShared::update_shared_entry(InstanceKlass* k, int id) {
1358   assert(CDSConfig::is_dumping_static_archive(), "class ID is used only for static dump (from classlist)");
1359   DumpTimeClassInfo* info = get_info(k);
1360   info->_id = id;
1361 }
1362 
1363 static const char* class_loader_name_for_shared(Klass* k) {
1364   assert(k != nullptr, "Sanity");
1365   assert(k->is_shared(), "Must be");
< prev index next >