diff --git a/src/hotspot/share/code/compiledIC.cpp b/src/hotspot/share/code/compiledIC.cpp index c6294ff5627..b966b580984 100644 --- a/src/hotspot/share/code/compiledIC.cpp +++ b/src/hotspot/share/code/compiledIC.cpp @@ -561,15 +561,14 @@ void CompiledIC::compute_monomorphic_entry(const methodHandle& method, bool CompiledIC::is_icholder_entry(address entry) { CodeBlob* cb = CodeCache::find_blob(entry); - if (cb != nullptr && cb->is_adapter_blob()) { - return true; + if (cb == nullptr) { + return false; } - // itable stubs also use CompiledICHolder - if (cb != nullptr && cb->is_vtable_blob()) { - VtableStub* s = VtableStubs::entry_point(entry); - return (s != nullptr) && s->is_itable_stub(); + if (cb->is_adapter_blob()) { + return true; + } else if (cb->is_vtable_blob()) { + return VtableStubs::is_icholder_entry(entry); } - return false; } diff --git a/src/hotspot/share/code/vtableStubs.cpp b/src/hotspot/share/code/vtableStubs.cpp index 934f805eefc..3c07bdba733 100644 --- a/src/hotspot/share/code/vtableStubs.cpp +++ b/src/hotspot/share/code/vtableStubs.cpp @@ -284,6 +284,13 @@ VtableStub* VtableStubs::entry_point(address pc) { return (s == stub) ? s : nullptr; } +bool VtableStubs::is_icholder_entry(address pc) { + assert(contains(pc), "must contain all vtable blobs"); + VtableStub* stub = (VtableStub*)(pc - VtableStub::entry_offset()); + // itable stubs use CompiledICHolder. + return stub->is_itable_stub(); +} + bool VtableStubs::contains(address pc) { // simple solution for now - we may want to use // a faster way if this function is called often diff --git a/src/hotspot/share/code/vtableStubs.hpp b/src/hotspot/share/code/vtableStubs.hpp index bd037e62cce..a2bb24f34ce 100644 --- a/src/hotspot/share/code/vtableStubs.hpp +++ b/src/hotspot/share/code/vtableStubs.hpp @@ -105,6 +105,7 @@ class VtableStubs : AllStatic { static address find_itable_stub(int itable_index) { return find_stub(false, itable_index); } static VtableStub* entry_point(address pc); // vtable stub entry point for a pc + static bool is_icholder_entry(address pc); // is the blob containing pc (which must be a vtable blob) an icholder? static bool contains(address pc); // is pc within any stub? static VtableStub* stub_containing(address pc); // stub containing pc or nullptr static int number_of_vtable_stubs() { return _number_of_vtable_stubs; }