8253303: G1: Move static initialization of G1FromCardCache to a proper location
Reviewed-by: ayang, sjohanss
This commit is contained in:
parent
34ec1bedd1
commit
955c2e6292
@ -1682,6 +1682,7 @@ jint G1CollectedHeap::initialize() {
|
|||||||
// The G1FromCardCache reserves card with value 0 as "invalid", so the heap must not
|
// The G1FromCardCache reserves card with value 0 as "invalid", so the heap must not
|
||||||
// start within the first card.
|
// start within the first card.
|
||||||
guarantee(heap_rs.base() >= (char*)G1CardTable::card_size, "Java heap must not start within the first card.");
|
guarantee(heap_rs.base() >= (char*)G1CardTable::card_size, "Java heap must not start within the first card.");
|
||||||
|
G1FromCardCache::initialize(max_reserved_regions());
|
||||||
// Also create a G1 rem set.
|
// Also create a G1 rem set.
|
||||||
_rem_set = new G1RemSet(this, _card_table, _hot_card_cache);
|
_rem_set = new G1RemSet(this, _card_table, _hot_card_cache);
|
||||||
_rem_set->initialize(max_reserved_regions());
|
_rem_set->initialize(max_reserved_regions());
|
||||||
|
@ -23,9 +23,11 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include "precompiled.hpp"
|
#include "precompiled.hpp"
|
||||||
|
#include "gc/g1/g1ConcurrentRefine.hpp"
|
||||||
|
#include "gc/g1/g1DirtyCardQueue.hpp"
|
||||||
#include "gc/g1/g1FromCardCache.hpp"
|
#include "gc/g1/g1FromCardCache.hpp"
|
||||||
#include "gc/g1/g1RemSet.hpp"
|
|
||||||
#include "memory/padded.inline.hpp"
|
#include "memory/padded.inline.hpp"
|
||||||
|
#include "runtime/globals.hpp"
|
||||||
#include "utilities/debug.hpp"
|
#include "utilities/debug.hpp"
|
||||||
|
|
||||||
uintptr_t** G1FromCardCache::_cache = NULL;
|
uintptr_t** G1FromCardCache::_cache = NULL;
|
||||||
@ -35,16 +37,16 @@ size_t G1FromCardCache::_static_mem_size = 0;
|
|||||||
uint G1FromCardCache::_max_workers = 0;
|
uint G1FromCardCache::_max_workers = 0;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
void G1FromCardCache::initialize(uint num_par_rem_sets, uint max_reserved_regions) {
|
void G1FromCardCache::initialize(uint max_reserved_regions) {
|
||||||
guarantee(max_reserved_regions > 0, "Heap size must be valid");
|
guarantee(max_reserved_regions > 0, "Heap size must be valid");
|
||||||
guarantee(_cache == NULL, "Should not call this multiple times");
|
guarantee(_cache == NULL, "Should not call this multiple times");
|
||||||
|
|
||||||
_max_reserved_regions = max_reserved_regions;
|
_max_reserved_regions = max_reserved_regions;
|
||||||
#ifdef ASSERT
|
#ifdef ASSERT
|
||||||
_max_workers = num_par_rem_sets;
|
_max_workers = num_par_rem_sets();
|
||||||
#endif
|
#endif
|
||||||
_cache = Padded2DArray<uintptr_t, mtGC>::create_unfreeable(_max_reserved_regions,
|
_cache = Padded2DArray<uintptr_t, mtGC>::create_unfreeable(_max_reserved_regions,
|
||||||
num_par_rem_sets,
|
num_par_rem_sets(),
|
||||||
&_static_mem_size);
|
&_static_mem_size);
|
||||||
|
|
||||||
if (AlwaysPreTouch) {
|
if (AlwaysPreTouch) {
|
||||||
@ -59,7 +61,7 @@ void G1FromCardCache::invalidate(uint start_idx, size_t new_num_regions) {
|
|||||||
uint end_idx = (start_idx + (uint)new_num_regions);
|
uint end_idx = (start_idx + (uint)new_num_regions);
|
||||||
assert(end_idx <= _max_reserved_regions, "Must be within max.");
|
assert(end_idx <= _max_reserved_regions, "Must be within max.");
|
||||||
|
|
||||||
for (uint i = 0; i < G1RemSet::num_par_rem_sets(); i++) {
|
for (uint i = 0; i < num_par_rem_sets(); i++) {
|
||||||
for (uint j = start_idx; j < end_idx; j++) {
|
for (uint j = start_idx; j < end_idx; j++) {
|
||||||
set(i, j, InvalidCard);
|
set(i, j, InvalidCard);
|
||||||
}
|
}
|
||||||
@ -68,7 +70,7 @@ void G1FromCardCache::invalidate(uint start_idx, size_t new_num_regions) {
|
|||||||
|
|
||||||
#ifndef PRODUCT
|
#ifndef PRODUCT
|
||||||
void G1FromCardCache::print(outputStream* out) {
|
void G1FromCardCache::print(outputStream* out) {
|
||||||
for (uint i = 0; i < G1RemSet::num_par_rem_sets(); i++) {
|
for (uint i = 0; i < num_par_rem_sets(); i++) {
|
||||||
for (uint j = 0; j < _max_reserved_regions; j++) {
|
for (uint j = 0; j < _max_reserved_regions; j++) {
|
||||||
out->print_cr("_from_card_cache[%u][%u] = " SIZE_FORMAT ".",
|
out->print_cr("_from_card_cache[%u][%u] = " SIZE_FORMAT ".",
|
||||||
i, j, at(i, j));
|
i, j, at(i, j));
|
||||||
@ -77,8 +79,12 @@ void G1FromCardCache::print(outputStream* out) {
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
uint G1FromCardCache::num_par_rem_sets() {
|
||||||
|
return G1DirtyCardQueueSet::num_par_ids() + G1ConcurrentRefine::max_num_threads() + MAX2(ConcGCThreads, ParallelGCThreads);
|
||||||
|
}
|
||||||
|
|
||||||
void G1FromCardCache::clear(uint region_idx) {
|
void G1FromCardCache::clear(uint region_idx) {
|
||||||
uint num_par_remsets = G1RemSet::num_par_rem_sets();
|
uint num_par_remsets = num_par_rem_sets();
|
||||||
for (uint i = 0; i < num_par_remsets; i++) {
|
for (uint i = 0; i < num_par_remsets; i++) {
|
||||||
set(i, region_idx, InvalidCard);
|
set(i, region_idx, InvalidCard);
|
||||||
}
|
}
|
||||||
|
@ -54,6 +54,13 @@ private:
|
|||||||
// This means that the heap must not contain card zero.
|
// This means that the heap must not contain card zero.
|
||||||
static const uintptr_t InvalidCard = 0;
|
static const uintptr_t InvalidCard = 0;
|
||||||
|
|
||||||
|
// Gives an approximation on how many threads can be expected to add records to
|
||||||
|
// a remembered set in parallel. This is used for sizing the G1FromCardCache to
|
||||||
|
// decrease performance losses due to data structure sharing.
|
||||||
|
// Examples for quantities that influence this value are the maximum number of
|
||||||
|
// mutator threads, maximum number of concurrent refinement or GC threads.
|
||||||
|
static uint num_par_rem_sets();
|
||||||
|
|
||||||
public:
|
public:
|
||||||
static void clear(uint region_idx);
|
static void clear(uint region_idx);
|
||||||
|
|
||||||
@ -79,7 +86,7 @@ public:
|
|||||||
_cache[region_idx][worker_id] = val;
|
_cache[region_idx][worker_id] = val;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void initialize(uint num_par_rem_sets, uint max_reserved_regions);
|
static void initialize(uint max_reserved_regions);
|
||||||
|
|
||||||
static void invalidate(uint start_idx, size_t num_regions);
|
static void invalidate(uint start_idx, size_t num_regions);
|
||||||
|
|
||||||
|
@ -38,6 +38,7 @@
|
|||||||
#include "gc/g1/g1RootClosures.hpp"
|
#include "gc/g1/g1RootClosures.hpp"
|
||||||
#include "gc/g1/g1RemSet.hpp"
|
#include "gc/g1/g1RemSet.hpp"
|
||||||
#include "gc/g1/g1SharedDirtyCardQueue.hpp"
|
#include "gc/g1/g1SharedDirtyCardQueue.hpp"
|
||||||
|
#include "gc/g1/g1_globals.hpp"
|
||||||
#include "gc/g1/heapRegion.inline.hpp"
|
#include "gc/g1/heapRegion.inline.hpp"
|
||||||
#include "gc/g1/heapRegionManager.inline.hpp"
|
#include "gc/g1/heapRegionManager.inline.hpp"
|
||||||
#include "gc/g1/heapRegionRemSet.inline.hpp"
|
#include "gc/g1/heapRegionRemSet.inline.hpp"
|
||||||
@ -481,12 +482,7 @@ G1RemSet::~G1RemSet() {
|
|||||||
delete _scan_state;
|
delete _scan_state;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint G1RemSet::num_par_rem_sets() {
|
|
||||||
return G1DirtyCardQueueSet::num_par_ids() + G1ConcurrentRefine::max_num_threads() + MAX2(ConcGCThreads, ParallelGCThreads);
|
|
||||||
}
|
|
||||||
|
|
||||||
void G1RemSet::initialize(uint max_reserved_regions) {
|
void G1RemSet::initialize(uint max_reserved_regions) {
|
||||||
G1FromCardCache::initialize(num_par_rem_sets(), max_reserved_regions);
|
|
||||||
_scan_state->initialize(max_reserved_regions);
|
_scan_state->initialize(max_reserved_regions);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -70,12 +70,6 @@ private:
|
|||||||
public:
|
public:
|
||||||
|
|
||||||
typedef CardTable::CardValue CardValue;
|
typedef CardTable::CardValue CardValue;
|
||||||
// Gives an approximation on how many threads can be expected to add records to
|
|
||||||
// a remembered set in parallel. This can be used for sizing data structures to
|
|
||||||
// decrease performance losses due to data structure sharing.
|
|
||||||
// Examples for quantities that influence this value are the maximum number of
|
|
||||||
// mutator threads, maximum number of concurrent refinement or GC threads.
|
|
||||||
static uint num_par_rem_sets();
|
|
||||||
|
|
||||||
// Initialize data that depends on the heap size being known.
|
// Initialize data that depends on the heap size being known.
|
||||||
void initialize(uint max_reserved_regions);
|
void initialize(uint max_reserved_regions);
|
||||||
|
Loading…
Reference in New Issue
Block a user