Skip to content

Commit 955c2e6

Browse files
author
Thomas Schatzl
committed
8253303: G1: Move static initialization of G1FromCardCache to a proper location
Reviewed-by: ayang, sjohanss
1 parent 34ec1be commit 955c2e6

File tree

5 files changed

+23
-19
lines changed

5 files changed

+23
-19
lines changed

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

+1
Original file line numberDiff line numberDiff line change
@@ -1682,6 +1682,7 @@ jint G1CollectedHeap::initialize() {
16821682
// The G1FromCardCache reserves card with value 0 as "invalid", so the heap must not
16831683
// start within the first card.
16841684
guarantee(heap_rs.base() >= (char*)G1CardTable::card_size, "Java heap must not start within the first card.");
1685+
G1FromCardCache::initialize(max_reserved_regions());
16851686
// Also create a G1 rem set.
16861687
_rem_set = new G1RemSet(this, _card_table, _hot_card_cache);
16871688
_rem_set->initialize(max_reserved_regions());

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

+13-7
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,11 @@
2323
*/
2424

2525
#include "precompiled.hpp"
26+
#include "gc/g1/g1ConcurrentRefine.hpp"
27+
#include "gc/g1/g1DirtyCardQueue.hpp"
2628
#include "gc/g1/g1FromCardCache.hpp"
27-
#include "gc/g1/g1RemSet.hpp"
2829
#include "memory/padded.inline.hpp"
30+
#include "runtime/globals.hpp"
2931
#include "utilities/debug.hpp"
3032

3133
uintptr_t** G1FromCardCache::_cache = NULL;
@@ -35,16 +37,16 @@ size_t G1FromCardCache::_static_mem_size = 0;
3537
uint G1FromCardCache::_max_workers = 0;
3638
#endif
3739

38-
void G1FromCardCache::initialize(uint num_par_rem_sets, uint max_reserved_regions) {
40+
void G1FromCardCache::initialize(uint max_reserved_regions) {
3941
guarantee(max_reserved_regions > 0, "Heap size must be valid");
4042
guarantee(_cache == NULL, "Should not call this multiple times");
4143

4244
_max_reserved_regions = max_reserved_regions;
4345
#ifdef ASSERT
44-
_max_workers = num_par_rem_sets;
46+
_max_workers = num_par_rem_sets();
4547
#endif
4648
_cache = Padded2DArray<uintptr_t, mtGC>::create_unfreeable(_max_reserved_regions,
47-
num_par_rem_sets,
49+
num_par_rem_sets(),
4850
&_static_mem_size);
4951

5052
if (AlwaysPreTouch) {
@@ -59,7 +61,7 @@ void G1FromCardCache::invalidate(uint start_idx, size_t new_num_regions) {
5961
uint end_idx = (start_idx + (uint)new_num_regions);
6062
assert(end_idx <= _max_reserved_regions, "Must be within max.");
6163

62-
for (uint i = 0; i < G1RemSet::num_par_rem_sets(); i++) {
64+
for (uint i = 0; i < num_par_rem_sets(); i++) {
6365
for (uint j = start_idx; j < end_idx; j++) {
6466
set(i, j, InvalidCard);
6567
}
@@ -68,7 +70,7 @@ void G1FromCardCache::invalidate(uint start_idx, size_t new_num_regions) {
6870

6971
#ifndef PRODUCT
7072
void G1FromCardCache::print(outputStream* out) {
71-
for (uint i = 0; i < G1RemSet::num_par_rem_sets(); i++) {
73+
for (uint i = 0; i < num_par_rem_sets(); i++) {
7274
for (uint j = 0; j < _max_reserved_regions; j++) {
7375
out->print_cr("_from_card_cache[%u][%u] = " SIZE_FORMAT ".",
7476
i, j, at(i, j));
@@ -77,8 +79,12 @@ void G1FromCardCache::print(outputStream* out) {
7779
}
7880
#endif
7981

82+
uint G1FromCardCache::num_par_rem_sets() {
83+
return G1DirtyCardQueueSet::num_par_ids() + G1ConcurrentRefine::max_num_threads() + MAX2(ConcGCThreads, ParallelGCThreads);
84+
}
85+
8086
void G1FromCardCache::clear(uint region_idx) {
81-
uint num_par_remsets = G1RemSet::num_par_rem_sets();
87+
uint num_par_remsets = num_par_rem_sets();
8288
for (uint i = 0; i < num_par_remsets; i++) {
8389
set(i, region_idx, InvalidCard);
8490
}

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

+8-1
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,13 @@ class G1FromCardCache : public AllStatic {
5454
// This means that the heap must not contain card zero.
5555
static const uintptr_t InvalidCard = 0;
5656

57+
// Gives an approximation on how many threads can be expected to add records to
58+
// a remembered set in parallel. This is used for sizing the G1FromCardCache to
59+
// decrease performance losses due to data structure sharing.
60+
// Examples for quantities that influence this value are the maximum number of
61+
// mutator threads, maximum number of concurrent refinement or GC threads.
62+
static uint num_par_rem_sets();
63+
5764
public:
5865
static void clear(uint region_idx);
5966

@@ -79,7 +86,7 @@ class G1FromCardCache : public AllStatic {
7986
_cache[region_idx][worker_id] = val;
8087
}
8188

82-
static void initialize(uint num_par_rem_sets, uint max_reserved_regions);
89+
static void initialize(uint max_reserved_regions);
8390

8491
static void invalidate(uint start_idx, size_t num_regions);
8592

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

+1-5
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@
3838
#include "gc/g1/g1RootClosures.hpp"
3939
#include "gc/g1/g1RemSet.hpp"
4040
#include "gc/g1/g1SharedDirtyCardQueue.hpp"
41+
#include "gc/g1/g1_globals.hpp"
4142
#include "gc/g1/heapRegion.inline.hpp"
4243
#include "gc/g1/heapRegionManager.inline.hpp"
4344
#include "gc/g1/heapRegionRemSet.inline.hpp"
@@ -481,12 +482,7 @@ G1RemSet::~G1RemSet() {
481482
delete _scan_state;
482483
}
483484

484-
uint G1RemSet::num_par_rem_sets() {
485-
return G1DirtyCardQueueSet::num_par_ids() + G1ConcurrentRefine::max_num_threads() + MAX2(ConcGCThreads, ParallelGCThreads);
486-
}
487-
488485
void G1RemSet::initialize(uint max_reserved_regions) {
489-
G1FromCardCache::initialize(num_par_rem_sets(), max_reserved_regions);
490486
_scan_state->initialize(max_reserved_regions);
491487
}
492488

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

-6
Original file line numberDiff line numberDiff line change
@@ -70,12 +70,6 @@ class G1RemSet: public CHeapObj<mtGC> {
7070
public:
7171

7272
typedef CardTable::CardValue CardValue;
73-
// Gives an approximation on how many threads can be expected to add records to
74-
// a remembered set in parallel. This can be used for sizing data structures to
75-
// decrease performance losses due to data structure sharing.
76-
// Examples for quantities that influence this value are the maximum number of
77-
// mutator threads, maximum number of concurrent refinement or GC threads.
78-
static uint num_par_rem_sets();
7973

8074
// Initialize data that depends on the heap size being known.
8175
void initialize(uint max_reserved_regions);

0 commit comments

Comments
 (0)