From 311b08d9fea441647e5980751592c7d4ab4b92e3 Mon Sep 17 00:00:00 2001 From: Ashutosh Mehra Date: Fri, 7 Nov 2025 15:34:30 -0500 Subject: [PATCH] 8371493: Simplify search for AdapterHandlerEntry Signed-off-by: Ashutosh Mehra --- src/hotspot/share/code/codeBlob.cpp | 3 +- src/hotspot/share/runtime/sharedRuntime.cpp | 34 ++------------------- src/hotspot/share/runtime/sharedRuntime.hpp | 1 - 3 files changed, 4 insertions(+), 34 deletions(-) diff --git a/src/hotspot/share/code/codeBlob.cpp b/src/hotspot/share/code/codeBlob.cpp index 18cdb6161fc6f..a0a34ec23fad6 100644 --- a/src/hotspot/share/code/codeBlob.cpp +++ b/src/hotspot/share/code/codeBlob.cpp @@ -870,9 +870,10 @@ void CodeBlob::dump_for_addr(address addr, outputStream* st, bool verbose) const return; } // - if (AdapterHandlerLibrary::contains(this)) { + if (is_adapter_blob()) { st->print_cr(INTPTR_FORMAT " is at code_begin+%d in an AdapterHandler", p2i(addr), (int)(addr - code_begin())); AdapterHandlerLibrary::print_handler_on(st, this); + return; } // the stubroutines are generated into a buffer blob StubCodeDesc* d = StubCodeDesc::desc_for(addr); diff --git a/src/hotspot/share/runtime/sharedRuntime.cpp b/src/hotspot/share/runtime/sharedRuntime.cpp index 835bbc0ae2f78..79c7c0b32b4e8 100644 --- a/src/hotspot/share/runtime/sharedRuntime.cpp +++ b/src/hotspot/share/runtime/sharedRuntime.cpp @@ -3396,42 +3396,12 @@ uint32_t AdapterHandlerLibrary::id(AdapterHandlerEntry* handler) { return handler->id(); } -bool AdapterHandlerLibrary::contains(const CodeBlob* b) { - bool found = false; -#if INCLUDE_CDS - if (AOTCodeCache::is_using_adapter()) { - auto findblob_archived_table = [&] (AdapterHandlerEntry* handler) { - if (b == CodeCache::find_blob(handler->get_i2c_entry())) { - found = true; - return false; // abort iteration - } else { - return true; // keep looking - } - }; - _aot_adapter_handler_table.iterate(findblob_archived_table); - } -#endif // INCLUDE_CDS - if (!found) { - auto findblob_runtime_table = [&] (AdapterFingerPrint* key, AdapterHandlerEntry* handler) { - if (b == CodeCache::find_blob(handler->get_i2c_entry())) { - found = true; - return false; // abort iteration - } else { - return true; // keep looking - } - }; - assert_locked_or_safepoint(AdapterHandlerLibrary_lock); - _adapter_handler_table->iterate(findblob_runtime_table); - } - return found; -} - void AdapterHandlerLibrary::print_handler_on(outputStream* st, const CodeBlob* b) { bool found = false; #if INCLUDE_CDS if (AOTCodeCache::is_using_adapter()) { auto findblob_archived_table = [&] (AdapterHandlerEntry* handler) { - if (b == CodeCache::find_blob(handler->get_i2c_entry())) { + if (b == handler->adapter_blob()) { found = true; st->print("Adapter for signature: "); handler->print_adapter_on(st); @@ -3445,7 +3415,7 @@ void AdapterHandlerLibrary::print_handler_on(outputStream* st, const CodeBlob* b #endif // INCLUDE_CDS if (!found) { auto findblob_runtime_table = [&] (AdapterFingerPrint* key, AdapterHandlerEntry* handler) { - if (b == CodeCache::find_blob(handler->get_i2c_entry())) { + if (b == handler->adapter_blob()) { found = true; st->print("Adapter for signature: "); handler->print_adapter_on(st); diff --git a/src/hotspot/share/runtime/sharedRuntime.hpp b/src/hotspot/share/runtime/sharedRuntime.hpp index f4ff51504f0e5..a696ce5a71b90 100644 --- a/src/hotspot/share/runtime/sharedRuntime.hpp +++ b/src/hotspot/share/runtime/sharedRuntime.hpp @@ -866,7 +866,6 @@ class AdapterHandlerLibrary: public AllStatic { static void print_handler(const CodeBlob* b) { print_handler_on(tty, b); } static void print_handler_on(outputStream* st, const CodeBlob* b); - static bool contains(const CodeBlob* b); static const char* name(AdapterHandlerEntry* handler); static uint32_t id(AdapterHandlerEntry* handler); #ifndef PRODUCT