Description
Proposal:
[1] SystemDictionaryShared::{_dumptime_table, _dumptime_lambda_proxy_class_dictionary} should be allocated at VM bootstrap to so:
+ We don't need to allocate these tables dynamically
+ We don't need to check if these tables exist when writing the archive
[2] The current implementation guarantees that SystemDictionaryShared::_dumptime_table always contains a DumpTimeClassInfo for each InstanceKlass that's being considered for inclusion in the CDS archive. We can simplify the old SystemDictionaryShared::find_or_allocate_info_for() API to
// Guaranteed to return non-NULL value for non-shared classes.
// k must not be a shared class.
DumpTimeClassInfo* SystemDictionaryShared::get_info(InstanceKlass* k)
=========================================
Background:
The API for SystemDictionaryShared::find_or_allocate_info_for() is too loose and potentially unreliable. By definition, it will allocate a new DumpTimeClassInfo if one doesn't already exist. It's used in places like this:
https://github.com/openjdk/jdk/blob/b1817a30a00d74f70b247c783047bfbb49515dda/src/hotspot/share/classfile/systemDictionaryShared.cpp#L673-L679
bool SystemDictionaryShared::is_excluded_class(InstanceKlass* k) {
assert(_no_class_loading_should_happen, "sanity");
assert_lock_strong(DumpTimeTable_lock);
Arguments::assert_is_dumping_archive();
DumpTimeClassInfo* p = find_or_allocate_info_for_locked(k);
return (p == NULL) ? true : p->is_excluded();
}
However, the implementation will not allocate under some circumstances. The behavior depends on many external states, making the code hard to understand:
https://github.com/openjdk/jdk/blob/master/src/hotspot/share/cds/dumpTimeClassInfo.cpp#L172-L190
DumpTimeClassInfo* DumpTimeSharedClassTable::find_or_allocate_info_for(InstanceKlass* k, bool dump_in_progress) {
bool created = false;
DumpTimeClassInfo* p;
if (!dump_in_progress) {
p = put_if_absent(k, &created);
} else {
p = get(k);
}
if (created) {
assert(!SystemDictionaryShared::no_class_loading_should_happen(),
"no new classes can be loaded while dumping archive");
p->_klass = k;
} else {
if (!dump_in_progress) {
assert(p->_klass == k, "Sanity");
}
}
return p;
}
[1] SystemDictionaryShared::{_dumptime_table, _dumptime_lambda_proxy_class_dictionary} should be allocated at VM bootstrap to so:
+ We don't need to allocate these tables dynamically
+ We don't need to check if these tables exist when writing the archive
[2] The current implementation guarantees that SystemDictionaryShared::_dumptime_table always contains a DumpTimeClassInfo for each InstanceKlass that's being considered for inclusion in the CDS archive. We can simplify the old SystemDictionaryShared::find_or_allocate_info_for() API to
// Guaranteed to return non-NULL value for non-shared classes.
// k must not be a shared class.
DumpTimeClassInfo* SystemDictionaryShared::get_info(InstanceKlass* k)
=========================================
Background:
The API for SystemDictionaryShared::find_or_allocate_info_for() is too loose and potentially unreliable. By definition, it will allocate a new DumpTimeClassInfo if one doesn't already exist. It's used in places like this:
https://github.com/openjdk/jdk/blob/b1817a30a00d74f70b247c783047bfbb49515dda/src/hotspot/share/classfile/systemDictionaryShared.cpp#L673-L679
bool SystemDictionaryShared::is_excluded_class(InstanceKlass* k) {
assert(_no_class_loading_should_happen, "sanity");
assert_lock_strong(DumpTimeTable_lock);
Arguments::assert_is_dumping_archive();
DumpTimeClassInfo* p = find_or_allocate_info_for_locked(k);
return (p == NULL) ? true : p->is_excluded();
}
However, the implementation will not allocate under some circumstances. The behavior depends on many external states, making the code hard to understand:
https://github.com/openjdk/jdk/blob/master/src/hotspot/share/cds/dumpTimeClassInfo.cpp#L172-L190
DumpTimeClassInfo* DumpTimeSharedClassTable::find_or_allocate_info_for(InstanceKlass* k, bool dump_in_progress) {
bool created = false;
DumpTimeClassInfo* p;
if (!dump_in_progress) {
p = put_if_absent(k, &created);
} else {
p = get(k);
}
if (created) {
assert(!SystemDictionaryShared::no_class_loading_should_happen(),
"no new classes can be loaded while dumping archive");
p->_klass = k;
} else {
if (!dump_in_progress) {
assert(p->_klass == k, "Sanity");
}
}
return p;
}
Attachments
Issue Links
- relates to
-
JDK-8301876 Crash in DumpTimeClassInfo::add_verification_constraint
- Closed