diff --git a/src/hotspot/cpu/aarch64/codeBuffer_aarch64.cpp b/src/hotspot/cpu/aarch64/codeBuffer_aarch64.cpp index 3bc12a1f65146..d7de6ec09a3d8 100644 --- a/src/hotspot/cpu/aarch64/codeBuffer_aarch64.cpp +++ b/src/hotspot/cpu/aarch64/codeBuffer_aarch64.cpp @@ -30,7 +30,7 @@ void CodeBuffer::share_trampoline_for(address dest, int caller_offset) { if (_shared_trampoline_requests == nullptr) { constexpr unsigned init_size = 8; constexpr unsigned max_size = 256; - _shared_trampoline_requests = new SharedTrampolineRequests(init_size, max_size); + _shared_trampoline_requests = new (mtCompiler)SharedTrampolineRequests(init_size, max_size); } bool created; diff --git a/src/hotspot/cpu/riscv/codeBuffer_riscv.cpp b/src/hotspot/cpu/riscv/codeBuffer_riscv.cpp index 35b016241506a..3e78bb02f2c78 100644 --- a/src/hotspot/cpu/riscv/codeBuffer_riscv.cpp +++ b/src/hotspot/cpu/riscv/codeBuffer_riscv.cpp @@ -32,7 +32,7 @@ void CodeBuffer::share_trampoline_for(address dest, int caller_offset) { if (_shared_trampoline_requests == nullptr) { constexpr unsigned init_size = 8; constexpr unsigned max_size = 256; - _shared_trampoline_requests = new SharedTrampolineRequests(init_size, max_size); + _shared_trampoline_requests = new (mtCompiler)SharedTrampolineRequests(init_size, max_size); } bool created; diff --git a/src/hotspot/share/asm/codeBuffer.cpp b/src/hotspot/share/asm/codeBuffer.cpp index e87fd7cd88792..785e49dcd83d2 100644 --- a/src/hotspot/share/asm/codeBuffer.cpp +++ b/src/hotspot/share/asm/codeBuffer.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2023, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -138,6 +138,10 @@ CodeBuffer::~CodeBuffer() { delete cb->_overflow_arena; } + if (_shared_trampoline_requests != nullptr) { + delete _shared_trampoline_requests; + } + NOT_PRODUCT(clear_strings()); } diff --git a/src/hotspot/share/asm/codeBuffer.hpp b/src/hotspot/share/asm/codeBuffer.hpp index c03281c7812ce..85191401331a0 100644 --- a/src/hotspot/share/asm/codeBuffer.hpp +++ b/src/hotspot/share/asm/codeBuffer.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2023, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -403,7 +403,7 @@ class CodeBuffer: public StackObj DEBUG_ONLY(COMMA private Scrubber) { }; typedef LinkedListImpl Offsets; - typedef ResizeableResourceHashtable SharedTrampolineRequests; + typedef ResizeableResourceHashtable SharedTrampolineRequests; private: enum { diff --git a/src/hotspot/share/classfile/classLoaderStats.hpp b/src/hotspot/share/classfile/classLoaderStats.hpp index a121e653906dc..8296c6ee25f3c 100644 --- a/src/hotspot/share/classfile/classLoaderStats.hpp +++ b/src/hotspot/share/classfile/classLoaderStats.hpp @@ -112,7 +112,7 @@ class ClassLoaderStatsClosure : public CLDClosure { } typedef ResourceHashtable StatsTable; outputStream* _out; @@ -125,13 +125,17 @@ class ClassLoaderStatsClosure : public CLDClosure { public: ClassLoaderStatsClosure(outputStream* out) : _out(out), - _stats(new StatsTable()), + _stats(new (mtStatistics)StatsTable()), _total_loaders(0), _total_classes(0), _total_chunk_sz(0), _total_block_sz(0) { } + ~ClassLoaderStatsClosure() { + delete _stats; + } + virtual void do_cld(ClassLoaderData* cld); virtual bool do_entry(oop const& key, ClassLoaderStats const& cls); void print(); diff --git a/src/hotspot/share/utilities/resourceHash.hpp b/src/hotspot/share/utilities/resourceHash.hpp index 2de64aee64a12..c390b3608fcb8 100644 --- a/src/hotspot/share/utilities/resourceHash.hpp +++ b/src/hotspot/share/utilities/resourceHash.hpp @@ -30,6 +30,8 @@ #include "utilities/numberSeq.hpp" #include "utilities/tableStatistics.hpp" +#include + template class ResourceHashtableNode : public AnyObj { public: @@ -55,6 +57,10 @@ template< bool (*EQUALS)(K const&, K const&) > class ResourceHashtableBase : public STORAGE { + static_assert(ALLOC_TYPE == AnyObj::C_HEAP || std::is_trivially_destructible::value, + "Destructor for K is only called with C_HEAP"); + static_assert(ALLOC_TYPE == AnyObj::C_HEAP || std::is_trivially_destructible::value, + "Destructor for V is only called with C_HEAP"); using Node = ResourceHashtableNode; private: int _number_of_entries;