8297872: Non-local G1MonotonicArenaFreePool::_freelist_pool has non-trivial ctor/dtor

Co-authored-by: Thomas Schatzl <tschatzl@openjdk.org>
Reviewed-by: kbarrett, tschatzl
This commit is contained in:
Ivan Walulya 2022-12-05 07:16:56 +00:00
parent 3b3bbe5487
commit 61b7093123
9 changed files with 25 additions and 20 deletions

View File

@ -1466,6 +1466,7 @@ G1CollectedHeap::G1CollectedHeap() :
_hot_card_cache(NULL),
_rem_set(NULL),
_card_set_config(),
_card_set_freelist_pool(G1CardSetConfiguration::num_mem_object_types()),
_cm(NULL),
_cm_thread(NULL),
_cr(NULL),

View File

@ -41,6 +41,7 @@
#include "gc/g1/g1HRPrinter.hpp"
#include "gc/g1/g1MonitoringSupport.hpp"
#include "gc/g1/g1MonotonicArenaFreeMemoryTask.hpp"
#include "gc/g1/g1MonotonicArenaFreePool.hpp"
#include "gc/g1/g1NUMA.hpp"
#include "gc/g1/g1SurvivorRegions.hpp"
#include "gc/g1/g1YoungGCEvacFailureInjector.hpp"
@ -787,6 +788,8 @@ private:
// Global card set configuration
G1CardSetConfiguration _card_set_config;
G1MonotonicArenaFreePool _card_set_freelist_pool;
public:
// After a collection pause, reset eden and the collection set.
void clear_eden();
@ -913,6 +916,9 @@ public:
// The remembered set.
G1RemSet* rem_set() const { return _rem_set; }
const G1MonotonicArenaFreePool* card_set_freelist_pool() const { return &_card_set_freelist_pool; }
G1MonotonicArenaFreePool* card_set_freelist_pool() { return &_card_set_freelist_pool; }
inline G1GCPhaseTimes* phase_times() const;
const G1CollectionSet* collection_set() const { return &_collection_set; }

View File

