Skip to content
This repository was archived by the owner on Aug 27, 2022. It is now read-only.
/ lanai Public archive

Commit 1d687b3

Browse files
committedApr 6, 2020
8242212: Shenandoah: initialize ShenandoahHeuristics::_region_data eagerly
Reviewed-by: rkennke
1 parent 185f372 commit 1d687b3

File tree

3 files changed

+10
-24
lines changed

3 files changed

+10
-24
lines changed
 

‎src/hotspot/share/gc/shenandoah/shenandoahHeap.cpp

+3-2
Original file line numberDiff line numberDiff line change
@@ -144,8 +144,6 @@ class ShenandoahPretouchBitmapTask : public AbstractGangTask {
144144
};
145145

146146
jint ShenandoahHeap::initialize() {
147-
initialize_heuristics();
148-
149147
//
150148
// Figure out heap sizing
151149
//
@@ -167,6 +165,9 @@ jint ShenandoahHeap::initialize() {
167165

168166
_num_regions = ShenandoahHeapRegion::region_count();
169167

168+
// Now we know the number of regions, initialize the heuristics.
169+
initialize_heuristics();
170+
170171
size_t num_committed_regions = init_byte_size / reg_size_bytes;
171172
num_committed_regions = MIN2(num_committed_regions, _num_regions);
172173
assert(num_committed_regions <= _num_regions, "sanity");

‎src/hotspot/share/gc/shenandoah/shenandoahHeuristics.cpp

+7-19
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,6 @@ int ShenandoahHeuristics::compare_by_garbage(RegionData a, RegionData b) {
4444

4545
ShenandoahHeuristics::ShenandoahHeuristics() :
4646
_region_data(NULL),
47-
_region_data_size(0),
4847
_degenerated_cycles_in_a_row(0),
4948
_successful_cycles_in_a_row(0),
5049
_bytes_in_cset(0),
@@ -59,26 +58,15 @@ ShenandoahHeuristics::ShenandoahHeuristics() :
5958
if (!ClassUnloadingWithConcurrentMark) {
6059
FLAG_SET_DEFAULT(ShenandoahUnloadClassesFrequency, 0);
6160
}
62-
}
6361

64-
ShenandoahHeuristics::~ShenandoahHeuristics() {
65-
if (_region_data != NULL) {
66-
FREE_C_HEAP_ARRAY(RegionGarbage, _region_data);
67-
}
62+
size_t num_regions = ShenandoahHeap::heap()->num_regions();
63+
assert(num_regions > 0, "Sanity");
64+
65+
_region_data = NEW_C_HEAP_ARRAY(RegionData, num_regions, mtGC);
6866
}
6967

70-
ShenandoahHeuristics::RegionData* ShenandoahHeuristics::get_region_data_cache(size_t num) {
71-
RegionData* res = _region_data;
72-
if (res == NULL) {
73-
res = NEW_C_HEAP_ARRAY(RegionData, num, mtGC);
74-
_region_data = res;
75-
_region_data_size = num;
76-
} else if (_region_data_size < num) {
77-
res = REALLOC_C_HEAP_ARRAY(RegionData, _region_data, num, mtGC);
78-
_region_data = res;
79-
_region_data_size = num;
80-
}
81-
return res;
68+
ShenandoahHeuristics::~ShenandoahHeuristics() {
69+
FREE_C_HEAP_ARRAY(RegionGarbage, _region_data);
8270
}
8371

8472
void ShenandoahHeuristics::choose_collection_set(ShenandoahCollectionSet* collection_set) {
@@ -93,7 +81,7 @@ void ShenandoahHeuristics::choose_collection_set(ShenandoahCollectionSet* collec
9381

9482
size_t num_regions = heap->num_regions();
9583

96-
RegionData* candidates = get_region_data_cache(num_regions);
84+
RegionData* candidates = _region_data;
9785

9886
size_t cand_idx = 0;
9987

‎src/hotspot/share/gc/shenandoah/shenandoahHeuristics.hpp

-3
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,6 @@ class ShenandoahHeuristics : public CHeapObj<mtGC> {
7878
} RegionData;
7979

8080
RegionData* _region_data;
81-
size_t _region_data_size;
8281

8382
uint _degenerated_cycles_in_a_row;
8483
uint _successful_cycles_in_a_row;
@@ -97,8 +96,6 @@ class ShenandoahHeuristics : public CHeapObj<mtGC> {
9796

9897
static int compare_by_garbage(RegionData a, RegionData b);
9998

100-
RegionData* get_region_data_cache(size_t num);
101-
10299
virtual void choose_collection_set_from_regiondata(ShenandoahCollectionSet* set,
103100
RegionData* data, size_t data_size,
104101
size_t free) = 0;

0 commit comments

Comments
 (0)