mirror of
https://github.com/openjdk/jdk.git
synced 2026-01-28 12:09:14 +00:00
8357504: Refactor the assignment of loader bits in InstanceKlassFlags
Reviewed-by: matsaave, ccheung
This commit is contained in:
parent
ee6891456e
commit
3bebb1fa76
@ -240,7 +240,7 @@ void AOTArtifactFinder::add_cached_instance_class(InstanceKlass* ik) {
|
||||
add_cached_instance_class(intf);
|
||||
}
|
||||
|
||||
if (CDSConfig::is_dumping_final_static_archive() && ik->is_shared_unregistered_class()) {
|
||||
if (CDSConfig::is_dumping_final_static_archive() && ik->defined_by_other_loaders()) {
|
||||
// The following are not appliable to unregistered classes
|
||||
return;
|
||||
}
|
||||
|
||||
@ -137,7 +137,7 @@ bool AOTClassLinker::try_add_candidate(InstanceKlass* ik) {
|
||||
}
|
||||
|
||||
if (ik->is_hidden()) {
|
||||
assert(ik->shared_class_loader_type() != ClassLoader::OTHER, "must have been set");
|
||||
assert(!ik->defined_by_other_loaders(), "hidden classes are archived only for builtin loaders");
|
||||
if (!CDSConfig::is_dumping_method_handles()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -372,7 +372,7 @@ bool AOTLinkedClassBulkLoader::is_pending_aot_linked_class(Klass* k) {
|
||||
// the four AOTLinkedClassCategory of classes that can be aot-linked.
|
||||
|
||||
InstanceKlass* ik = InstanceKlass::cast(k);
|
||||
if (ik->is_shared_boot_class()) {
|
||||
if (ik->defined_by_boot_loader()) {
|
||||
if (ik->module() != nullptr && ik->in_javabase_module()) {
|
||||
// AOTLinkedClassCategory::BOOT1 -- all aot-linked classes in
|
||||
// java.base must have been loaded before a GC can ever happen.
|
||||
@ -382,11 +382,11 @@ bool AOTLinkedClassBulkLoader::is_pending_aot_linked_class(Klass* k) {
|
||||
// module system is ready.
|
||||
return !_boot2_completed;
|
||||
}
|
||||
} else if (ik->is_shared_platform_class()) {
|
||||
} else if (ik->defined_by_platform_loader()) {
|
||||
// AOTLinkedClassCategory::PLATFORM classes cannot be loaded until
|
||||
// the platform class loader is initialized.
|
||||
return !_platform_completed;
|
||||
} else if (ik->is_shared_app_class()) {
|
||||
} else if (ik->defined_by_app_loader()) {
|
||||
// AOTLinkedClassCategory::APP cannot be loaded until the app class loader
|
||||
// is initialized.
|
||||
return !_app_completed;
|
||||
|
||||
@ -834,10 +834,6 @@ void ArchiveBuilder::make_klasses_shareable() {
|
||||
bool aotlinked = AOTClassLinker::is_candidate(src_ik);
|
||||
inited = ik->has_aot_initialized_mirror();
|
||||
ADD_COUNT(num_instance_klasses);
|
||||
if (CDSConfig::is_dumping_dynamic_archive()) {
|
||||
// For static dump, class loader type are already set.
|
||||
ik->assign_class_loader_type();
|
||||
}
|
||||
if (ik->is_hidden()) {
|
||||
ADD_COUNT(num_hidden_klasses);
|
||||
hidden = " hidden";
|
||||
@ -861,17 +857,17 @@ void ArchiveBuilder::make_klasses_shareable() {
|
||||
// Legacy CDS support for lambda proxies
|
||||
CDS_JAVA_HEAP_ONLY(assert(HeapShared::is_lambda_proxy_klass(ik), "sanity");)
|
||||
}
|
||||
} else if (ik->is_shared_boot_class()) {
|
||||
} else if (ik->defined_by_boot_loader()) {
|
||||
type = "boot";
|
||||
ADD_COUNT(num_boot_klasses);
|
||||
} else if (ik->is_shared_platform_class()) {
|
||||
} else if (ik->defined_by_platform_loader()) {
|
||||
type = "plat";
|
||||
ADD_COUNT(num_platform_klasses);
|
||||
} else if (ik->is_shared_app_class()) {
|
||||
} else if (ik->defined_by_app_loader()) {
|
||||
type = "app";
|
||||
ADD_COUNT(num_app_klasses);
|
||||
} else {
|
||||
assert(ik->is_shared_unregistered_class(), "must be");
|
||||
assert(ik->defined_by_other_loaders(), "must be");
|
||||
type = "unreg";
|
||||
ADD_COUNT(num_unregistered_klasses);
|
||||
}
|
||||
@ -883,11 +879,11 @@ void ArchiveBuilder::make_klasses_shareable() {
|
||||
if (!ik->is_linked()) {
|
||||
num_unlinked_klasses ++;
|
||||
unlinked = " unlinked";
|
||||
if (ik->is_shared_boot_class()) {
|
||||
if (ik->defined_by_boot_loader()) {
|
||||
boot_unlinked ++;
|
||||
} else if (ik->is_shared_platform_class()) {
|
||||
} else if (ik->defined_by_platform_loader()) {
|
||||
platform_unlinked ++;
|
||||
} else if (ik->is_shared_app_class()) {
|
||||
} else if (ik->defined_by_app_loader()) {
|
||||
app_unlinked ++;
|
||||
} else {
|
||||
unreg_unlinked ++;
|
||||
|
||||
@ -120,7 +120,7 @@ PackageEntry* CDSProtectionDomain::get_package_entry_from_class(InstanceKlass* i
|
||||
PackageEntry* pkg_entry = ik->package();
|
||||
if (CDSConfig::is_using_full_module_graph() && ik->is_shared() && pkg_entry != nullptr) {
|
||||
assert(MetaspaceShared::is_in_shared_metaspace(pkg_entry), "must be");
|
||||
assert(!ik->is_shared_unregistered_class(), "unexpected archived package entry for an unregistered class");
|
||||
assert(!ik->defined_by_other_loaders(), "unexpected archived package entry for an unregistered class");
|
||||
assert(ik->module()->is_named(), "unexpected archived package entry for a class in an unnamed module");
|
||||
return pkg_entry;
|
||||
}
|
||||
|
||||
@ -511,7 +511,7 @@ void ClassListParser::constant_pool_resolution_warning(const char* msg, ...) {
|
||||
// S2 will be incorrectly used as the supertype of U instead of S1 due to
|
||||
// limitations in the loading mechanism of unregistered classes.
|
||||
void ClassListParser::check_supertype_obstruction(int specified_supertype_id, const InstanceKlass* specified_supertype, TRAPS) {
|
||||
if (specified_supertype->is_shared_unregistered_class()) {
|
||||
if (specified_supertype->defined_by_other_loaders()) {
|
||||
return; // Only registered supertypes can be obstructed
|
||||
}
|
||||
const InstanceKlass* obstructor = SystemDictionaryShared::get_unregistered_class(specified_supertype->name());
|
||||
@ -582,7 +582,7 @@ InstanceKlass* ClassListParser::load_class_from_source(Symbol* class_name, TRAPS
|
||||
}
|
||||
}
|
||||
|
||||
assert(k->is_shared_unregistered_class(), "must be");
|
||||
assert(k->defined_by_other_loaders(), "must be");
|
||||
|
||||
bool added = SystemDictionaryShared::add_unregistered_class(THREAD, k);
|
||||
if (!added) {
|
||||
|
||||
@ -46,7 +46,7 @@ void DumpTimeSharedClassTable::iterate_all_live_classes(Function function) const
|
||||
assert(SafepointSynchronize::is_at_safepoint(), "invariant");
|
||||
assert_lock_strong(DumpTimeTable_lock);
|
||||
if (CDSConfig::is_dumping_final_static_archive() && !k->is_loaded()) {
|
||||
assert(k->is_shared_unregistered_class(), "must be");
|
||||
assert(k->defined_by_other_loaders(), "must be");
|
||||
function(k, info);
|
||||
} else if (k->is_loader_alive()) {
|
||||
function(k, info);
|
||||
|
||||
@ -173,7 +173,7 @@ void FinalImageRecipes::load_all_classes(TRAPS) {
|
||||
Klass* k = _all_klasses->at(i);
|
||||
if (k->is_instance_klass()) {
|
||||
InstanceKlass* ik = InstanceKlass::cast(k);
|
||||
if (ik->is_shared_unregistered_class()) {
|
||||
if (ik->defined_by_other_loaders()) {
|
||||
SystemDictionaryShared::init_dumptime_info(ik);
|
||||
SystemDictionaryShared::add_unregistered_class(THREAD, ik);
|
||||
SystemDictionaryShared::copy_unregistered_class_size_and_crc32(ik);
|
||||
|
||||
@ -803,7 +803,7 @@ void KlassSubGraphInfo::add_subgraph_object_klass(Klass* orig_k) {
|
||||
} else if (orig_k->is_objArray_klass()) {
|
||||
Klass* abk = ObjArrayKlass::cast(orig_k)->bottom_klass();
|
||||
if (abk->is_instance_klass()) {
|
||||
assert(InstanceKlass::cast(abk)->is_shared_boot_class(),
|
||||
assert(InstanceKlass::cast(abk)->defined_by_boot_loader(),
|
||||
"must be boot class");
|
||||
check_allowed_klass(InstanceKlass::cast(ObjArrayKlass::cast(orig_k)->bottom_klass()));
|
||||
}
|
||||
@ -1097,7 +1097,7 @@ void HeapShared::resolve_classes_for_subgraphs(JavaThread* current, ArchivableSt
|
||||
ArchivableStaticFieldInfo* info = &fields[i];
|
||||
TempNewSymbol klass_name = SymbolTable::new_symbol(info->klass_name);
|
||||
InstanceKlass* k = SystemDictionaryShared::find_builtin_class(klass_name);
|
||||
assert(k != nullptr && k->is_shared_boot_class(), "sanity");
|
||||
assert(k != nullptr && k->defined_by_boot_loader(), "sanity");
|
||||
resolve_classes_for_subgraph_of(current, k);
|
||||
}
|
||||
}
|
||||
@ -1284,7 +1284,7 @@ void HeapShared::resolve_or_init(const char* klass_name, bool do_init, TRAPS) {
|
||||
if (k == nullptr) {
|
||||
return;
|
||||
}
|
||||
assert(k->is_shared_boot_class(), "sanity");
|
||||
assert(k->defined_by_boot_loader(), "sanity");
|
||||
resolve_or_init(k, false, CHECK);
|
||||
if (do_init) {
|
||||
resolve_or_init(k, true, CHECK);
|
||||
@ -1644,7 +1644,7 @@ void HeapShared::archive_reachable_objects_from_static_field(InstanceKlass *k,
|
||||
int field_offset,
|
||||
const char* field_name) {
|
||||
assert(CDSConfig::is_dumping_heap(), "dump time only");
|
||||
assert(k->is_shared_boot_class(), "must be boot class");
|
||||
assert(k->defined_by_boot_loader(), "must be boot class");
|
||||
|
||||
oop m = k->java_mirror();
|
||||
|
||||
@ -1695,7 +1695,7 @@ class VerifySharedOopClosure: public BasicOopIterateClosure {
|
||||
|
||||
void HeapShared::verify_subgraph_from_static_field(InstanceKlass* k, int field_offset) {
|
||||
assert(CDSConfig::is_dumping_heap(), "dump time only");
|
||||
assert(k->is_shared_boot_class(), "must be boot class");
|
||||
assert(k->defined_by_boot_loader(), "must be boot class");
|
||||
|
||||
oop m = k->java_mirror();
|
||||
oop f = m->obj_field(field_offset);
|
||||
@ -1869,7 +1869,7 @@ void HeapShared::init_subgraph_entry_fields(ArchivableStaticFieldInfo fields[],
|
||||
}
|
||||
|
||||
InstanceKlass* ik = InstanceKlass::cast(k);
|
||||
assert(InstanceKlass::cast(ik)->is_shared_boot_class(),
|
||||
assert(InstanceKlass::cast(ik)->defined_by_boot_loader(),
|
||||
"Only support boot classes");
|
||||
|
||||
if (is_test_class) {
|
||||
|
||||
@ -170,7 +170,6 @@ void LambdaProxyClassDictionary::add_lambda_proxy_class(InstanceKlass* caller_ik
|
||||
|
||||
MutexLocker ml(DumpTimeTable_lock, Mutex::_no_safepoint_check_flag);
|
||||
|
||||
lambda_ik->assign_class_loader_type();
|
||||
lambda_ik->set_shared_classpath_index(caller_ik->shared_classpath_index());
|
||||
InstanceKlass* nest_host = caller_ik->nest_host(CHECK);
|
||||
assert(nest_host != nullptr, "unexpected nullptr nest_host");
|
||||
|
||||
@ -733,7 +733,7 @@ bool MetaspaceShared::may_be_eagerly_linked(InstanceKlass* ik) {
|
||||
// linked/verified at runtime.
|
||||
return false;
|
||||
}
|
||||
if (CDSConfig::is_dumping_dynamic_archive() && ik->is_shared_unregistered_class()) {
|
||||
if (CDSConfig::is_dumping_dynamic_archive() && ik->defined_by_other_loaders()) {
|
||||
// Linking of unregistered classes at this stage may cause more
|
||||
// classes to be resolved, resulting in calls to ClassLoader.loadClass()
|
||||
// that may not be expected by custom class loaders.
|
||||
@ -1046,7 +1046,7 @@ bool MetaspaceShared::try_link_class(JavaThread* current, InstanceKlass* ik) {
|
||||
if (ik->is_loaded() && !ik->is_linked() && ik->can_be_verified_at_dumptime() &&
|
||||
!SystemDictionaryShared::has_class_failed_verification(ik)) {
|
||||
bool saved = BytecodeVerificationLocal;
|
||||
if (ik->is_shared_unregistered_class() && ik->class_loader() == nullptr) {
|
||||
if (ik->defined_by_other_loaders() && ik->class_loader() == nullptr) {
|
||||
// The verification decision is based on BytecodeVerificationRemote
|
||||
// for non-system classes. Since we are using the null classloader
|
||||
// to load non-system classes for customized class loaders during dumping,
|
||||
|
||||
@ -5015,6 +5015,7 @@ void ClassFileParser::fill_instance_klass(InstanceKlass* ik,
|
||||
|
||||
// Set name and CLD before adding to CLD
|
||||
ik->set_class_loader_data(_loader_data);
|
||||
ik->set_class_loader_type();
|
||||
ik->set_name(_class_name);
|
||||
|
||||
// Add all classes to our internal class loader list here,
|
||||
|
||||
@ -1195,7 +1195,6 @@ void ClassLoader::record_result(JavaThread* current, InstanceKlass* ik,
|
||||
if (loader == nullptr) {
|
||||
// JFR classes
|
||||
ik->set_shared_classpath_index(0);
|
||||
ik->set_shared_class_loader_type(ClassLoader::BOOT_LOADER);
|
||||
}
|
||||
return;
|
||||
}
|
||||
@ -1290,25 +1289,10 @@ void ClassLoader::record_result(JavaThread* current, InstanceKlass* ik,
|
||||
void ClassLoader::record_hidden_class(InstanceKlass* ik) {
|
||||
assert(ik->is_hidden(), "must be");
|
||||
|
||||
s2 classloader_type;
|
||||
if (HeapShared::is_lambda_form_klass(ik)) {
|
||||
classloader_type = ClassLoader::BOOT_LOADER;
|
||||
} else {
|
||||
oop loader = ik->class_loader();
|
||||
|
||||
if (loader == nullptr) {
|
||||
classloader_type = ClassLoader::BOOT_LOADER;
|
||||
} else if (SystemDictionary::is_platform_class_loader(loader)) {
|
||||
classloader_type = ClassLoader::PLATFORM_LOADER;
|
||||
} else if (SystemDictionary::is_system_class_loader(loader)) {
|
||||
classloader_type = ClassLoader::APP_LOADER;
|
||||
} else {
|
||||
// This class won't be archived, so no need to update its
|
||||
// classloader_type/classpath_index.
|
||||
return;
|
||||
}
|
||||
if (ik->defined_by_other_loaders()) {
|
||||
// We don't archive hidden classes for non-builtin loaders.
|
||||
return;
|
||||
}
|
||||
ik->set_shared_class_loader_type(classloader_type);
|
||||
|
||||
if (HeapShared::is_lambda_proxy_klass(ik)) {
|
||||
InstanceKlass* nest_host = ik->nest_host_not_null();
|
||||
@ -1317,7 +1301,7 @@ void ClassLoader::record_hidden_class(InstanceKlass* ik) {
|
||||
ik->set_shared_classpath_index(0);
|
||||
} else {
|
||||
// Generated invoker classes.
|
||||
if (classloader_type == ClassLoader::APP_LOADER) {
|
||||
if (ik->defined_by_app_loader()) {
|
||||
ik->set_shared_classpath_index(AOTClassLocationConfig::dumptime()->app_cp_start_index());
|
||||
} else {
|
||||
ik->set_shared_classpath_index(0);
|
||||
|
||||
@ -71,16 +71,12 @@ void ClassLoaderExt::record_result_for_builtin_loader(s2 classpath_index, Instan
|
||||
assert(CDSConfig::is_dumping_archive(), "sanity");
|
||||
|
||||
oop loader = result->class_loader();
|
||||
s2 classloader_type;
|
||||
if (SystemDictionary::is_system_class_loader(loader)) {
|
||||
classloader_type = ClassLoader::APP_LOADER;
|
||||
AOTClassLocationConfig::dumptime_set_has_app_classes();
|
||||
} else if (SystemDictionary::is_platform_class_loader(loader)) {
|
||||
classloader_type = ClassLoader::PLATFORM_LOADER;
|
||||
AOTClassLocationConfig::dumptime_set_has_platform_classes();
|
||||
} else {
|
||||
precond(loader == nullptr);
|
||||
classloader_type = ClassLoader::BOOT_LOADER;
|
||||
}
|
||||
|
||||
if (CDSConfig::is_dumping_preimage_static_archive() || CDSConfig::is_dumping_dynamic_archive()) {
|
||||
@ -91,10 +87,9 @@ void ClassLoaderExt::record_result_for_builtin_loader(s2 classpath_index, Instan
|
||||
|
||||
AOTClassLocationConfig::dumptime_update_max_used_index(classpath_index);
|
||||
result->set_shared_classpath_index(classpath_index);
|
||||
result->set_shared_class_loader_type(classloader_type);
|
||||
|
||||
#if INCLUDE_CDS_JAVA_HEAP
|
||||
if (CDSConfig::is_dumping_heap() && AllowArchivingWithJavaAgent && classloader_type == ClassLoader::BOOT_LOADER &&
|
||||
if (CDSConfig::is_dumping_heap() && AllowArchivingWithJavaAgent && result->defined_by_boot_loader() &&
|
||||
classpath_index < 0 && redefined) {
|
||||
// When dumping the heap (which happens only during static dump), classes for the built-in
|
||||
// loaders are always loaded from known locations (jimage, classpath or modulepath),
|
||||
|
||||
@ -98,7 +98,6 @@ InstanceKlass* KlassFactory::check_shared_class_file_load_hook(
|
||||
|
||||
if (class_loader.is_null()) {
|
||||
new_ik->set_classpath_index(path_index);
|
||||
new_ik->assign_class_loader_type();
|
||||
}
|
||||
|
||||
return new_ik;
|
||||
|
||||
@ -923,15 +923,15 @@ bool SystemDictionary::is_shared_class_visible(Symbol* class_name,
|
||||
|
||||
// (1) Check if we are loading into the same loader as in dump time.
|
||||
|
||||
if (ik->is_shared_boot_class()) {
|
||||
if (ik->defined_by_boot_loader()) {
|
||||
if (class_loader() != nullptr) {
|
||||
return false;
|
||||
}
|
||||
} else if (ik->is_shared_platform_class()) {
|
||||
} else if (ik->defined_by_platform_loader()) {
|
||||
if (class_loader() != java_platform_loader()) {
|
||||
return false;
|
||||
}
|
||||
} else if (ik->is_shared_app_class()) {
|
||||
} else if (ik->defined_by_app_loader()) {
|
||||
if (class_loader() != java_system_loader()) {
|
||||
return false;
|
||||
}
|
||||
@ -961,7 +961,7 @@ bool SystemDictionary::is_shared_class_visible_impl(Symbol* class_name,
|
||||
PackageEntry* pkg_entry,
|
||||
Handle class_loader) {
|
||||
int scp_index = ik->shared_classpath_index();
|
||||
assert(!ik->is_shared_unregistered_class(), "this function should be called for built-in classes only");
|
||||
assert(!ik->defined_by_other_loaders(), "this function should be called for built-in classes only");
|
||||
assert(scp_index >= 0, "must be");
|
||||
const AOTClassLocation* cl = AOTClassLocationConfig::runtime()->class_location_at(scp_index);
|
||||
if (!Universe::is_module_initialized()) {
|
||||
@ -1023,7 +1023,7 @@ bool SystemDictionary::check_shared_class_super_type(InstanceKlass* klass, Insta
|
||||
// + Don't do it for unregistered classes -- they can be unloaded so
|
||||
// super_type->class_loader_data() could be stale.
|
||||
// + Don't check if loader data is null, ie. the super_type isn't fully loaded.
|
||||
if (!super_type->is_shared_unregistered_class() && super_type->class_loader_data() != nullptr) {
|
||||
if (!super_type->defined_by_other_loaders() && super_type->class_loader_data() != nullptr) {
|
||||
// Check if the superclass is loaded by the current class_loader
|
||||
Symbol* name = super_type->name();
|
||||
InstanceKlass* check = find_instance_klass(THREAD, name, class_loader);
|
||||
@ -1226,7 +1226,7 @@ InstanceKlass* SystemDictionary::load_instance_class_impl(Symbol* class_name, Ha
|
||||
{
|
||||
PerfTraceTime vmtimer(ClassLoader::perf_shared_classload_time());
|
||||
InstanceKlass* ik = SystemDictionaryShared::find_builtin_class(class_name);
|
||||
if (ik != nullptr && ik->is_shared_boot_class() && !ik->shared_loading_failed()) {
|
||||
if (ik != nullptr && ik->defined_by_boot_loader() && !ik->shared_loading_failed()) {
|
||||
SharedClassLoadingMark slm(THREAD, ik);
|
||||
k = load_shared_class(ik, class_loader, Handle(), nullptr, pkg_entry, CHECK_NULL);
|
||||
}
|
||||
|
||||
@ -103,8 +103,8 @@ InstanceKlass* SystemDictionaryShared::load_shared_class_for_builtin_loader(
|
||||
InstanceKlass* ik = find_builtin_class(class_name);
|
||||
|
||||
if (ik != nullptr && !ik->shared_loading_failed()) {
|
||||
if ((SystemDictionary::is_system_class_loader(class_loader()) && ik->is_shared_app_class()) ||
|
||||
(SystemDictionary::is_platform_class_loader(class_loader()) && ik->is_shared_platform_class())) {
|
||||
if ((SystemDictionary::is_system_class_loader(class_loader()) && ik->defined_by_app_loader()) ||
|
||||
(SystemDictionary::is_platform_class_loader(class_loader()) && ik->defined_by_platform_loader())) {
|
||||
SharedClassLoadingMark slm(THREAD, ik);
|
||||
PackageEntry* pkg_entry = CDSProtectionDomain::get_package_entry_from_class(ik, class_loader);
|
||||
Handle protection_domain =
|
||||
@ -250,7 +250,7 @@ bool SystemDictionaryShared::is_early_klass(InstanceKlass* ik) {
|
||||
}
|
||||
|
||||
bool SystemDictionaryShared::check_for_exclusion_impl(InstanceKlass* k) {
|
||||
if (CDSConfig::is_dumping_final_static_archive() && k->is_shared_unregistered_class()
|
||||
if (CDSConfig::is_dumping_final_static_archive() && k->defined_by_other_loaders()
|
||||
&& k->is_shared()) {
|
||||
return false; // Do not exclude: unregistered classes are passed from preimage to final image.
|
||||
}
|
||||
@ -592,11 +592,11 @@ void SystemDictionaryShared::validate_before_archiving(InstanceKlass* k) {
|
||||
assert(LambdaProxyClassDictionary::is_registered_lambda_proxy_class(k), "unexpected hidden class %s", name);
|
||||
}
|
||||
}
|
||||
guarantee(!k->is_shared_unregistered_class(),
|
||||
guarantee(!k->defined_by_other_loaders(),
|
||||
"Class loader type must be set for BUILTIN class %s", name);
|
||||
|
||||
} else {
|
||||
guarantee(k->is_shared_unregistered_class(),
|
||||
guarantee(k->defined_by_other_loaders(),
|
||||
"Class loader type must not be set for UNREGISTERED class %s", name);
|
||||
}
|
||||
}
|
||||
@ -754,7 +754,7 @@ void SystemDictionaryShared::dumptime_classes_do(MetaspaceClosure* it) {
|
||||
|
||||
auto do_klass = [&] (InstanceKlass* k, DumpTimeClassInfo& info) {
|
||||
if (CDSConfig::is_dumping_final_static_archive() && !k->is_loaded()) {
|
||||
assert(k->is_shared_unregistered_class(), "must be");
|
||||
assert(k->defined_by_other_loaders(), "must be");
|
||||
info.metaspace_pointers_do(it);
|
||||
} else if (k->is_loader_alive() && !info.is_excluded()) {
|
||||
info.metaspace_pointers_do(it);
|
||||
@ -940,11 +940,11 @@ void SystemDictionaryShared::record_linking_constraint(Symbol* name, InstanceKla
|
||||
bool SystemDictionaryShared::check_linking_constraints(Thread* current, InstanceKlass* klass) {
|
||||
assert(CDSConfig::is_using_archive(), "called at run time with CDS enabled only");
|
||||
LogTarget(Info, class, loader, constraints) log;
|
||||
if (klass->is_shared_boot_class()) {
|
||||
if (klass->defined_by_boot_loader()) {
|
||||
// No class loader constraint check performed for boot classes.
|
||||
return true;
|
||||
}
|
||||
if (klass->is_shared_platform_class() || klass->is_shared_app_class()) {
|
||||
if (klass->defined_by_platform_loader() || klass->defined_by_app_loader()) {
|
||||
RunTimeClassInfo* info = RunTimeClassInfo::get_for(klass);
|
||||
assert(info != nullptr, "Sanity");
|
||||
if (info->num_loader_constraints() > 0) {
|
||||
@ -987,7 +987,7 @@ bool SystemDictionaryShared::check_linking_constraints(Thread* current, Instance
|
||||
void SystemDictionaryShared::copy_linking_constraints_from_preimage(InstanceKlass* klass) {
|
||||
assert(CDSConfig::is_using_archive(), "called at run time with CDS enabled only");
|
||||
JavaThread* current = JavaThread::current();
|
||||
if (klass->is_shared_platform_class() || klass->is_shared_app_class()) {
|
||||
if (klass->defined_by_platform_loader() || klass->defined_by_app_loader()) {
|
||||
RunTimeClassInfo* rt_info = RunTimeClassInfo::get_for(klass); // from preimage
|
||||
|
||||
if (rt_info->num_loader_constraints() > 0) {
|
||||
@ -1155,13 +1155,13 @@ const char* SystemDictionaryShared::loader_type_for_shared_class(Klass* k) {
|
||||
assert(k->is_shared(), "Must be");
|
||||
assert(k->is_instance_klass(), "Must be");
|
||||
InstanceKlass* ik = InstanceKlass::cast(k);
|
||||
if (ik->is_shared_boot_class()) {
|
||||
if (ik->defined_by_boot_loader()) {
|
||||
return "boot_loader";
|
||||
} else if (ik->is_shared_platform_class()) {
|
||||
} else if (ik->defined_by_platform_loader()) {
|
||||
return "platform_loader";
|
||||
} else if (ik->is_shared_app_class()) {
|
||||
} else if (ik->defined_by_app_loader()) {
|
||||
return "app_loader";
|
||||
} else if (ik->is_shared_unregistered_class()) {
|
||||
} else if (ik->defined_by_other_loaders()) {
|
||||
return "unregistered_loader";
|
||||
} else {
|
||||
return "unknown loader";
|
||||
|
||||
@ -81,7 +81,7 @@ bool vmClasses::resolve(vmClassID id, TRAPS) {
|
||||
#if INCLUDE_CDS
|
||||
if (CDSConfig::is_using_archive() && !JvmtiExport::should_post_class_prepare()) {
|
||||
InstanceKlass* k = *klassp;
|
||||
assert(k->is_shared_boot_class(), "must be");
|
||||
assert(k->defined_by_boot_loader(), "must be");
|
||||
|
||||
ClassLoaderData* loader_data = ClassLoaderData::the_null_class_loader_data();
|
||||
resolve_shared_class(k, loader_data, Handle(), CHECK_false);
|
||||
|
||||
@ -446,7 +446,7 @@ void ConstantPool::remove_unshareable_info() {
|
||||
if (CDSConfig::is_dumping_final_static_archive()) {
|
||||
ConstantPool* src_cp = ArchiveBuilder::current()->get_source_addr(this);
|
||||
InstanceKlass* src_holder = src_cp->pool_holder();
|
||||
if (src_holder->is_shared_unregistered_class()) {
|
||||
if (src_holder->defined_by_other_loaders()) {
|
||||
// Unregistered classes are not loaded in the AOT assembly phase. The resolved reference length
|
||||
// is already saved during the training run.
|
||||
precond(!src_holder->is_loaded());
|
||||
|
||||
@ -538,8 +538,7 @@ void ConstantPoolCache::remove_resolved_indy_entries_if_non_deterministic() {
|
||||
|
||||
bool ConstantPoolCache::can_archive_resolved_method(ConstantPool* src_cp, ResolvedMethodEntry* method_entry) {
|
||||
InstanceKlass* pool_holder = constant_pool()->pool_holder();
|
||||
if (!(pool_holder->is_shared_boot_class() || pool_holder->is_shared_platform_class() ||
|
||||
pool_holder->is_shared_app_class())) {
|
||||
if (pool_holder->defined_by_other_loaders()) {
|
||||
// Archiving resolved cp entries for classes from non-builtin loaders
|
||||
// is not yet supported.
|
||||
return false;
|
||||
|
||||
@ -2734,7 +2734,7 @@ void InstanceKlass::init_shared_package_entry() {
|
||||
_package_entry = nullptr;
|
||||
#else
|
||||
if (CDSConfig::is_dumping_full_module_graph()) {
|
||||
if (is_shared_unregistered_class()) {
|
||||
if (defined_by_other_loaders()) {
|
||||
_package_entry = nullptr;
|
||||
} else {
|
||||
_package_entry = PackageEntry::get_archived_entry(_package_entry);
|
||||
@ -2842,17 +2842,6 @@ bool InstanceKlass::can_be_verified_at_dumptime() const {
|
||||
return true;
|
||||
}
|
||||
|
||||
int InstanceKlass::shared_class_loader_type() const {
|
||||
if (is_shared_boot_class()) {
|
||||
return ClassLoader::BOOT_LOADER;
|
||||
} else if (is_shared_platform_class()) {
|
||||
return ClassLoader::PLATFORM_LOADER;
|
||||
} else if (is_shared_app_class()) {
|
||||
return ClassLoader::APP_LOADER;
|
||||
} else {
|
||||
return ClassLoader::OTHER;
|
||||
}
|
||||
}
|
||||
#endif // INCLUDE_CDS
|
||||
|
||||
#if INCLUDE_JVMTI
|
||||
|
||||
@ -306,12 +306,12 @@ class InstanceKlass: public Klass {
|
||||
// Sets finalization state
|
||||
static void set_finalization_enabled(bool val) { _finalization_enabled = val; }
|
||||
|
||||
// The three BUILTIN class loader types
|
||||
bool is_shared_boot_class() const { return _misc_flags.is_shared_boot_class(); }
|
||||
bool is_shared_platform_class() const { return _misc_flags.is_shared_platform_class(); }
|
||||
bool is_shared_app_class() const { return _misc_flags.is_shared_app_class(); }
|
||||
// The UNREGISTERED class loader type
|
||||
bool is_shared_unregistered_class() const { return _misc_flags.is_shared_unregistered_class(); }
|
||||
// Quick checks for the loader that defined this class (without switching on this->class_loader())
|
||||
bool defined_by_boot_loader() const { return _misc_flags.defined_by_boot_loader(); }
|
||||
bool defined_by_platform_loader() const { return _misc_flags.defined_by_platform_loader(); }
|
||||
bool defined_by_app_loader() const { return _misc_flags.defined_by_app_loader(); }
|
||||
bool defined_by_other_loaders() const { return _misc_flags.defined_by_other_loaders(); }
|
||||
void set_class_loader_type() { _misc_flags.set_class_loader_type(_class_loader_data); }
|
||||
|
||||
// Check if the class can be shared in CDS
|
||||
bool is_shareable() const;
|
||||
@ -320,12 +320,6 @@ class InstanceKlass: public Klass {
|
||||
|
||||
void set_shared_loading_failed() { _misc_flags.set_shared_loading_failed(true); }
|
||||
|
||||
#if INCLUDE_CDS
|
||||
int shared_class_loader_type() const;
|
||||
void set_shared_class_loader_type(s2 loader_type) { _misc_flags.set_shared_class_loader_type(loader_type); }
|
||||
void assign_class_loader_type() { _misc_flags.assign_class_loader_type(_class_loader_data); }
|
||||
#endif
|
||||
|
||||
bool has_nonstatic_fields() const { return _misc_flags.has_nonstatic_fields(); }
|
||||
void set_has_nonstatic_fields(bool b) { _misc_flags.set_has_nonstatic_fields(b); }
|
||||
|
||||
|
||||
@ -37,36 +37,19 @@ void InstanceKlassFlags::print_on(outputStream* st) const {
|
||||
#undef IK_FLAGS_PRINT
|
||||
}
|
||||
|
||||
#if INCLUDE_CDS
|
||||
void InstanceKlassFlags::set_shared_class_loader_type(s2 loader_type) {
|
||||
switch (loader_type) {
|
||||
case ClassLoader::BOOT_LOADER:
|
||||
_flags |= _misc_is_shared_boot_class;
|
||||
break;
|
||||
case ClassLoader::PLATFORM_LOADER:
|
||||
_flags |= _misc_is_shared_platform_class;
|
||||
break;
|
||||
case ClassLoader::APP_LOADER:
|
||||
_flags |= _misc_is_shared_app_class;
|
||||
break;
|
||||
default:
|
||||
ShouldNotReachHere();
|
||||
break;
|
||||
}
|
||||
}
|
||||
void InstanceKlassFlags::set_class_loader_type(const ClassLoaderData* cld) {
|
||||
assert((_flags & builtin_loader_type_bits()) == 0, "set only once");
|
||||
|
||||
void InstanceKlassFlags::assign_class_loader_type(const ClassLoaderData* cld) {
|
||||
if (cld->is_boot_class_loader_data()) {
|
||||
set_shared_class_loader_type(ClassLoader::BOOT_LOADER);
|
||||
_flags |= _misc_defined_by_boot_loader;
|
||||
}
|
||||
else if (cld->is_platform_class_loader_data()) {
|
||||
set_shared_class_loader_type(ClassLoader::PLATFORM_LOADER);
|
||||
_flags |= _misc_defined_by_platform_loader;
|
||||
}
|
||||
else if (cld->is_system_class_loader_data()) {
|
||||
set_shared_class_loader_type(ClassLoader::APP_LOADER);
|
||||
_flags |= _misc_defined_by_app_loader;
|
||||
}
|
||||
}
|
||||
#endif // INCLUDE_CDS
|
||||
|
||||
#ifdef ASSERT
|
||||
void InstanceKlassFlags::assert_is_safe(bool set) {
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2023, 2024, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2023, 2025, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -47,9 +47,9 @@ class InstanceKlassFlags {
|
||||
flag(has_nonstatic_concrete_methods , 1 << 4) /* class/superclass/implemented interfaces has non-static, concrete methods */ \
|
||||
flag(declares_nonstatic_concrete_methods, 1 << 5) /* directly declares non-static, concrete methods */ \
|
||||
flag(shared_loading_failed , 1 << 6) /* class has been loaded from shared archive */ \
|
||||
flag(is_shared_boot_class , 1 << 7) /* defining class loader is boot class loader */ \
|
||||
flag(is_shared_platform_class , 1 << 8) /* defining class loader is platform class loader */ \
|
||||
flag(is_shared_app_class , 1 << 9) /* defining class loader is app class loader */ \
|
||||
flag(defined_by_boot_loader , 1 << 7) /* defining class loader is boot class loader */ \
|
||||
flag(defined_by_platform_loader , 1 << 8) /* defining class loader is platform class loader */ \
|
||||
flag(defined_by_app_loader , 1 << 9) /* defining class loader is app class loader */ \
|
||||
flag(has_contended_annotations , 1 << 10) /* has @Contended annotation */ \
|
||||
flag(has_localvariable_table , 1 << 11) /* has localvariable information */ \
|
||||
flag(has_miranda_methods , 1 << 12) /* True if this class has miranda methods in it's vtable */ \
|
||||
@ -76,8 +76,8 @@ class InstanceKlassFlags {
|
||||
};
|
||||
#undef IK_STATUS_ENUM_NAME
|
||||
|
||||
u2 shared_loader_type_bits() const {
|
||||
return _misc_is_shared_boot_class|_misc_is_shared_platform_class|_misc_is_shared_app_class;
|
||||
u2 builtin_loader_type_bits() const {
|
||||
return _misc_defined_by_boot_loader|_misc_defined_by_platform_loader|_misc_defined_by_app_loader;
|
||||
}
|
||||
|
||||
// These flags are write-once before the class is published and then read-only so don't require atomic updates.
|
||||
@ -100,13 +100,12 @@ class InstanceKlassFlags {
|
||||
IK_FLAGS_DO(IK_FLAGS_GET_SET)
|
||||
#undef IK_FLAGS_GET_SET
|
||||
|
||||
bool is_shared_unregistered_class() const {
|
||||
return (_flags & shared_loader_type_bits()) == 0;
|
||||
bool defined_by_other_loaders() const {
|
||||
return (_flags & builtin_loader_type_bits()) == 0;
|
||||
}
|
||||
|
||||
void set_shared_class_loader_type(s2 loader_type);
|
||||
void set_class_loader_type(const ClassLoaderData* cld);
|
||||
|
||||
void assign_class_loader_type(const ClassLoaderData* cld);
|
||||
void assert_is_safe(bool set) NOT_DEBUG_RETURN;
|
||||
|
||||
// Create getters and setters for the status values.
|
||||
|
||||
@ -831,12 +831,12 @@ void Klass::remove_java_mirror() {
|
||||
if (orig_mirror == nullptr) {
|
||||
assert(CDSConfig::is_dumping_final_static_archive(), "sanity");
|
||||
if (is_instance_klass()) {
|
||||
assert(InstanceKlass::cast(this)->is_shared_unregistered_class(), "sanity");
|
||||
assert(InstanceKlass::cast(this)->defined_by_other_loaders(), "sanity");
|
||||
} else {
|
||||
precond(is_objArray_klass());
|
||||
Klass *k = ObjArrayKlass::cast(this)->bottom_klass();
|
||||
precond(k->is_instance_klass());
|
||||
assert(InstanceKlass::cast(k)->is_shared_unregistered_class(), "sanity");
|
||||
assert(InstanceKlass::cast(k)->defined_by_other_loaders(), "sanity");
|
||||
}
|
||||
} else {
|
||||
oop scratch_mirror = HeapShared::scratch_java_mirror(orig_mirror);
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user