Skip to content
This repository has been archived by the owner. It is now read-only.
Permalink
Browse files
8268522: InstanceKlass::can_be_verified_at_dumptime() returns opposit…
…e value

Reviewed-by: dholmes, minqi, iklam
  • Loading branch information
calvinccheung committed Jun 14, 2021
1 parent abe20c1 commit c088d093e2e73fd0739d9e96f9f5ea67a01ae06c
Show file tree
Hide file tree
Showing 8 changed files with 25 additions and 25 deletions.
@@ -390,7 +390,7 @@ static void rewrite_nofast_bytecode(const methodHandle& method) {
void MetaspaceShared::rewrite_nofast_bytecodes_and_calculate_fingerprints(Thread* thread, InstanceKlass* ik) {
for (int i = 0; i < ik->methods()->length(); i++) {
methodHandle m(thread, ik->methods()->at(i));
if (!ik->can_be_verified_at_dumptime()) {
if (ik->can_be_verified_at_dumptime()) {
rewrite_nofast_bytecode(m);
}
Fingerprinter fp(m);
@@ -574,7 +574,7 @@ class CollectCLDClosure : public CLDClosure {
bool MetaspaceShared::linking_required(InstanceKlass* ik) {
// For static CDS dump, do not link old classes.
// For dynamic CDS dump, only link classes loaded by the builtin class loaders.
return DumpSharedSpaces ? !ik->can_be_verified_at_dumptime() : !ik->is_shared_unregistered_class();
return DumpSharedSpaces ? ik->can_be_verified_at_dumptime() : !ik->is_shared_unregistered_class();
}

bool MetaspaceShared::link_class_for_cds(InstanceKlass* ik, TRAPS) {
@@ -750,7 +750,7 @@ bool MetaspaceShared::try_link_class(JavaThread* current, InstanceKlass* ik) {
ExceptionMark em(current);
JavaThread* THREAD = current; // For exception macros.
Arguments::assert_is_dumping_archive();
if (ik->is_loaded() && !ik->is_linked() && !ik->can_be_verified_at_dumptime() &&
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() == NULL) {
@@ -1411,7 +1411,7 @@ bool SystemDictionaryShared::check_for_exclusion_impl(InstanceKlass* k) {
if (has_class_failed_verification(k)) {
return warn_excluded(k, "Failed verification");
} else {
if (!k->can_be_verified_at_dumptime()) {
if (k->can_be_verified_at_dumptime()) {
return warn_excluded(k, "Not linked");
}
}
@@ -1425,7 +1425,7 @@ bool SystemDictionaryShared::check_for_exclusion_impl(InstanceKlass* k) {
return true;
}

if (k->can_be_verified_at_dumptime() && k->is_linked()) {
if (!k->can_be_verified_at_dumptime() && k->is_linked()) {
return warn_excluded(k, "Old class has been linked");
}

@@ -571,7 +571,7 @@ void Rewriter::rewrite(InstanceKlass* klass, TRAPS) {
#if INCLUDE_CDS
if (klass->is_shared()) {
assert(!klass->is_rewritten(), "rewritten shared classes cannot be rewritten again");
assert(klass->can_be_verified_at_dumptime(), "only shared old classes aren't rewritten");
assert(!klass->can_be_verified_at_dumptime(), "only shared old classes aren't rewritten");
}
#endif // INCLUDE_CDS
ResourceMark rm(THREAD);
@@ -370,7 +370,7 @@ void ConstantPool::restore_unshareable_info(TRAPS) {
}

void ConstantPool::remove_unshareable_info() {
if (!_pool_holder->is_linked() && _pool_holder->is_shared_old_klass()) {
if (!_pool_holder->is_linked() && !_pool_holder->verified_at_dump_time()) {
return;
}
// Resolved references are not in the shared archive.
@@ -2403,8 +2403,8 @@ void InstanceKlass::metaspace_pointers_do(MetaspaceClosure* it) {
void InstanceKlass::remove_unshareable_info() {

if (can_be_verified_at_dumptime()) {
// Set the old class bit.
set_is_shared_old_klass();
// Remember this so we can avoid walking the hierarchy at runtime.
set_verified_at_dump_time();
}

Klass::remove_unshareable_info();
@@ -2549,19 +2549,19 @@ void InstanceKlass::restore_unshareable_info(ClassLoaderData* loader_data, Handl
// Verification of archived old classes will be performed during run time.
bool InstanceKlass::can_be_verified_at_dumptime() const {
if (major_version() < 50 /*JAVA_6_VERSION*/) {
return true;
return false;
}
if (java_super() != NULL && java_super()->can_be_verified_at_dumptime()) {
return true;
if (java_super() != NULL && !java_super()->can_be_verified_at_dumptime()) {
return false;
}
Array<InstanceKlass*>* interfaces = local_interfaces();
int len = interfaces->length();
for (int i = 0; i < len; i++) {
if (interfaces->at(i)->can_be_verified_at_dumptime()) {
return true;
if (!interfaces->at(i)->can_be_verified_at_dumptime()) {
return false;
}
}
return false;
return true;
}

void InstanceKlass::set_shared_class_loader_type(s2 loader_type) {
@@ -178,7 +178,7 @@ class Klass : public Metadata {
enum {
_archived_lambda_proxy_is_available = 2,
_has_value_based_class_annotation = 4,
_is_shared_old_klass = 8
_verified_at_dump_time = 8
};
#endif

@@ -334,11 +334,11 @@ class Klass : public Metadata {
NOT_CDS(return false;)
}

void set_is_shared_old_klass() {
CDS_ONLY(_shared_class_flags |= _is_shared_old_klass;)
void set_verified_at_dump_time() {
CDS_ONLY(_shared_class_flags |= _verified_at_dump_time;)
}
bool is_shared_old_klass() const {
CDS_ONLY(return (_shared_class_flags & _is_shared_old_klass) != 0;)
bool verified_at_dump_time() const {
CDS_ONLY(return (_shared_class_flags & _verified_at_dump_time) != 0;)
NOT_CDS(return false;)
}

@@ -51,7 +51,7 @@ inline InstanceKlass* klassVtable::ik() const {
}

bool klassVtable::is_preinitialized_vtable() {
return _klass->is_shared() && !MetaspaceShared::remapped_readwrite() && !_klass->is_shared_old_klass();
return _klass->is_shared() && !MetaspaceShared::remapped_readwrite() && _klass->verified_at_dump_time();
}


@@ -1094,8 +1094,8 @@ void itableMethodEntry::initialize(InstanceKlass* klass, Method* m) {
#ifdef ASSERT
if (MetaspaceShared::is_in_shared_metaspace((void*)&_method) &&
!MetaspaceShared::remapped_readwrite() &&
!m->method_holder()->can_be_verified_at_dumptime() &&
!klass->can_be_verified_at_dumptime()) {
m->method_holder()->verified_at_dump_time() &&
klass->verified_at_dump_time()) {
// At runtime initialize_itable is rerun as part of link_class_impl()
// for a shared class loaded by the non-boot loader.
// The dumptime itable method entry should be the same as the runtime entry.
@@ -409,7 +409,7 @@ void Method::remove_unshareable_info() {
}

void Method::set_vtable_index(int index) {
if (is_shared() && !MetaspaceShared::remapped_readwrite() && !method_holder()->is_shared_old_klass()) {
if (is_shared() && !MetaspaceShared::remapped_readwrite() && method_holder()->verified_at_dump_time()) {
// At runtime initialize_vtable is rerun as part of link_class_impl()
// for a shared class loaded by the non-boot loader to obtain the loader
// constraints based on the runtime classloaders' context.
@@ -420,7 +420,7 @@ void Method::set_vtable_index(int index) {
}

void Method::set_itable_index(int index) {
if (is_shared() && !MetaspaceShared::remapped_readwrite() && !method_holder()->is_shared_old_klass()) {
if (is_shared() && !MetaspaceShared::remapped_readwrite() && method_holder()->verified_at_dump_time()) {
// At runtime initialize_itable is rerun as part of link_class_impl()
// for a shared class loaded by the non-boot loader to obtain the loader
// constraints based on the runtime classloaders' context. The dumptime

1 comment on commit c088d09

@openjdk-notifier
Copy link

@openjdk-notifier openjdk-notifier bot commented on c088d09 Jun 14, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.