mirror of
https://github.com/openjdk/jdk.git
synced 2025-09-18 18:14:38 +02:00
8267191: Avoid repeated SystemDictionaryShared::should_be_excluded calls
Reviewed-by: dholmes, coleenp
This commit is contained in:
parent
74f30ad38b
commit
b961f2535c
2 changed files with 58 additions and 52 deletions
|
@ -80,6 +80,7 @@ bool SystemDictionaryShared::_dump_in_progress = false;
|
||||||
class DumpTimeSharedClassInfo: public CHeapObj<mtClass> {
|
class DumpTimeSharedClassInfo: public CHeapObj<mtClass> {
|
||||||
bool _excluded;
|
bool _excluded;
|
||||||
bool _is_early_klass;
|
bool _is_early_klass;
|
||||||
|
bool _has_checked_exclusion;
|
||||||
public:
|
public:
|
||||||
struct DTLoaderConstraint {
|
struct DTLoaderConstraint {
|
||||||
Symbol* _name;
|
Symbol* _name;
|
||||||
|
@ -122,6 +123,7 @@ public:
|
||||||
_nest_host = NULL;
|
_nest_host = NULL;
|
||||||
_failed_verification = false;
|
_failed_verification = false;
|
||||||
_is_archived_lambda_proxy = false;
|
_is_archived_lambda_proxy = false;
|
||||||
|
_has_checked_exclusion = false;
|
||||||
_id = -1;
|
_id = -1;
|
||||||
_clsfile_size = -1;
|
_clsfile_size = -1;
|
||||||
_clsfile_crc32 = -1;
|
_clsfile_crc32 = -1;
|
||||||
|
@ -174,10 +176,6 @@ public:
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void set_excluded() {
|
|
||||||
_excluded = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool is_excluded() {
|
bool is_excluded() {
|
||||||
// _klass may become NULL due to DynamicArchiveBuilder::set_to_null
|
// _klass may become NULL due to DynamicArchiveBuilder::set_to_null
|
||||||
return _excluded || _failed_verification || _klass == NULL;
|
return _excluded || _failed_verification || _klass == NULL;
|
||||||
|
@ -188,21 +186,14 @@ public:
|
||||||
return _is_early_klass;
|
return _is_early_klass;
|
||||||
}
|
}
|
||||||
|
|
||||||
void set_failed_verification() {
|
// simple accessors
|
||||||
_failed_verification = true;
|
void set_excluded() { _excluded = true; }
|
||||||
}
|
bool has_checked_exclusion() const { return _has_checked_exclusion; }
|
||||||
|
void set_has_checked_exclusion() { _has_checked_exclusion = true; }
|
||||||
bool failed_verification() {
|
bool failed_verification() const { return _failed_verification; }
|
||||||
return _failed_verification;
|
void set_failed_verification() { _failed_verification = true; }
|
||||||
}
|
InstanceKlass* nest_host() const { return _nest_host; }
|
||||||
|
void set_nest_host(InstanceKlass* nest_host) { _nest_host = nest_host; }
|
||||||
void set_nest_host(InstanceKlass* nest_host) {
|
|
||||||
_nest_host = nest_host;
|
|
||||||
}
|
|
||||||
|
|
||||||
InstanceKlass* nest_host() {
|
|
||||||
return _nest_host;
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
inline unsigned DumpTimeSharedClassTable_hash(InstanceKlass* const& k) {
|
inline unsigned DumpTimeSharedClassTable_hash(InstanceKlass* const& k) {
|
||||||
|
@ -1326,41 +1317,60 @@ bool SystemDictionaryShared::is_early_klass(InstanceKlass* ik) {
|
||||||
return (info != NULL) ? info->is_early_klass() : false;
|
return (info != NULL) ? info->is_early_klass() : false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void SystemDictionaryShared::warn_excluded(InstanceKlass* k, const char* reason) {
|
// Returns true so the caller can do: return warn_excluded(".....");
|
||||||
|
bool SystemDictionaryShared::warn_excluded(InstanceKlass* k, const char* reason) {
|
||||||
ResourceMark rm;
|
ResourceMark rm;
|
||||||
log_warning(cds)("Skipping %s: %s", k->name()->as_C_string(), reason);
|
log_warning(cds)("Skipping %s: %s", k->name()->as_C_string(), reason);
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool SystemDictionaryShared::should_be_excluded(InstanceKlass* k) {
|
bool SystemDictionaryShared::check_for_exclusion(InstanceKlass* k, DumpTimeSharedClassInfo* info) {
|
||||||
|
if (MetaspaceShared::is_in_shared_metaspace(k)) {
|
||||||
|
// We have reached a super type that's already in the base archive. Treat it
|
||||||
|
// as "not excluded".
|
||||||
|
assert(DynamicDumpSharedSpaces, "must be");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (info == NULL) {
|
||||||
|
info = _dumptime_table->get(k);
|
||||||
|
assert(info != NULL, "supertypes of any classes in _dumptime_table must either be shared, or must also be in _dumptime_table");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!info->has_checked_exclusion()) {
|
||||||
|
if (check_for_exclusion_impl(k)) {
|
||||||
|
info->set_excluded();
|
||||||
|
}
|
||||||
|
info->set_has_checked_exclusion();
|
||||||
|
}
|
||||||
|
|
||||||
|
return info->is_excluded();
|
||||||
|
}
|
||||||
|
|
||||||
|
bool SystemDictionaryShared::check_for_exclusion_impl(InstanceKlass* k) {
|
||||||
if (k->is_in_error_state()) {
|
if (k->is_in_error_state()) {
|
||||||
warn_excluded(k, "In error state");
|
return warn_excluded(k, "In error state");
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
if (k->has_been_redefined()) {
|
if (k->has_been_redefined()) {
|
||||||
warn_excluded(k, "Has been redefined");
|
return warn_excluded(k, "Has been redefined");
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
if (!k->is_hidden() && k->shared_classpath_index() < 0 && is_builtin(k)) {
|
if (!k->is_hidden() && k->shared_classpath_index() < 0 && is_builtin(k)) {
|
||||||
// These are classes loaded from unsupported locations (such as those loaded by JVMTI native
|
// These are classes loaded from unsupported locations (such as those loaded by JVMTI native
|
||||||
// agent during dump time).
|
// agent during dump time).
|
||||||
warn_excluded(k, "Unsupported location");
|
return warn_excluded(k, "Unsupported location");
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
if (k->signers() != NULL) {
|
if (k->signers() != NULL) {
|
||||||
// We cannot include signed classes in the archive because the certificates
|
// We cannot include signed classes in the archive because the certificates
|
||||||
// used during dump time may be different than those used during
|
// used during dump time may be different than those used during
|
||||||
// runtime (due to expiration, etc).
|
// runtime (due to expiration, etc).
|
||||||
warn_excluded(k, "Signed JAR");
|
return warn_excluded(k, "Signed JAR");
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
if (is_jfr_event_class(k)) {
|
if (is_jfr_event_class(k)) {
|
||||||
// We cannot include JFR event classes because they need runtime-specific
|
// We cannot include JFR event classes because they need runtime-specific
|
||||||
// instrumentation in order to work with -XX:FlightRecorderOptions:retransform=false.
|
// instrumentation in order to work with -XX:FlightRecorderOptions:retransform=false.
|
||||||
// There are only a small number of these classes, so it's not worthwhile to
|
// There are only a small number of these classes, so it's not worthwhile to
|
||||||
// support them and make CDS more complicated.
|
// support them and make CDS more complicated.
|
||||||
warn_excluded(k, "JFR event class");
|
return warn_excluded(k, "JFR event class");
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
if (k->init_state() < InstanceKlass::linked) {
|
if (k->init_state() < InstanceKlass::linked) {
|
||||||
// In CDS dumping, we will attempt to link all classes. Those that fail to link will
|
// In CDS dumping, we will attempt to link all classes. Those that fail to link will
|
||||||
|
@ -1374,12 +1384,10 @@ bool SystemDictionaryShared::should_be_excluded(InstanceKlass* k) {
|
||||||
// a custom ClassLoader.loadClass() may be called, at a point where the
|
// a custom ClassLoader.loadClass() may be called, at a point where the
|
||||||
// class loader doesn't expect it.
|
// class loader doesn't expect it.
|
||||||
if (has_class_failed_verification(k)) {
|
if (has_class_failed_verification(k)) {
|
||||||
warn_excluded(k, "Failed verification");
|
return warn_excluded(k, "Failed verification");
|
||||||
return true;
|
|
||||||
} else {
|
} else {
|
||||||
if (!k->has_old_class_version()) {
|
if (!k->has_old_class_version()) {
|
||||||
warn_excluded(k, "Not linked");
|
return warn_excluded(k, "Not linked");
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1393,20 +1401,19 @@ bool SystemDictionaryShared::should_be_excluded(InstanceKlass* k) {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (k->has_old_class_version() && k->is_linked()) {
|
if (k->has_old_class_version() && k->is_linked()) {
|
||||||
warn_excluded(k, "Old class has been linked");
|
return warn_excluded(k, "Old class has been linked");
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
InstanceKlass* super = k->java_super();
|
|
||||||
if (super != NULL && should_be_excluded(super)) {
|
|
||||||
ResourceMark rm;
|
|
||||||
log_warning(cds)("Skipping %s: super class %s is excluded", k->name()->as_C_string(), super->name()->as_C_string());
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (k->is_hidden() && !is_registered_lambda_proxy_class(k)) {
|
if (k->is_hidden() && !is_registered_lambda_proxy_class(k)) {
|
||||||
ResourceMark rm;
|
ResourceMark rm;
|
||||||
log_debug(cds)("Skipping %s: %s", k->name()->as_C_string(), "Hidden class");
|
log_debug(cds)("Skipping %s: Hidden class", k->name()->as_C_string());
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
InstanceKlass* super = k->java_super();
|
||||||
|
if (super != NULL && check_for_exclusion(super, NULL)) {
|
||||||
|
ResourceMark rm;
|
||||||
|
log_warning(cds)("Skipping %s: super class %s is excluded", k->name()->as_C_string(), super->name()->as_C_string());
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1414,13 +1421,13 @@ bool SystemDictionaryShared::should_be_excluded(InstanceKlass* k) {
|
||||||
int len = interfaces->length();
|
int len = interfaces->length();
|
||||||
for (int i = 0; i < len; i++) {
|
for (int i = 0; i < len; i++) {
|
||||||
InstanceKlass* intf = interfaces->at(i);
|
InstanceKlass* intf = interfaces->at(i);
|
||||||
if (should_be_excluded(intf)) {
|
if (check_for_exclusion(intf, NULL)) {
|
||||||
log_warning(cds)("Skipping %s: interface %s is excluded", k->name()->as_C_string(), intf->name()->as_C_string());
|
log_warning(cds)("Skipping %s: interface %s is excluded", k->name()->as_C_string(), intf->name()->as_C_string());
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return false; // false == k should NOT be excluded
|
||||||
}
|
}
|
||||||
|
|
||||||
// k is a class before relocating by ArchiveBuilder
|
// k is a class before relocating by ArchiveBuilder
|
||||||
|
@ -1447,9 +1454,7 @@ void SystemDictionaryShared::validate_before_archiving(InstanceKlass* k) {
|
||||||
class ExcludeDumpTimeSharedClasses : StackObj {
|
class ExcludeDumpTimeSharedClasses : StackObj {
|
||||||
public:
|
public:
|
||||||
bool do_entry(InstanceKlass* k, DumpTimeSharedClassInfo& info) {
|
bool do_entry(InstanceKlass* k, DumpTimeSharedClassInfo& info) {
|
||||||
if (SystemDictionaryShared::should_be_excluded(k) || info.is_excluded()) {
|
SystemDictionaryShared::check_for_exclusion(k, &info);
|
||||||
info.set_excluded();
|
|
||||||
}
|
|
||||||
return true; // keep on iterating
|
return true; // keep on iterating
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
|
@ -212,8 +212,8 @@ private:
|
||||||
static void write_lambda_proxy_class_dictionary(LambdaProxyClassDictionary* dictionary);
|
static void write_lambda_proxy_class_dictionary(LambdaProxyClassDictionary* dictionary);
|
||||||
static bool is_jfr_event_class(InstanceKlass *k);
|
static bool is_jfr_event_class(InstanceKlass *k);
|
||||||
static bool is_registered_lambda_proxy_class(InstanceKlass* ik);
|
static bool is_registered_lambda_proxy_class(InstanceKlass* ik);
|
||||||
static void warn_excluded(InstanceKlass* k, const char* reason);
|
static bool warn_excluded(InstanceKlass* k, const char* reason);
|
||||||
static bool should_be_excluded(InstanceKlass* k);
|
static bool check_for_exclusion_impl(InstanceKlass* k);
|
||||||
|
|
||||||
static bool _dump_in_progress;
|
static bool _dump_in_progress;
|
||||||
DEBUG_ONLY(static bool _no_class_loading_should_happen;)
|
DEBUG_ONLY(static bool _no_class_loading_should_happen;)
|
||||||
|
@ -304,6 +304,7 @@ public:
|
||||||
return (k->shared_classpath_index() != UNREGISTERED_INDEX);
|
return (k->shared_classpath_index() != UNREGISTERED_INDEX);
|
||||||
}
|
}
|
||||||
static void check_excluded_classes();
|
static void check_excluded_classes();
|
||||||
|
static bool check_for_exclusion(InstanceKlass* k, DumpTimeSharedClassInfo* info);
|
||||||
static void validate_before_archiving(InstanceKlass* k);
|
static void validate_before_archiving(InstanceKlass* k);
|
||||||
static bool is_excluded_class(InstanceKlass* k);
|
static bool is_excluded_class(InstanceKlass* k);
|
||||||
static void set_excluded(InstanceKlass* k);
|
static void set_excluded(InstanceKlass* k);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue