8274988: G1: refine G1SegmentedArrayAllocOptions and G1CardSetAllocOptions

Reviewed-by: tschatzl, ayang
This commit is contained in:
Hamlin Li 2021-10-21 01:17:52 +00:00
parent c7a80e60e2
commit a120937e81
2 changed files with 11 additions and 8 deletions

View File

@ -39,6 +39,9 @@ class outputStream;
// Collects G1CardSetAllocator options/heuristics. Called by G1CardSetAllocator
// to determine the next size of the allocated G1CardSetBuffer.
class G1CardSetAllocOptions : public G1SegmentedArrayAllocOptions {
static const uint MinimumBufferSize = 8;
static const uint MaximumBufferSize = UINT_MAX / 2;
uint exponential_expand(uint prev_num_elems) const {
return clamp(prev_num_elems * 2, _initial_num_elems, _max_num_elems);
}

View File

@ -115,15 +115,11 @@ public:
class G1SegmentedArrayAllocOptions {
protected:
uint _elem_size;
uint _initial_num_elems;
const uint _elem_size;
const uint _initial_num_elems;
// Defines a limit to the number of elements in the buffer
uint _max_num_elems;
uint _alignment;
static const uint BufferAlignment = 4;
static const uint MinimumBufferSize = 8;
static const uint MaximumBufferSize = UINT_MAX / 2;
const uint _max_num_elems;
const uint _alignment;
public:
G1SegmentedArrayAllocOptions(uint elem_size, uint initial_num_elems, uint max_num_elems, uint alignment) :
@ -131,6 +127,10 @@ public:
_initial_num_elems(initial_num_elems),
_max_num_elems(max_num_elems),
_alignment(alignment) {
assert(_elem_size > 0, "Must be");
assert(_initial_num_elems > 0, "Must be");
assert(_max_num_elems > 0, "Must be");
assert(_alignment > 0, "Must be");
}
virtual uint next_num_elems(uint prev_num_elems) const {