Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(530)

Unified Diff: test/unittests/zone/segmentpool-unittest.cc

Issue 2424393002: Constrain the zone segment pool size (Closed)
Patch Set: Reaction to comments Created 4 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « test/unittests/unittests.gyp ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: test/unittests/zone/segmentpool-unittest.cc
diff --git a/test/unittests/zone/segmentpool-unittest.cc b/test/unittests/zone/segmentpool-unittest.cc
new file mode 100644
index 0000000000000000000000000000000000000000..dd2c94f729a375965cb2821369a2c52235a45c39
--- /dev/null
+++ b/test/unittests/zone/segmentpool-unittest.cc
@@ -0,0 +1,35 @@
+// Copyright 2016 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 "src/zone/accounting-allocator.h"
+#include "testing/gtest/include/gtest/gtest.h"
+
+namespace v8 {
+namespace internal {
+
+TEST(Zone, SegmentPoolConstraints) {
+ size_t sizes[]{
+ 0, // Corner case
+ AccountingAllocator::kMaxPoolSizeLowMemoryDevice,
+ AccountingAllocator::kMaxPoolSizeMediumMemoryDevice,
+ AccountingAllocator::kMaxPoolSizeHighMemoryDevice,
+ AccountingAllocator::kMaxPoolSizeHugeMemoryDevice,
+ GB // Something really large
+ };
+
+ AccountingAllocator allocator;
+ for (size_t size : sizes) {
+ allocator.ConfigureSegmentPool(size);
+ size_t total_size = 0;
+ for (size_t power = 0; power < AccountingAllocator::kNumberBuckets;
+ ++power) {
+ total_size +=
+ allocator.unused_segments_max_sizes_[power] * (size_t(1) << power);
+ }
+ EXPECT_LE(total_size, size);
+ }
+}
+
+} // namespace internal
+} // namespace v8
« no previous file with comments | « test/unittests/unittests.gyp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698