diff --git a/src/hotspot/share/cds/archiveBuilder.cpp b/src/hotspot/share/cds/archiveBuilder.cpp index 7f8c7787152..1d054561c76 100644 --- a/src/hotspot/share/cds/archiveBuilder.cpp +++ b/src/hotspot/share/cds/archiveBuilder.cpp @@ -748,17 +748,29 @@ void ArchiveBuilder::mark_and_relocate_to_buffered_addr(address* ptr_location) { bool ArchiveBuilder::has_been_archived(address src_addr) const { SourceObjInfo* p = _src_obj_table.get(src_addr); - return (p != nullptr); -} - -bool ArchiveBuilder::has_been_buffered(address src_addr) const { - if (RegeneratedClasses::has_been_regenerated(src_addr) || - _src_obj_table.get(src_addr) == nullptr || - get_buffered_addr(src_addr) == nullptr) { + if (p == nullptr) { + // This object has never been seen by ArchiveBuilder return false; - } else { - return true; } + if (p->buffered_addr() == nullptr) { + // ArchiveBuilder has seen this object, but decided not to archive it. So + // Any reference to this object will be modified to nullptr inside the buffer. + assert(p->follow_mode() == set_to_null, "must be"); + return false; + } + + DEBUG_ONLY({ + // This is a class/method that belongs to one of the "original" classes that + // have been regenerated by lambdaFormInvokers.cpp. We must have archived + // the "regenerated" version of it. + if (RegeneratedClasses::has_been_regenerated(src_addr)) { + address regen_obj = RegeneratedClasses::get_regenerated_object(src_addr); + precond(regen_obj != nullptr && regen_obj != src_addr); + assert(has_been_archived(regen_obj), "must be"); + assert(get_buffered_addr(src_addr) == get_buffered_addr(regen_obj), "must be"); + }}); + + return true; } address ArchiveBuilder::get_buffered_addr(address src_addr) const { diff --git a/src/hotspot/share/cds/archiveBuilder.hpp b/src/hotspot/share/cds/archiveBuilder.hpp index 1efd4045a99..39cc1c1eb8c 100644 --- a/src/hotspot/share/cds/archiveBuilder.hpp +++ b/src/hotspot/share/cds/archiveBuilder.hpp @@ -180,6 +180,7 @@ private: return _buffered_addr; } MetaspaceObj::Type msotype() const { return _msotype; } + FollowMode follow_mode() const { return _follow_mode; } }; class SourceObjList { @@ -443,10 +444,8 @@ public: } bool has_been_archived(address src_addr) const; - - bool has_been_buffered(address src_addr) const; - template bool has_been_buffered(T src_addr) const { - return has_been_buffered((address)src_addr); + template bool has_been_archived(T src_addr) const { + return has_been_archived((address)src_addr); } address get_buffered_addr(address src_addr) const; diff --git a/src/hotspot/share/cds/archiveHeapWriter.cpp b/src/hotspot/share/cds/archiveHeapWriter.cpp index b651da8418b..9c55b71a1b2 100644 --- a/src/hotspot/share/cds/archiveHeapWriter.cpp +++ b/src/hotspot/share/cds/archiveHeapWriter.cpp @@ -764,7 +764,7 @@ void ArchiveHeapWriter::compute_ptrmap(ArchiveHeapInfo* heap_info) { native_ptr = RegeneratedClasses::get_regenerated_object(native_ptr); } - guarantee(ArchiveBuilder::current()->has_been_buffered((address)native_ptr), + guarantee(ArchiveBuilder::current()->has_been_archived((address)native_ptr), "Metadata %p should have been archived", native_ptr); address buffered_native_ptr = ArchiveBuilder::current()->get_buffered_addr((address)native_ptr); diff --git a/src/hotspot/share/cds/archiveUtils.cpp b/src/hotspot/share/cds/archiveUtils.cpp index 9a92c6a8648..3c900cad035 100644 --- a/src/hotspot/share/cds/archiveUtils.cpp +++ b/src/hotspot/share/cds/archiveUtils.cpp @@ -383,8 +383,7 @@ void ArchiveUtils::log_to_classlist(BootstrapInfo* bootstrap_specifier, TRAPS) { } bool ArchiveUtils::has_aot_initialized_mirror(InstanceKlass* src_ik) { - if (SystemDictionaryShared::is_excluded_class(src_ik)) { - assert(!ArchiveBuilder::current()->has_been_buffered(src_ik), "sanity"); + if (!ArchiveBuilder::current()->has_been_archived(src_ik)) { return false; } return ArchiveBuilder::current()->get_buffered_addr(src_ik)->has_aot_initialized_mirror();