summaryrefslogtreecommitdiff
path: root/deps/v8/test/unittests/heap/heap-controller-unittest.cc
diff options
context:
space:
mode:
Diffstat (limited to 'deps/v8/test/unittests/heap/heap-controller-unittest.cc')
-rw-r--r--deps/v8/test/unittests/heap/heap-controller-unittest.cc80
1 files changed, 41 insertions, 39 deletions
diff --git a/deps/v8/test/unittests/heap/heap-controller-unittest.cc b/deps/v8/test/unittests/heap/heap-controller-unittest.cc
index dc75820f64..b2446afa84 100644
--- a/deps/v8/test/unittests/heap/heap-controller-unittest.cc
+++ b/deps/v8/test/unittests/heap/heap-controller-unittest.cc
@@ -32,80 +32,82 @@ void CheckEqualRounded(double expected, double actual) {
EXPECT_DOUBLE_EQ(expected, actual);
}
-TEST(HeapController, HeapGrowingFactor) {
- CheckEqualRounded(HeapController::kMaxHeapGrowingFactor,
- HeapController::HeapGrowingFactor(34, 1, 4.0));
- CheckEqualRounded(3.553, HeapController::HeapGrowingFactor(45, 1, 4.0));
- CheckEqualRounded(2.830, HeapController::HeapGrowingFactor(50, 1, 4.0));
- CheckEqualRounded(1.478, HeapController::HeapGrowingFactor(100, 1, 4.0));
- CheckEqualRounded(1.193, HeapController::HeapGrowingFactor(200, 1, 4.0));
- CheckEqualRounded(1.121, HeapController::HeapGrowingFactor(300, 1, 4.0));
- CheckEqualRounded(HeapController::HeapGrowingFactor(300, 1, 4.0),
- HeapController::HeapGrowingFactor(600, 2, 4.0));
- CheckEqualRounded(HeapController::kMinHeapGrowingFactor,
- HeapController::HeapGrowingFactor(400, 1, 4.0));
+TEST_F(HeapControllerTest, HeapGrowingFactor) {
+ HeapController heap_controller(i_isolate()->heap());
+ double min_factor = heap_controller.kMinGrowingFactor;
+ double max_factor = heap_controller.kMaxGrowingFactor;
+
+ CheckEqualRounded(max_factor, heap_controller.GrowingFactor(34, 1, 4.0));
+ CheckEqualRounded(3.553, heap_controller.GrowingFactor(45, 1, 4.0));
+ CheckEqualRounded(2.830, heap_controller.GrowingFactor(50, 1, 4.0));
+ CheckEqualRounded(1.478, heap_controller.GrowingFactor(100, 1, 4.0));
+ CheckEqualRounded(1.193, heap_controller.GrowingFactor(200, 1, 4.0));
+ CheckEqualRounded(1.121, heap_controller.GrowingFactor(300, 1, 4.0));
+ CheckEqualRounded(heap_controller.GrowingFactor(300, 1, 4.0),
+ heap_controller.GrowingFactor(600, 2, 4.0));
+ CheckEqualRounded(min_factor, heap_controller.GrowingFactor(400, 1, 4.0));
}
-TEST(HeapController, MaxHeapGrowingFactor) {
- CheckEqualRounded(1.3, HeapController::MaxHeapGrowingFactor(
- HeapController::kMinOldGenerationSize * MB));
- CheckEqualRounded(1.600, HeapController::MaxHeapGrowingFactor(
- HeapController::kMaxOldGenerationSize / 2 * MB));
- CheckEqualRounded(1.999, HeapController::MaxHeapGrowingFactor(
- (HeapController::kMaxOldGenerationSize -
- Heap::kPointerMultiplier) *
- MB));
+TEST_F(HeapControllerTest, MaxHeapGrowingFactor) {
+ HeapController heap_controller(i_isolate()->heap());
CheckEqualRounded(
- 4.0,
- HeapController::MaxHeapGrowingFactor(
- static_cast<size_t>(HeapController::kMaxOldGenerationSize) * MB));
+ 1.3, heap_controller.MaxGrowingFactor(heap_controller.kMinSize * MB));
+ CheckEqualRounded(1.600, heap_controller.MaxGrowingFactor(
+ heap_controller.kMaxSize / 2 * MB));
+ CheckEqualRounded(
+ 1.999, heap_controller.MaxGrowingFactor(
+ (heap_controller.kMaxSize - Heap::kPointerMultiplier) * MB));
+ CheckEqualRounded(4.0,
+ heap_controller.MaxGrowingFactor(
+ static_cast<size_t>(heap_controller.kMaxSize) * MB));
}
TEST_F(HeapControllerTest, OldGenerationAllocationLimit) {
Heap* heap = i_isolate()->heap();
+ HeapController heap_controller(heap);
size_t old_gen_size = 128 * MB;
size_t max_old_generation_size = 512 * MB;
double gc_speed = 100;
double mutator_speed = 1;
size_t new_space_capacity = 16 * MB;
- double max_factor =
- HeapController::MaxHeapGrowingFactor(max_old_generation_size);
+ double max_factor = heap_controller.MaxGrowingFactor(max_old_generation_size);
double factor =
- HeapController::HeapGrowingFactor(gc_speed, mutator_speed, max_factor);
+ heap_controller.GrowingFactor(gc_speed, mutator_speed, max_factor);
EXPECT_EQ(static_cast<size_t>(old_gen_size * factor + new_space_capacity),
- heap->heap_controller()->CalculateOldGenerationAllocationLimit(
+ heap->heap_controller()->CalculateAllocationLimit(
old_gen_size, max_old_generation_size, gc_speed, mutator_speed,
new_space_capacity, Heap::HeapGrowingMode::kDefault));
- factor = Min(factor, HeapController::kConservativeHeapGrowingFactor);
+ factor = Min(factor, heap_controller.kConservativeGrowingFactor);
EXPECT_EQ(static_cast<size_t>(old_gen_size * factor + new_space_capacity),
- heap->heap_controller()->CalculateOldGenerationAllocationLimit(
+ heap->heap_controller()->CalculateAllocationLimit(
old_gen_size, max_old_generation_size, gc_speed, mutator_speed,
new_space_capacity, Heap::HeapGrowingMode::kSlow));
- factor = Min(factor, HeapController::kConservativeHeapGrowingFactor);
+ factor = Min(factor, heap_controller.kConservativeGrowingFactor);
EXPECT_EQ(static_cast<size_t>(old_gen_size * factor + new_space_capacity),
- heap->heap_controller()->CalculateOldGenerationAllocationLimit(
+ heap->heap_controller()->CalculateAllocationLimit(
old_gen_size, max_old_generation_size, gc_speed, mutator_speed,
new_space_capacity, Heap::HeapGrowingMode::kConservative));
- factor = HeapController::kMinHeapGrowingFactor;
+ factor = heap_controller.kMinGrowingFactor;
EXPECT_EQ(static_cast<size_t>(old_gen_size * factor + new_space_capacity),
- heap->heap_controller()->CalculateOldGenerationAllocationLimit(
+ heap->heap_controller()->CalculateAllocationLimit(
old_gen_size, max_old_generation_size, gc_speed, mutator_speed,
new_space_capacity, Heap::HeapGrowingMode::kMinimal));
}
-TEST(HeapController, MaxOldGenerationSize) {
+TEST_F(HeapControllerTest, MaxOldGenerationSize) {
+ HeapController heap_controller(i_isolate()->heap());
uint64_t configurations[][2] = {
- {0, HeapController::kMinOldGenerationSize},
- {512, HeapController::kMinOldGenerationSize},
+ {0, heap_controller.kMinSize},
+ {512, heap_controller.kMinSize},
{1 * GB, 256 * Heap::kPointerMultiplier},
{2 * static_cast<uint64_t>(GB), 512 * Heap::kPointerMultiplier},
- {4 * static_cast<uint64_t>(GB), HeapController::kMaxOldGenerationSize},
- {8 * static_cast<uint64_t>(GB), HeapController::kMaxOldGenerationSize}};
+ {4 * static_cast<uint64_t>(GB), heap_controller.kMaxSize},
+ {8 * static_cast<uint64_t>(GB), heap_controller.kMaxSize}};
for (auto configuration : configurations) {
ASSERT_EQ(configuration[1],