diff --git a/src/hotspot/cpu/x86/stubGenerator_x86_64_kyber.cpp b/src/hotspot/cpu/x86/stubGenerator_x86_64_kyber.cpp index 347a9b936a8..13b1c942213 100644 --- a/src/hotspot/cpu/x86/stubGenerator_x86_64_kyber.cpp +++ b/src/hotspot/cpu/x86/stubGenerator_x86_64_kyber.cpp @@ -957,6 +957,9 @@ address generate_kyber12To16_avx512(StubGenerator *stubgen, __ mov64(rax, 0); // return 0 __ ret(0); + // record the stub entry and end + stubgen->store_archive_data(stub_id, start, __ pc()); + return start; } diff --git a/src/hotspot/share/code/aotCodeCache.cpp b/src/hotspot/share/code/aotCodeCache.cpp index e1c9184faca..1ed75bf4f85 100644 --- a/src/hotspot/share/code/aotCodeCache.cpp +++ b/src/hotspot/share/code/aotCodeCache.cpp @@ -2615,10 +2615,6 @@ address AOTStubData::load_archive_data(StubId stub_id, address& end, GrowableArr StubAddrRange &range = _ranges[idx]; int base = range.start_index(); if (base < 0) { -#ifdef DEBUG - // reset index so we can idenitfy which ones we failed to find - range.init_entry(-2, 0); -#endif return nullptr; } int count = range.count(); @@ -2695,3 +2691,23 @@ void AOTStubData::store_archive_data(StubId stub_id, address start, address end, } range.init_entry(base, _address_array.length() - base); } + +void AOTStubData::stub_epilog(StubId stub_id) { + DEBUG_ONLY(check_stored(stub_id)); +} + +#ifdef ASSERT +void AOTStubData::check_stored(StubId stub_id) { + // Only need to check if we are dumping + // + // This excludes cases where the cache got closed because of error + // plus the pre-universe stubs we can never store because they are + // generated prior to cache opening. + if (is_dumping()) { + int idx = StubInfo::stubgen_offset_in_blob(_blob_id, stub_id); + assert(idx >= 0 && idx < _stub_cnt, "invalid index %d for stub count %d", idx, _stub_cnt); + StubAddrRange& range = _ranges[idx]; + assert(range.start_index() != -1, "missing store_archive_data for generated stub %s", StubInfo::name(stub_id)); + } +} +#endif diff --git a/src/hotspot/share/code/aotCodeCache.hpp b/src/hotspot/share/code/aotCodeCache.hpp index 999fa5fb658..0a0274e3a67 100644 --- a/src/hotspot/share/code/aotCodeCache.hpp +++ b/src/hotspot/share/code/aotCodeCache.hpp @@ -266,6 +266,10 @@ public: address load_archive_data(StubId stub_id, address &end, GrowableArray
* entries = nullptr, GrowableArray* extras = nullptr) NOT_CDS_RETURN_(nullptr); void store_archive_data(StubId stub_id, address start, address end, GrowableArray* entries = nullptr, GrowableArray* extras = nullptr) NOT_CDS_RETURN; + void stub_epilog(StubId stub_id); +#ifdef ASSERT + void check_stored(StubId stub_id); +#endif const AOTStubData* as_const() { return (const AOTStubData*)this; } }; diff --git a/src/hotspot/share/runtime/stubCodeGenerator.cpp b/src/hotspot/share/runtime/stubCodeGenerator.cpp index 45e40f4a754..94825ba2d0b 100644 --- a/src/hotspot/share/runtime/stubCodeGenerator.cpp +++ b/src/hotspot/share/runtime/stubCodeGenerator.cpp @@ -178,6 +178,9 @@ void StubCodeGenerator::stub_prolog(StubCodeDesc* cdesc) { } void StubCodeGenerator::stub_epilog(StubCodeDesc* cdesc) { + if (_stub_data != nullptr && _stub_data->is_dumping()) { + _stub_data->stub_epilog(cdesc->stub_id()); + } print_stub_code_desc(cdesc); } @@ -259,15 +262,18 @@ void StubCodeGenerator::verify_stub(StubId stub_id) { // Implementation of CodeMark -StubCodeMark::StubCodeMark(StubCodeGenerator* cgen, const char* group, const char* name) { +StubCodeMark::StubCodeMark(StubCodeGenerator* cgen, const char* group, const char* name, StubId stub_id) { _cgen = cgen; - _cdesc = new StubCodeDesc(group, name, _cgen->assembler()->pc()); + _cdesc = new StubCodeDesc(group, name, _cgen->assembler()->pc(), nullptr, stub_id); _cgen->stub_prolog(_cdesc); // define the stub's beginning (= entry point) to be after the prolog: _cdesc->set_begin(_cgen->assembler()->pc()); } -StubCodeMark::StubCodeMark(StubCodeGenerator* cgen, StubId stub_id) : StubCodeMark(cgen, "StubRoutines", StubRoutines::get_stub_name(stub_id)) { +StubCodeMark::StubCodeMark(StubCodeGenerator* cgen, const char* group, const char* name) : StubCodeMark(cgen, group, name, StubId::NO_STUBID) { +} + +StubCodeMark::StubCodeMark(StubCodeGenerator* cgen, StubId stub_id) : StubCodeMark(cgen, "StubRoutines", StubRoutines::get_stub_name(stub_id), stub_id) { #ifdef ASSERT cgen->verify_stub(stub_id); #endif diff --git a/src/hotspot/share/runtime/stubCodeGenerator.hpp b/src/hotspot/share/runtime/stubCodeGenerator.hpp index 958fa76543b..9b94e24fd9b 100644 --- a/src/hotspot/share/runtime/stubCodeGenerator.hpp +++ b/src/hotspot/share/runtime/stubCodeGenerator.hpp @@ -50,6 +50,8 @@ class StubCodeDesc: public CHeapObj