@ -3052,8 +3052,10 @@ G1PrintRegionLivenessInfoClosure::~G1PrintRegionLivenessInfoClosure() {
return;
}
G1CollectedHeap* g1h = G1CollectedHeap::heap();
_total_remset_bytes += g1h->card_set_freelist_pool()->mem_size();
// add static memory usages to remembered set sizes
_total_remset_bytes += G1CardSetFreePool::free_list_pool()->mem_size() + HeapRegionRemSet::static_mem_size();
_total_remset_bytes += HeapRegionRemSet::static_mem_size();
// Print the footer of the output.
log_trace(gc, liveness)(G1PPRL_LINE_PREFIX);
log_trace(gc, liveness)(G1PPRL_LINE_PREFIX

View File

@ -27,6 +27,7 @@
#include "gc/g1/g1CardSetMemory.inline.hpp"
#include "gc/g1/g1CollectedHeap.hpp"
#include "gc/g1/g1MonotonicArenaFreeMemoryTask.hpp"
#include "gc/g1/g1MonotonicArenaFreePool.hpp"
#include "gc/g1/g1_globals.hpp"
#include "gc/g1/heapRegionRemSet.hpp"
#include "gc/shared/gc_globals.hpp"
@ -53,7 +54,9 @@ bool G1MonotonicArenaFreeMemoryTask::calculate_return_infos(jlong deadline) {
// Ignore the deadline in this step as it is very short.
G1MonotonicArenaMemoryStats used = _total_used;
G1MonotonicArenaMemoryStats free = G1MonotonicArenaFreePool::free_list_sizes();
G1CollectedHeap* g1h = G1CollectedHeap::heap();
G1MonotonicArenaFreePool* freelist_pool = g1h->card_set_freelist_pool();
G1MonotonicArenaMemoryStats free = freelist_pool->memory_sizes();
_return_info = new G1ReturnMemoryProcessorSet(used.num_pools());
for (uint i = 0; i < used.num_pools(); i++) {
@ -69,7 +72,7 @@ bool G1MonotonicArenaFreeMemoryTask::calculate_return_infos(jlong deadline) {
_return_info->append(new G1ReturnMemoryProcessor(return_to_vm_size));
}
G1MonotonicArenaFreePool::update_unlink_processors(_return_info);
freelist_pool->update_unlink_processors(_return_info);
return false;
}

View File

@ -44,10 +44,9 @@ void G1MonotonicArenaMemoryStats::clear() {
}
void G1MonotonicArenaFreePool::update_unlink_processors(G1ReturnMemoryProcessorSet* unlink_processor) {
uint num_free_lists = _freelist_pool.num_free_lists();
for (uint i = 0; i < num_free_lists; i++) {
unlink_processor->at(i)->visit_free_list(_freelist_pool.free_list(i));
for (uint i = 0; i < num_free_lists(); i++) {
unlink_processor->at(i)->visit_free_list(free_list(i));
}
}
@ -148,8 +147,6 @@ bool G1MonotonicArenaFreePool::G1ReturnMemoryProcessor::return_to_os(jlong deadl
return _first != nullptr;
}
G1MonotonicArenaFreePool G1MonotonicArenaFreePool::_freelist_pool(G1CardSetConfiguration::num_mem_object_types());
G1MonotonicArenaFreePool::G1MonotonicArenaFreePool(uint num_free_lists) :
_num_free_lists(num_free_lists) {
@ -184,8 +181,8 @@ size_t G1MonotonicArenaFreePool::mem_size() const {
return result;
}
void G1MonotonicArenaFreePool::print_on(outputStream* out) {
out->print_cr(" Free Pool: size %zu", free_list_pool()->mem_size());
void G1MonotonicArenaFreePool::print_on(outputStream* out) const {
out->print_cr(" Free Pool: size %zu", mem_size());
for (uint i = 0; i < _num_free_lists; i++) {
FormatBuffer<> fmt(" %s", G1CardSetConfiguration::mem_object_type_name_str(i));
_free_lists[i].print_on(out, fmt);

View File

@ -58,20 +58,15 @@ public:
// e.g. G1CardSetAllocators::_arena
class G1MonotonicArenaFreePool {
using SegmentFreeList = G1MonotonicArena::SegmentFreeList;
// The global free pool.
static G1MonotonicArenaFreePool _freelist_pool;
const uint _num_free_lists;
SegmentFreeList* _free_lists;
public:
static G1MonotonicArenaFreePool* free_list_pool() { return &_freelist_pool; }
static G1MonotonicArenaMemoryStats free_list_sizes() { return _freelist_pool.memory_sizes(); }
class G1ReturnMemoryProcessor;
typedef GrowableArrayCHeap<G1ReturnMemoryProcessor*, mtGC> G1ReturnMemoryProcessorSet;
static void update_unlink_processors(G1ReturnMemoryProcessorSet* unlink_processors);
void update_unlink_processors(G1ReturnMemoryProcessorSet* unlink_processors);
explicit G1MonotonicArenaFreePool(uint num_free_lists);
~G1MonotonicArenaFreePool();
@ -86,7 +81,7 @@ public:
G1MonotonicArenaMemoryStats memory_sizes() const;
size_t mem_size() const;
void print_on(outputStream* out);
void print_on(outputStream* out) const;
};
// Data structure containing current in-progress state for returning memory to the

View File

@ -285,7 +285,8 @@ public:
rem_set->occupied());
HeapRegionRemSet::print_static_mem_size(out);
G1CardSetFreePool::free_list_pool()->print_on(out);
G1CollectedHeap* g1h = G1CollectedHeap::heap();
g1h->card_set_freelist_pool()->print_on(out);
// Code root statistics
HeapRegionRemSet* max_code_root_rem_set = max_code_root_mem_sz_region()->rem_set();

View File

@ -59,7 +59,7 @@ HeapRegionRemSet::HeapRegionRemSet(HeapRegion* hr,
G1CardSetConfiguration* config) :
_m(Mutex::service - 1, FormatBuffer<128>("HeapRegionRemSet#%u_lock", hr->hrm_index())),
_code_roots(),
_card_set_mm(config, G1MonotonicArenaFreePool::free_list_pool()),
_card_set_mm(config, G1CollectedHeap::heap()->card_set_freelist_pool()),
_card_set(config, &_card_set_mm),
_hr(hr),
_state(Untracked) { }

View File

@ -141,7 +141,7 @@ public:
// Returns the memory occupancy of all static data structures associated
// with remembered sets.
static size_t static_mem_size() {
return G1CardSet::static_mem_size() + G1CodeRootSet::static_mem_size() + sizeof(G1CardSetFreePool);
return G1CardSet::static_mem_size() + G1CodeRootSet::static_mem_size();
}
static void print_static_mem_size(outputStream* out);