v8/test/unittests/api/resource-constraints-unittest.cc
Ulan Degenbaev 8732596c70 [ptr-compr, heap] Use system pointer size for heap limit computation
A pointer-compressed heap has the same heap limit heuristics as a 32-bit
heap. Specifically, the heap limit is restricted to 1GB due to scarce
virtual addresses space on 32-bit platforms. That limitation does not
apply for pointer-compressed heaps which can use 4GB.

This CL changes the heap limit computation to use system the pointer
size instead of the tagged pointer size. Note that the young generation
limit continues to use the tagged pointer size.

Bug: chromium:1045034
Change-Id: I9d5bb818c32a82322476e9c97feee331400ebe0f
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2042102
Reviewed-by: Igor Sheludko <ishell@chromium.org>
Commit-Queue: Ulan Degenbaev <ulan@chromium.org>
Cr-Commit-Position: refs/heads/master@{#66159}
2020-02-06 17:32:44 +00:00

58 lines
2.3 KiB
C++

// Copyright 2017 the V8 project authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "testing/gtest/include/gtest/gtest.h"
#include "include/v8-platform.h"
#include "include/v8.h"
#include "src/heap/heap.h"
namespace v8 {
TEST(ResourceConstraints, ConfigureDefaultsFromHeapSizeSmall) {
const size_t KB = static_cast<size_t>(i::KB);
const size_t MB = static_cast<size_t>(i::MB);
const size_t pm = i::Heap::kPointerMultiplier;
v8::ResourceConstraints constraints;
constraints.ConfigureDefaultsFromHeapSize(1 * MB, 1 * MB);
ASSERT_EQ(i::Heap::MinOldGenerationSize(),
constraints.max_old_generation_size_in_bytes());
ASSERT_EQ(3 * 512 * pm * KB,
constraints.max_young_generation_size_in_bytes());
ASSERT_EQ(0u, constraints.initial_old_generation_size_in_bytes());
ASSERT_EQ(0u, constraints.initial_young_generation_size_in_bytes());
}
TEST(ResourceConstraints, ConfigureDefaultsFromHeapSizeLarge) {
const size_t KB = static_cast<size_t>(i::KB);
const size_t MB = static_cast<size_t>(i::MB);
const size_t pm = i::Heap::kPointerMultiplier;
v8::ResourceConstraints constraints;
constraints.ConfigureDefaultsFromHeapSize(100u * MB, 3000u * MB);
ASSERT_EQ(3000u * MB - 3 * 8192 * pm * KB,
constraints.max_old_generation_size_in_bytes());
ASSERT_EQ(3 * 8192 * pm * KB,
constraints.max_young_generation_size_in_bytes());
ASSERT_EQ(100u * MB - 3 * 512 * pm * KB,
constraints.initial_old_generation_size_in_bytes());
ASSERT_EQ(3 * 512 * pm * KB,
constraints.initial_young_generation_size_in_bytes());
}
TEST(ResourceConstraints, ConfigureDefaults) {
const size_t KB = static_cast<size_t>(i::KB);
const size_t MB = static_cast<size_t>(i::MB);
const size_t pm = i::Heap::kPointerMultiplier;
const size_t hlm = i::Heap::kHeapLimitMultiplier;
v8::ResourceConstraints constraints;
constraints.ConfigureDefaults(2048u * MB, 0u);
ASSERT_EQ(512u * hlm * MB, constraints.max_old_generation_size_in_bytes());
ASSERT_EQ(3 * 4096 * pm * KB,
constraints.max_young_generation_size_in_bytes());
ASSERT_EQ(0u, constraints.initial_old_generation_size_in_bytes());
ASSERT_EQ(0u, constraints.initial_young_generation_size_in_bytes());
}
} // namespace v8