Skip to content

Commit dd5d4df

Browse files
author
Ivan Walulya
committed
8295658: G1: Refactor G1SegmentedArray to indicate that it is an allocator
Reviewed-by: tschatzl, sjohanss
1 parent cf65605 commit dd5d4df

19 files changed

+307
-307
lines changed

src/hotspot/share/gc/g1/g1CardSetMemory.cpp

+13-13
Original file line numberDiff line numberDiff line change
@@ -26,17 +26,17 @@
2626

2727
#include "gc/g1/g1CardSetContainers.inline.hpp"
2828
#include "gc/g1/g1CardSetMemory.inline.hpp"
29-
#include "gc/g1/g1SegmentedArray.inline.hpp"
29+
#include "gc/g1/g1MonotonicArena.inline.hpp"
3030
#include "runtime/atomic.hpp"
3131
#include "utilities/ostream.hpp"
3232

3333
G1CardSetAllocator::G1CardSetAllocator(const char* name,
3434
const G1CardSetAllocOptions* alloc_options,
35-
G1CardSetFreeList* free_segment_list) :
36-
_segmented_array(alloc_options, free_segment_list),
37-
_free_slots_list(name, &_segmented_array)
35+
SegmentFreeList* segment_free_list) :
36+
_arena(alloc_options, segment_free_list),
37+
_free_slots_list(name, &_arena)
3838
{
39-
uint slot_size = _segmented_array.slot_size();
39+
uint slot_size = _arena.slot_size();
4040
assert(slot_size >= sizeof(G1CardSetContainer), "Slot instance size %u for allocator %s too small", slot_size, name);
4141
}
4242

@@ -51,23 +51,23 @@ void G1CardSetAllocator::free(void* slot) {
5151

5252
void G1CardSetAllocator::drop_all() {
5353
_free_slots_list.reset();
54-
_segmented_array.drop_all();
54+
_arena.drop_all();
5555
}
5656

5757
size_t G1CardSetAllocator::mem_size() const {
5858
return sizeof(*this) +
59-
num_segments() * sizeof(G1CardSetSegment) +
60-
_segmented_array.num_total_slots() * _segmented_array.slot_size();
59+
num_segments() * sizeof(Segment) +
60+
_arena.num_total_slots() * _arena.slot_size();
6161
}
6262

6363
size_t G1CardSetAllocator::unused_mem_size() const {
64-
uint num_unused_slots = (_segmented_array.num_total_slots() - _segmented_array.num_allocated_slots()) +
64+
uint num_unused_slots = (_arena.num_total_slots() - _arena.num_allocated_slots()) +
6565
(uint)_free_slots_list.free_count();
66-
return num_unused_slots * _segmented_array.slot_size();
66+
return num_unused_slots * _arena.slot_size();
6767
}
6868

6969
uint G1CardSetAllocator::num_segments() const {
70-
return _segmented_array.num_segments();
70+
return _arena.num_segments();
7171
}
7272

7373
G1CardSetMemoryManager::G1CardSetMemoryManager(G1CardSetConfiguration* config,
@@ -123,8 +123,8 @@ size_t G1CardSetMemoryManager::unused_mem_size() const {
123123
return result;
124124
}
125125

126-
G1SegmentedArrayMemoryStats G1CardSetMemoryManager::memory_stats() const {
127-
G1SegmentedArrayMemoryStats result;
126+
G1MonotonicArenaMemoryStats G1CardSetMemoryManager::memory_stats() const {
127+
G1MonotonicArenaMemoryStats result;
128128
for (uint i = 0; i < num_mem_object_types(); i++) {
129129
result._num_mem_sizes[i] += _allocators[i].mem_size();
130130
result._num_segments[i] += _allocators[i].num_segments();

src/hotspot/share/gc/g1/g1CardSetMemory.hpp

+12-14
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,8 @@
2727

2828
#include "gc/g1/g1CardSet.hpp"
2929
#include "gc/g1/g1CardSetContainers.hpp"
30-
#include "gc/g1/g1SegmentedArray.hpp"
31-
#include "gc/g1/g1SegmentedArrayFreePool.hpp"
30+
#include "gc/g1/g1MonotonicArena.hpp"
31+
#include "gc/g1/g1MonotonicArenaFreePool.hpp"
3232
#include "gc/shared/freeListAllocator.hpp"
3333
#include "memory/allocation.hpp"
3434
#include "utilities/growableArray.hpp"
@@ -37,8 +37,8 @@ class G1CardSetConfiguration;
3737
class outputStream;
3838

3939
// Collects G1CardSetAllocator options/heuristics. Called by G1CardSetAllocator
40-
// to determine the next size of the allocated G1CardSetSegment.
41-
class G1CardSetAllocOptions : public G1SegmentedArrayAllocOptions {
40+
// to determine the next size of the allocated memory Segment.
41+
class G1CardSetAllocOptions : public G1MonotonicArena::AllocOptions {
4242
static const uint MinimumNumSlots = 8;
4343
static const uint MaximumNumSlots = UINT_MAX / 2;
4444

@@ -50,30 +50,28 @@ class G1CardSetAllocOptions : public G1SegmentedArrayAllocOptions {
5050
static const uint SlotAlignment = 8;
5151

5252
G1CardSetAllocOptions(uint slot_size, uint initial_num_slots = MinimumNumSlots, uint max_num_slots = MaximumNumSlots) :
53-
G1SegmentedArrayAllocOptions(mtGCCardSet, slot_size, initial_num_slots, max_num_slots, SlotAlignment) {
53+
G1MonotonicArena::AllocOptions(mtGCCardSet, slot_size, initial_num_slots, max_num_slots, SlotAlignment) {
5454
}
5555

5656
virtual uint next_num_slots(uint prev_num_slots) const override {
5757
return exponential_expand(prev_num_slots);
5858
}
5959
};
6060

61-
using G1CardSetSegment = G1SegmentedArraySegment;
62-
63-
using G1CardSetFreeList = G1SegmentedArrayFreeList;
64-
6561
// Arena-like allocator for (card set) heap memory objects.
6662
//
6763
// Allocation occurs from an internal free list of objects first. If the free list is
68-
// empty then tries to allocate from the G1SegmentedArray.
64+
// empty then tries to allocate from the G1MonotonicArena.
6965
class G1CardSetAllocator {
70-
G1SegmentedArray _segmented_array;
66+
using Segment = G1MonotonicArena::Segment;
67+
using SegmentFreeList = G1MonotonicArena::SegmentFreeList;
68+
G1MonotonicArena _arena;
7169
FreeListAllocator _free_slots_list;
7270

7371
public:
7472
G1CardSetAllocator(const char* name,
7573
const G1CardSetAllocOptions* alloc_options,
76-
G1CardSetFreeList* free_segment_list);
74+
SegmentFreeList* segment_free_list);
7775
~G1CardSetAllocator();
7876

7977
void* allocate();
@@ -91,7 +89,7 @@ class G1CardSetAllocator {
9189
uint num_segments() const;
9290
};
9391

94-
using G1CardSetFreePool = G1SegmentedArrayFreePool;
92+
using G1CardSetFreePool = G1MonotonicArenaFreePool;
9593

9694
class G1CardSetMemoryManager : public CHeapObj<mtGCCardSet> {
9795
G1CardSetConfiguration* _config;
@@ -118,7 +116,7 @@ class G1CardSetMemoryManager : public CHeapObj<mtGCCardSet> {
118116
size_t mem_size() const;
119117
size_t unused_mem_size() const;
120118

121-
G1SegmentedArrayMemoryStats memory_stats() const;
119+
G1MonotonicArenaMemoryStats memory_stats() const;
122120
};
123121

124122
#endif // SHARE_GC_G1_G1CARDSETMEMORY_HPP

src/hotspot/share/gc/g1/g1CardSetMemory.inline.hpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727

2828
#include "gc/g1/g1CardSetMemory.hpp"
2929
#include "gc/g1/g1CardSetContainers.inline.hpp"
30-
#include "gc/g1/g1SegmentedArray.inline.hpp"
30+
#include "gc/g1/g1MonotonicArena.inline.hpp"
3131
#include "utilities/globalCounter.inline.hpp"
3232
#include "utilities/ostream.hpp"
3333

src/hotspot/share/gc/g1/g1CollectedHeap.cpp

+8-8
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@
5353
#include "gc/g1/g1HotCardCache.hpp"
5454
#include "gc/g1/g1InitLogger.hpp"
5555
#include "gc/g1/g1MemoryPool.hpp"
56+
#include "gc/g1/g1MonotonicArenaFreeMemoryTask.hpp"
5657
#include "gc/g1/g1OopClosures.inline.hpp"
5758
#include "gc/g1/g1ParallelCleaning.hpp"
5859
#include "gc/g1/g1ParScanThreadState.inline.hpp"
@@ -64,7 +65,6 @@
6465
#include "gc/g1/g1RootClosures.hpp"
6566
#include "gc/g1/g1RootProcessor.hpp"
6667
#include "gc/g1/g1SATBMarkQueueSet.hpp"
67-
#include "gc/g1/g1SegmentedArrayFreeMemoryTask.hpp"
6868
#include "gc/g1/g1ServiceThread.hpp"
6969
#include "gc/g1/g1ThreadLocalData.hpp"
7070
#include "gc/g1/g1Trace.hpp"
@@ -1429,7 +1429,7 @@ G1CollectedHeap::G1CollectedHeap() :
14291429
CollectedHeap(),
14301430
_service_thread(NULL),
14311431
_periodic_gc_task(NULL),
1432-
_free_segmented_array_memory_task(NULL),
1432+
_free_arena_memory_task(NULL),
14331433
_workers(NULL),
14341434
_card_table(NULL),
14351435
_collection_pause_end(Ticks::now()),
@@ -1717,8 +1717,8 @@ jint G1CollectedHeap::initialize() {
17171717
_periodic_gc_task = new G1PeriodicGCTask("Periodic GC Task");
17181718
_service_thread->register_task(_periodic_gc_task);
17191719

1720-
_free_segmented_array_memory_task = new G1SegmentedArrayFreeMemoryTask("Card Set Free Memory Task");
1721-
_service_thread->register_task(_free_segmented_array_memory_task);
1720+
_free_arena_memory_task = new G1MonotonicArenaFreeMemoryTask("Card Set Free Memory Task");
1721+
_service_thread->register_task(_free_arena_memory_task);
17221722

17231723
// Here we allocate the dummy HeapRegion that is required by the
17241724
// G1AllocRegion class.
@@ -2612,8 +2612,8 @@ void G1CollectedHeap::gc_epilogue(bool full) {
26122612

26132613
_collection_pause_end = Ticks::now();
26142614

2615-
_free_segmented_array_memory_task->notify_new_stats(&_young_gen_card_set_stats,
2616-
&_collection_set_candidates_card_set_stats);
2615+
_free_arena_memory_task->notify_new_stats(&_young_gen_card_set_stats,
2616+
&_collection_set_candidates_card_set_stats);
26172617
}
26182618

26192619
uint G1CollectedHeap::uncommit_regions(uint region_limit) {
@@ -2922,11 +2922,11 @@ bool G1CollectedHeap::should_sample_collection_set_candidates() const {
29222922
return candidates != NULL && candidates->num_remaining() > 0;
29232923
}
29242924

2925-
void G1CollectedHeap::set_collection_set_candidates_stats(G1SegmentedArrayMemoryStats& stats) {
2925+
void G1CollectedHeap::set_collection_set_candidates_stats(G1MonotonicArenaMemoryStats& stats) {
29262926
_collection_set_candidates_card_set_stats = stats;
29272927
}
29282928

2929-
void G1CollectedHeap::set_young_gen_card_set_stats(const G1SegmentedArrayMemoryStats& stats) {
2929+
void G1CollectedHeap::set_young_gen_card_set_stats(const G1MonotonicArenaMemoryStats& stats) {
29302930
_young_gen_card_set_stats = stats;
29312931
}
29322932

src/hotspot/share/gc/g1/g1CollectedHeap.hpp

+6-6
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,8 @@
4040
#include "gc/g1/g1HeapVerifier.hpp"
4141
#include "gc/g1/g1HRPrinter.hpp"
4242
#include "gc/g1/g1MonitoringSupport.hpp"
43+
#include "gc/g1/g1MonotonicArenaFreeMemoryTask.hpp"
4344
#include "gc/g1/g1NUMA.hpp"
44-
#include "gc/g1/g1SegmentedArrayFreeMemoryTask.hpp"
4545
#include "gc/g1/g1SurvivorRegions.hpp"
4646
#include "gc/g1/g1YoungGCEvacFailureInjector.hpp"
4747
#include "gc/g1/heapRegionManager.hpp"
@@ -145,7 +145,7 @@ class G1CollectedHeap : public CollectedHeap {
145145
private:
146146
G1ServiceThread* _service_thread;
147147
G1ServiceTask* _periodic_gc_task;
148-
G1SegmentedArrayFreeMemoryTask* _free_segmented_array_memory_task;
148+
G1MonotonicArenaFreeMemoryTask* _free_arena_memory_task;
149149

150150
WorkerThreads* _workers;
151151
G1CardTable* _card_table;
@@ -162,9 +162,9 @@ class G1CollectedHeap : public CollectedHeap {
162162
HeapRegionSet _humongous_set;
163163

164164
// Young gen memory statistics before GC.
165-
G1SegmentedArrayMemoryStats _young_gen_card_set_stats;
165+
G1MonotonicArenaMemoryStats _young_gen_card_set_stats;
166166
// Collection set candidates memory statistics after GC.
167-
G1SegmentedArrayMemoryStats _collection_set_candidates_card_set_stats;
167+
G1MonotonicArenaMemoryStats _collection_set_candidates_card_set_stats;
168168

169169
// The block offset table for the G1 heap.
170170
G1BlockOffsetTable* _bot;
@@ -239,8 +239,8 @@ class G1CollectedHeap : public CollectedHeap {
239239
void set_humongous_stats(uint num_humongous_total, uint num_humongous_candidates);
240240

241241
bool should_sample_collection_set_candidates() const;
242-
void set_collection_set_candidates_stats(G1SegmentedArrayMemoryStats& stats);
243-
void set_young_gen_card_set_stats(const G1SegmentedArrayMemoryStats& stats);
242+
void set_collection_set_candidates_stats(G1MonotonicArenaMemoryStats& stats);
243+
void set_young_gen_card_set_stats(const G1MonotonicArenaMemoryStats& stats);
244244

245245
private:
246246

0 commit comments

Comments
 (0)