| OLD | NEW |
| 1 // Copyright 2014 the V8 project authors. All rights reserved. | 1 // Copyright 2014 the V8 project authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include <cmath> | 5 #include <cmath> |
| 6 #include <iostream> | 6 #include <iostream> |
| 7 #include <limits> | 7 #include <limits> |
| 8 | 8 |
| 9 #include "src/objects.h" | 9 #include "src/objects.h" |
| 10 #include "src/objects-inl.h" | 10 #include "src/objects-inl.h" |
| (...skipping 15 matching lines...) Expand all Loading... |
| 26 | 26 |
| 27 void CheckEqualRounded(double expected, double actual) { | 27 void CheckEqualRounded(double expected, double actual) { |
| 28 expected = Round(expected); | 28 expected = Round(expected); |
| 29 actual = Round(actual); | 29 actual = Round(actual); |
| 30 EXPECT_DOUBLE_EQ(expected, actual); | 30 EXPECT_DOUBLE_EQ(expected, actual); |
| 31 } | 31 } |
| 32 | 32 |
| 33 | 33 |
| 34 TEST(Heap, HeapGrowingFactor) { | 34 TEST(Heap, HeapGrowingFactor) { |
| 35 CheckEqualRounded(Heap::kMaxHeapGrowingFactor, | 35 CheckEqualRounded(Heap::kMaxHeapGrowingFactor, |
| 36 Heap::HeapGrowingFactor(34, 1)); | 36 Heap::HeapGrowingFactor(34, 1, 4.0)); |
| 37 CheckEqualRounded(3.553, Heap::HeapGrowingFactor(45, 1)); | 37 CheckEqualRounded(3.553, Heap::HeapGrowingFactor(45, 1, 4.0)); |
| 38 CheckEqualRounded(2.830, Heap::HeapGrowingFactor(50, 1)); | 38 CheckEqualRounded(2.830, Heap::HeapGrowingFactor(50, 1, 4.0)); |
| 39 CheckEqualRounded(1.478, Heap::HeapGrowingFactor(100, 1)); | 39 CheckEqualRounded(1.478, Heap::HeapGrowingFactor(100, 1, 4.0)); |
| 40 CheckEqualRounded(1.193, Heap::HeapGrowingFactor(200, 1)); | 40 CheckEqualRounded(1.193, Heap::HeapGrowingFactor(200, 1, 4.0)); |
| 41 CheckEqualRounded(1.121, Heap::HeapGrowingFactor(300, 1)); | 41 CheckEqualRounded(1.121, Heap::HeapGrowingFactor(300, 1, 4.0)); |
| 42 CheckEqualRounded(Heap::HeapGrowingFactor(300, 1), | 42 CheckEqualRounded(Heap::HeapGrowingFactor(300, 1, 4.0), |
| 43 Heap::HeapGrowingFactor(600, 2)); | 43 Heap::HeapGrowingFactor(600, 2, 4.0)); |
| 44 CheckEqualRounded(Heap::kMinHeapGrowingFactor, | 44 CheckEqualRounded(Heap::kMinHeapGrowingFactor, |
| 45 Heap::HeapGrowingFactor(400, 1)); | 45 Heap::HeapGrowingFactor(400, 1, 4.0)); |
| 46 } |
| 47 |
| 48 TEST(Heap, MaxHeapGrowingFactor) { |
| 49 CheckEqualRounded( |
| 50 1.3, Heap::MaxHeapGrowingFactor(Heap::kMinOldGenerationSize * MB)); |
| 51 CheckEqualRounded(1.6, Heap::MaxHeapGrowingFactor( |
| 52 ((Heap::kMaxOldGenerationSize - 1) / 2) * MB)); |
| 53 CheckEqualRounded( |
| 54 2.0, Heap::MaxHeapGrowingFactor((Heap::kMaxOldGenerationSize - 1) * MB)); |
| 55 CheckEqualRounded(4.0, |
| 56 Heap::MaxHeapGrowingFactor( |
| 57 static_cast<size_t>(Heap::kMaxOldGenerationSize) * MB)); |
| 46 } | 58 } |
| 47 | 59 |
| 48 TEST(Heap, SemiSpaceSize) { | 60 TEST(Heap, SemiSpaceSize) { |
| 49 uint64_t configurations[][2] = { | 61 uint64_t configurations[][2] = { |
| 50 {0, 1 * i::Heap::kPointerMultiplier}, | 62 {0, 1 * i::Heap::kPointerMultiplier}, |
| 51 {512 * i::MB, 1 * i::Heap::kPointerMultiplier}, | 63 {512 * i::MB, 1 * i::Heap::kPointerMultiplier}, |
| 52 {1 * i::GB, 3 * i::Heap::kPointerMultiplier}, | 64 {1 * i::GB, 3 * i::Heap::kPointerMultiplier}, |
| 53 {2 * static_cast<uint64_t>(i::GB), i::Heap::kMaxSemiSpaceSize}, | 65 {2 * static_cast<uint64_t>(i::GB), i::Heap::kMaxSemiSpaceSize}, |
| 54 {4 * static_cast<uint64_t>(i::GB), i::Heap::kMaxSemiSpaceSize}, | 66 {4 * static_cast<uint64_t>(i::GB), i::Heap::kMaxSemiSpaceSize}, |
| 55 {8 * static_cast<uint64_t>(i::GB), i::Heap::kMaxSemiSpaceSize}}; | 67 {8 * static_cast<uint64_t>(i::GB), i::Heap::kMaxSemiSpaceSize}}; |
| 56 | 68 |
| 57 for (auto configuration : configurations) { | 69 for (auto configuration : configurations) { |
| 58 ASSERT_EQ(configuration[1], | 70 ASSERT_EQ(configuration[1], |
| 59 static_cast<uint64_t>( | 71 static_cast<uint64_t>( |
| 60 i::Heap::ComputeMaxSemiSpaceSize(configuration[0]))); | 72 i::Heap::ComputeMaxSemiSpaceSize(configuration[0]))); |
| 61 } | 73 } |
| 62 } | 74 } |
| 63 | 75 |
| 64 TEST(Heap, OldGenerationSize) { | 76 TEST(Heap, OldGenerationSize) { |
| 65 uint64_t configurations[][2] = { | 77 uint64_t configurations[][2] = { |
| 66 {0, i::Heap::kMinOldSpaceSize}, | 78 {0, i::Heap::kMinOldGenerationSize}, |
| 67 {512, i::Heap::kMinOldSpaceSize}, | 79 {512, i::Heap::kMinOldGenerationSize}, |
| 68 {1 * i::GB, 256 * i::Heap::kPointerMultiplier}, | 80 {1 * i::GB, 256 * i::Heap::kPointerMultiplier}, |
| 69 {2 * static_cast<uint64_t>(i::GB), 512 * i::Heap::kPointerMultiplier}, | 81 {2 * static_cast<uint64_t>(i::GB), 512 * i::Heap::kPointerMultiplier}, |
| 70 {4 * static_cast<uint64_t>(i::GB), i::Heap::kMaxOldSpaceSize}, | 82 {4 * static_cast<uint64_t>(i::GB), i::Heap::kMaxOldGenerationSize}, |
| 71 {8 * static_cast<uint64_t>(i::GB), i::Heap::kMaxOldSpaceSize}}; | 83 {8 * static_cast<uint64_t>(i::GB), i::Heap::kMaxOldGenerationSize}}; |
| 72 | 84 |
| 73 for (auto configuration : configurations) { | 85 for (auto configuration : configurations) { |
| 74 ASSERT_EQ(configuration[1], | 86 ASSERT_EQ(configuration[1], |
| 75 static_cast<uint64_t>( | 87 static_cast<uint64_t>( |
| 76 i::Heap::ComputeMaxOldGenerationSize(configuration[0]))); | 88 i::Heap::ComputeMaxOldGenerationSize(configuration[0]))); |
| 77 } | 89 } |
| 78 } | 90 } |
| 79 | 91 |
| 80 } // namespace internal | 92 } // namespace internal |
| 81 } // namespace v8 | 93 } // namespace v8 |
| OLD | NEW |