summaryrefslogtreecommitdiff
path: root/deps/v8/test/unittests/heap/heap-controller-unittest.cc
diff options
context:
space:
mode:
authorMichaël Zasso <targos@protonmail.com>2019-08-01 08:38:30 +0200
committerMichaël Zasso <targos@protonmail.com>2019-08-01 12:53:56 +0200
commit2dcc3665abf57c3607cebffdeeca062f5894885d (patch)
tree4f560748132edcfb4c22d6f967a7e80d23d7ea2c /deps/v8/test/unittests/heap/heap-controller-unittest.cc
parent1ee47d550c6de132f06110aa13eceb7551d643b3 (diff)
downloadnode-new-2dcc3665abf57c3607cebffdeeca062f5894885d.tar.gz
deps: update V8 to 7.6.303.28
PR-URL: https://github.com/nodejs/node/pull/28016 Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Refael Ackermann (רפאל פלחי) <refack@gmail.com> Reviewed-By: Rich Trott <rtrott@gmail.com> Reviewed-By: Michael Dawson <michael_dawson@ca.ibm.com> Reviewed-By: Jiawen Geng <technicalcute@gmail.com>
Diffstat (limited to 'deps/v8/test/unittests/heap/heap-controller-unittest.cc')
-rw-r--r--deps/v8/test/unittests/heap/heap-controller-unittest.cc121
1 files changed, 58 insertions, 63 deletions
diff --git a/deps/v8/test/unittests/heap/heap-controller-unittest.cc b/deps/v8/test/unittests/heap/heap-controller-unittest.cc
index d3bb177aa3..445c49052c 100644
--- a/deps/v8/test/unittests/heap/heap-controller-unittest.cc
+++ b/deps/v8/test/unittests/heap/heap-controller-unittest.cc
@@ -6,11 +6,11 @@
#include <iostream>
#include <limits>
-#include "src/objects-inl.h"
-#include "src/objects.h"
+#include "src/objects/objects-inl.h"
+#include "src/objects/objects.h"
-#include "src/handles-inl.h"
-#include "src/handles.h"
+#include "src/handles/handles-inl.h"
+#include "src/handles/handles.h"
#include "src/heap/heap-controller.h"
#include "test/unittests/test-utils.h"
@@ -19,7 +19,7 @@
namespace v8 {
namespace internal {
-using HeapControllerTest = TestWithIsolate;
+using MemoryControllerTest = TestWithIsolate;
double Round(double x) {
// Round to three digits.
@@ -32,86 +32,81 @@ void CheckEqualRounded(double expected, double actual) {
EXPECT_DOUBLE_EQ(expected, actual);
}
-TEST_F(HeapControllerTest, HeapGrowingFactor) {
- HeapController heap_controller(i_isolate()->heap());
- double min_factor = heap_controller.min_growing_factor_;
- double max_factor = heap_controller.max_growing_factor_;
-
- 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));
+namespace {
+
+using V8Controller = MemoryController<V8HeapTrait>;
+
+} // namespace
+
+TEST_F(MemoryControllerTest, HeapGrowingFactor) {
+ CheckEqualRounded(V8HeapTrait::kMaxGrowingFactor,
+ V8Controller::DynamicGrowingFactor(34, 1, 4.0));
+ CheckEqualRounded(3.553, V8Controller::DynamicGrowingFactor(45, 1, 4.0));
+ CheckEqualRounded(2.830, V8Controller::DynamicGrowingFactor(50, 1, 4.0));
+ CheckEqualRounded(1.478, V8Controller::DynamicGrowingFactor(100, 1, 4.0));
+ CheckEqualRounded(1.193, V8Controller::DynamicGrowingFactor(200, 1, 4.0));
+ CheckEqualRounded(1.121, V8Controller::DynamicGrowingFactor(300, 1, 4.0));
+ CheckEqualRounded(V8Controller::DynamicGrowingFactor(300, 1, 4.0),
+ V8Controller::DynamicGrowingFactor(600, 2, 4.0));
+ CheckEqualRounded(V8HeapTrait::kMinGrowingFactor,
+ V8Controller::DynamicGrowingFactor(400, 1, 4.0));
}
-TEST_F(HeapControllerTest, MaxHeapGrowingFactor) {
- HeapController heap_controller(i_isolate()->heap());
+TEST_F(MemoryControllerTest, MaxHeapGrowingFactor) {
+ CheckEqualRounded(1.3,
+ V8Controller::MaxGrowingFactor(V8HeapTrait::kMinSize * MB));
CheckEqualRounded(
- 1.3, heap_controller.MaxGrowingFactor(HeapController::kMinSize * MB));
- CheckEqualRounded(1.600, heap_controller.MaxGrowingFactor(
- HeapController::kMaxSize / 2 * MB));
+ 1.600, V8Controller::MaxGrowingFactor(V8HeapTrait::kMaxSize / 2 * MB));
CheckEqualRounded(
- 1.999, heap_controller.MaxGrowingFactor(
- (HeapController::kMaxSize - Heap::kPointerMultiplier) * MB));
- CheckEqualRounded(4.0,
- heap_controller.MaxGrowingFactor(
- static_cast<size_t>(HeapController::kMaxSize) * MB));
+ 1.999, V8Controller::MaxGrowingFactor(
+ (V8HeapTrait::kMaxSize - Heap::kPointerMultiplier) * MB));
+ CheckEqualRounded(4.0, V8Controller::MaxGrowingFactor(
+ static_cast<size_t>(V8HeapTrait::kMaxSize) * MB));
}
-TEST_F(HeapControllerTest, OldGenerationAllocationLimit) {
+TEST_F(MemoryControllerTest, 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 = heap_controller.MaxGrowingFactor(max_old_generation_size);
- double factor =
- heap_controller.GrowingFactor(gc_speed, mutator_speed, max_factor);
+ double factor = V8Controller::GrowingFactor(heap, max_old_generation_size,
+ gc_speed, mutator_speed);
- EXPECT_EQ(
- static_cast<size_t>(old_gen_size * factor + new_space_capacity),
- heap->heap_controller()->CalculateAllocationLimit(
- old_gen_size, max_old_generation_size, max_factor, gc_speed,
- mutator_speed, new_space_capacity, Heap::HeapGrowingMode::kDefault));
+ EXPECT_EQ(static_cast<size_t>(old_gen_size * factor + new_space_capacity),
+ V8Controller::CalculateAllocationLimit(
+ heap, old_gen_size, max_old_generation_size, new_space_capacity,
+ factor, Heap::HeapGrowingMode::kDefault));
- factor = Min(factor, heap_controller.conservative_growing_factor_);
- EXPECT_EQ(
- static_cast<size_t>(old_gen_size * factor + new_space_capacity),
- heap->heap_controller()->CalculateAllocationLimit(
- old_gen_size, max_old_generation_size, max_factor, gc_speed,
- mutator_speed, new_space_capacity, Heap::HeapGrowingMode::kSlow));
+ factor = Min(factor, V8HeapTrait::kConservativeGrowingFactor);
+ EXPECT_EQ(static_cast<size_t>(old_gen_size * factor + new_space_capacity),
+ V8Controller::CalculateAllocationLimit(
+ heap, old_gen_size, max_old_generation_size, new_space_capacity,
+ factor, Heap::HeapGrowingMode::kSlow));
+
+ factor = Min(factor, V8HeapTrait::kConservativeGrowingFactor);
+ EXPECT_EQ(static_cast<size_t>(old_gen_size * factor + new_space_capacity),
+ V8Controller::CalculateAllocationLimit(
+ heap, old_gen_size, max_old_generation_size, new_space_capacity,
+ factor, Heap::HeapGrowingMode::kConservative));
- factor = Min(factor, heap_controller.conservative_growing_factor_);
+ factor = V8HeapTrait::kMinGrowingFactor;
EXPECT_EQ(static_cast<size_t>(old_gen_size * factor + new_space_capacity),
- heap->heap_controller()->CalculateAllocationLimit(
- old_gen_size, max_old_generation_size, max_factor, gc_speed,
- mutator_speed, new_space_capacity,
- Heap::HeapGrowingMode::kConservative));
-
- factor = heap_controller.min_growing_factor_;
- EXPECT_EQ(
- static_cast<size_t>(old_gen_size * factor + new_space_capacity),
- heap->heap_controller()->CalculateAllocationLimit(
- old_gen_size, max_old_generation_size, max_factor, gc_speed,
- mutator_speed, new_space_capacity, Heap::HeapGrowingMode::kMinimal));
+ V8Controller::CalculateAllocationLimit(
+ heap, old_gen_size, max_old_generation_size, new_space_capacity,
+ factor, Heap::HeapGrowingMode::kMinimal));
}
-TEST_F(HeapControllerTest, MaxOldGenerationSize) {
- HeapController heap_controller(i_isolate()->heap());
+TEST_F(MemoryControllerTest, MaxOldGenerationSize) {
uint64_t configurations[][2] = {
- {0, HeapController::kMinSize},
- {512, HeapController::kMinSize},
+ {0, V8HeapTrait::kMinSize},
+ {512, V8HeapTrait::kMinSize},
{1 * GB, 256 * Heap::kPointerMultiplier},
{2 * static_cast<uint64_t>(GB), 512 * Heap::kPointerMultiplier},
- {4 * static_cast<uint64_t>(GB), HeapController::kMaxSize},
- {8 * static_cast<uint64_t>(GB), HeapController::kMaxSize}};
+ {4 * static_cast<uint64_t>(GB), V8HeapTrait::kMaxSize},
+ {8 * static_cast<uint64_t>(GB), V8HeapTrait::kMaxSize}};
for (auto configuration : configurations) {
ASSERT_EQ(configuration[1],