OLD | NEW |
1 // Copyright 2016 the V8 project authors. All rights reserved. | 1 // Copyright 2016 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 "src/zone/accounting-allocator.h" | 5 #include "src/zone/accounting-allocator.h" |
6 #include "testing/gtest/include/gtest/gtest.h" | 6 #include "testing/gtest/include/gtest/gtest.h" |
7 | 7 |
8 namespace v8 { | 8 namespace v8 { |
9 namespace internal { | 9 namespace internal { |
10 | 10 |
11 TEST(Zone, SegmentPoolConstraints) { | 11 TEST(Zone, SegmentPoolConstraints) { |
12 size_t sizes[]{ | 12 size_t sizes[]{ |
13 0, // Corner case | 13 0, // Corner case |
14 AccountingAllocator::kMaxPoolSizeLowMemoryDevice, | 14 AccountingAllocator::kMaxPoolSize, |
15 AccountingAllocator::kMaxPoolSizeMediumMemoryDevice, | |
16 AccountingAllocator::kMaxPoolSizeHighMemoryDevice, | |
17 AccountingAllocator::kMaxPoolSizeHugeMemoryDevice, | |
18 GB // Something really large | 15 GB // Something really large |
19 }; | 16 }; |
20 | 17 |
21 AccountingAllocator allocator; | 18 AccountingAllocator allocator; |
22 for (size_t size : sizes) { | 19 for (size_t size : sizes) { |
23 allocator.ConfigureSegmentPool(size); | 20 allocator.ConfigureSegmentPool(size); |
24 size_t total_size = 0; | 21 size_t total_size = 0; |
25 for (size_t power = 0; power < AccountingAllocator::kNumberBuckets; | 22 for (size_t power = 0; power < AccountingAllocator::kNumberBuckets; |
26 ++power) { | 23 ++power) { |
27 total_size += | 24 total_size += |
28 allocator.unused_segments_max_sizes_[power] * (size_t(1) << power); | 25 allocator.unused_segments_max_sizes_[power] * (size_t(1) << power); |
29 } | 26 } |
30 EXPECT_LE(total_size, size); | 27 EXPECT_LE(total_size, size); |
31 } | 28 } |
32 } | 29 } |
33 | 30 |
34 } // namespace internal | 31 } // namespace internal |
35 } // namespace v8 | 32 } // namespace v8 |
OLD | NEW |