Commit 58d78bfe authored by Ulan Degenbaev's avatar Ulan Degenbaev Committed by Commit Bot

[heap] Provide --max-heap-size flag

The flag configures both the young and old generation limits.

Bug: v8:9306
Change-Id: Ib94dcb6dc014864248a5926f585b54a83db28063
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/1679500Reviewed-by: 's avatarHannes Payer <hpayer@chromium.org>
Reviewed-by: 's avatarMichael Lippautz <mlippautz@chromium.org>
Commit-Queue: Ulan Degenbaev <ulan@chromium.org>
Cr-Commit-Position: refs/heads/master@{#62440}
parent 933f23f6
......@@ -742,6 +742,11 @@ DEFINE_BOOL(experimental_new_space_growth_heuristic, false,
"Grow the new space based on the percentage of survivors instead "
"of their absolute value.")
DEFINE_SIZE_T(max_old_space_size, 0, "max size of the old space (in Mbytes)")
DEFINE_SIZE_T(
max_heap_size, 0,
"max size of the heap (in Mbytes) "
"both max_semi_space_size and max_old_space_size take precedence. "
"All three flags cannot be specified at the same time.")
DEFINE_BOOL(huge_max_old_generation_size, false,
"Increase max size of the old space to 4 GB for x64 systems with"
"the physical memory bigger than 16 GB")
......
......@@ -4409,7 +4409,7 @@ void Heap::IterateBuiltins(RootVisitor* v) {
}
void Heap::ConfigureHeap(const v8::ResourceConstraints& constraints) {
// Initialize max_semi_space_size_.
// Initialize max_semi_space_size_.
{
if (constraints.max_young_generation_size_in_bytes() > 0) {
max_semi_space_size_ = SemiSpaceSizeFromYoungGenerationSize(
......@@ -4417,6 +4417,20 @@ void Heap::ConfigureHeap(const v8::ResourceConstraints& constraints) {
}
if (FLAG_max_semi_space_size > 0) {
max_semi_space_size_ = static_cast<size_t>(FLAG_max_semi_space_size) * MB;
} else if (FLAG_max_heap_size > 0) {
size_t max_heap_size = static_cast<size_t>(FLAG_max_heap_size) * MB;
size_t young_generation_size, old_generation_size;
if (FLAG_max_old_space_size > 0) {
old_generation_size = static_cast<size_t>(FLAG_max_old_space_size) * MB;
young_generation_size = max_heap_size > old_generation_size
? max_heap_size - old_generation_size
: 0;
} else {
GenerationSizesFromHeapSize(max_heap_size, &young_generation_size,
&old_generation_size);
}
max_semi_space_size_ =
SemiSpaceSizeFromYoungGenerationSize(young_generation_size);
}
if (FLAG_stress_compaction) {
// This will cause more frequent GCs when stressing.
......@@ -4440,6 +4454,13 @@ void Heap::ConfigureHeap(const v8::ResourceConstraints& constraints) {
if (FLAG_max_old_space_size > 0) {
max_old_generation_size_ =
static_cast<size_t>(FLAG_max_old_space_size) * MB;
} else if (FLAG_max_heap_size > 0) {
size_t max_heap_size = static_cast<size_t>(FLAG_max_heap_size) * MB;
size_t young_generation_size =
YoungGenerationSizeFromSemiSpaceSize(max_semi_space_size_);
max_old_generation_size_ = max_heap_size > young_generation_size
? max_heap_size - young_generation_size
: 0;
}
max_old_generation_size_ =
Max(max_old_generation_size_, MinOldGenerationSize());
......@@ -4447,6 +4468,9 @@ void Heap::ConfigureHeap(const v8::ResourceConstraints& constraints) {
RoundDown<Page::kPageSize>(max_old_generation_size_);
}
CHECK_IMPLIES(FLAG_max_heap_size > 0,
FLAG_max_semi_space_size == 0 || FLAG_max_old_space_size == 0);
// Initialize initial_semispace_size_.
{
if (max_semi_space_size_ == kMaxSemiSpaceSize) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment