Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

8301564: Non-C-heap allocated ResourceHashtable keys and values must have trivial destructor #12355

Closed
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/hotspot/cpu/aarch64/codeBuffer_aarch64.cpp
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion src/hotspot/cpu/riscv/codeBuffer_riscv.cpp
Expand Up @@ -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;
Expand Down
6 changes: 5 additions & 1 deletion 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
Expand Down Expand Up @@ -138,6 +138,10 @@ CodeBuffer::~CodeBuffer() {
delete cb->_overflow_arena;
}

if (_shared_trampoline_requests != nullptr) {
delete _shared_trampoline_requests;
}

NOT_PRODUCT(clear_strings());
}

Expand Down
4 changes: 2 additions & 2 deletions 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
Expand Down Expand Up @@ -403,7 +403,7 @@ class CodeBuffer: public StackObj DEBUG_ONLY(COMMA private Scrubber) {
};

typedef LinkedListImpl<int> Offsets;
typedef ResizeableResourceHashtable<address, Offsets> SharedTrampolineRequests;
typedef ResizeableResourceHashtable<address, Offsets, AnyObj::C_HEAP, mtCompiler> SharedTrampolineRequests;

private:
enum {
Expand Down
10 changes: 7 additions & 3 deletions src/hotspot/share/classfile/classLoaderStats.hpp
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2014, 2021, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2014, 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
Expand Down Expand Up @@ -112,7 +112,7 @@ class ClassLoaderStatsClosure : public CLDClosure {
}

typedef ResourceHashtable<oop, ClassLoaderStats,
256, AnyObj::RESOURCE_AREA, mtInternal,
256, AnyObj::C_HEAP, mtStatistics,
ClassLoaderStatsClosure::oop_hash> StatsTable;

outputStream* _out;
Expand All @@ -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();
Expand Down
6 changes: 6 additions & 0 deletions src/hotspot/share/utilities/resourceHash.hpp
Expand Up @@ -30,6 +30,8 @@
#include "utilities/numberSeq.hpp"
#include "utilities/tableStatistics.hpp"

#include <type_traits>

template<typename K, typename V>
class ResourceHashtableNode : public AnyObj {
public:
Expand All @@ -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<K>::value,
"Destructor for K is only called with C_HEAP");
static_assert(ALLOC_TYPE == AnyObj::C_HEAP || std::is_trivially_destructible<V>::value,
"Destructor for V is only called with C_HEAP");
using Node = ResourceHashtableNode<K, V>;
private:
int _number_of_entries;
Expand Down