From 3d6e775d7135919519a9748036cd20b6c130bb42 Mon Sep 17 00:00:00 2001 From: Thomas Schatzl Date: Mon, 25 Sep 2023 06:38:11 +0000 Subject: [PATCH] 8316669: ImmutableOopMapSet destructor not called Reviewed-by: thartmann, jvernee, kvn --- src/hotspot/share/code/codeBlob.cpp | 7 ++++--- src/hotspot/share/compiler/oopMap.cpp | 3 +++ src/hotspot/share/compiler/oopMap.hpp | 3 +++ 3 files changed, 10 insertions(+), 3 deletions(-) diff --git a/src/hotspot/share/code/codeBlob.cpp b/src/hotspot/share/code/codeBlob.cpp index afb807065ab..a384edc936f 100644 --- a/src/hotspot/share/code/codeBlob.cpp +++ b/src/hotspot/share/code/codeBlob.cpp @@ -174,8 +174,10 @@ void RuntimeBlob::free(RuntimeBlob* blob) { } void CodeBlob::flush() { - FREE_C_HEAP_ARRAY(unsigned char, _oop_maps); - _oop_maps = nullptr; + if (_oop_maps != nullptr) { + delete _oop_maps; + _oop_maps = nullptr; + } NOT_PRODUCT(_asm_remarks.clear()); NOT_PRODUCT(_dbg_strings.clear()); } @@ -190,7 +192,6 @@ void CodeBlob::set_oop_maps(OopMapSet* p) { } } - void RuntimeBlob::trace_new_stub(RuntimeBlob* stub, const char* name1, const char* name2) { // Do not hold the CodeCache lock during name formatting. assert(!CodeCache_lock->owned_by_self(), "release CodeCache before registering the stub"); diff --git a/src/hotspot/share/compiler/oopMap.cpp b/src/hotspot/share/compiler/oopMap.cpp index a32934e3ff6..6ab8970a795 100644 --- a/src/hotspot/share/compiler/oopMap.cpp +++ b/src/hotspot/share/compiler/oopMap.cpp @@ -871,6 +871,9 @@ ImmutableOopMapSet* ImmutableOopMapSet::build_from(const OopMapSet* oopmap_set) return builder.build(); } +void ImmutableOopMapSet::operator delete(void* p) { + FREE_C_HEAP_ARRAY(unsigned char, p); +} //------------------------------DerivedPointerTable--------------------------- diff --git a/src/hotspot/share/compiler/oopMap.hpp b/src/hotspot/share/compiler/oopMap.hpp index 0af9b1abaa9..80832cdacd4 100644 --- a/src/hotspot/share/compiler/oopMap.hpp +++ b/src/hotspot/share/compiler/oopMap.hpp @@ -335,7 +335,10 @@ private: address data() const { return (address) this + sizeof(*this) + sizeof(ImmutableOopMapPair) * _count; } public: + void operator delete(void* p); + ImmutableOopMapSet(const OopMapSet* oopmap_set, int size) : _count(oopmap_set->size()), _size(size) {} + ~ImmutableOopMapSet() = default; ImmutableOopMap* oopmap_at_offset(int offset) const { assert(offset >= 0 && offset < _size, "must be within boundaries");