bsalomon@google.com | 4da34e3 | 2012-06-19 15:40:27 +0000 | [diff] [blame] | 1 | /* |
| 2 | * Copyright 2011 Google Inc. |
| 3 | * |
| 4 | * Use of this source code is governed by a BSD-style license that can be |
| 5 | * found in the LICENSE file. |
| 6 | */ |
| 7 | |
Mike Klein | c0bd9f9 | 2019-04-23 12:05:21 -0500 | [diff] [blame] | 8 | #include "include/private/SkTArray.h" |
| 9 | #include "include/private/SkTDArray.h" |
| 10 | #include "include/private/SkTemplates.h" |
| 11 | #include "include/utils/SkRandom.h" |
| 12 | #include "src/gpu/GrMemoryPool.h" |
| 13 | #include "tests/Test.h" |
bsalomon@google.com | 4da34e3 | 2012-06-19 15:40:27 +0000 | [diff] [blame] | 14 | |
bsalomon@google.com | 4da34e3 | 2012-06-19 15:40:27 +0000 | [diff] [blame] | 15 | // A is the top of an inheritance tree of classes that overload op new and |
| 16 | // and delete to use a GrMemoryPool. The objects have values of different types |
| 17 | // that can be set and checked. |
| 18 | class A { |
| 19 | public: |
Mike Klein | fc6c37b | 2016-09-27 09:34:10 -0400 | [diff] [blame] | 20 | A() {} |
bsalomon@google.com | 4da34e3 | 2012-06-19 15:40:27 +0000 | [diff] [blame] | 21 | virtual void setValues(int v) { |
Brian Osman | 50ea3c0 | 2019-02-04 10:01:53 -0500 | [diff] [blame] | 22 | fChar = static_cast<char>(v & 0xFF); |
bsalomon@google.com | 4da34e3 | 2012-06-19 15:40:27 +0000 | [diff] [blame] | 23 | } |
| 24 | virtual bool checkValues(int v) { |
Brian Osman | 50ea3c0 | 2019-02-04 10:01:53 -0500 | [diff] [blame] | 25 | return fChar == static_cast<char>(v & 0xFF); |
bsalomon@google.com | 4da34e3 | 2012-06-19 15:40:27 +0000 | [diff] [blame] | 26 | } |
Mike Klein | fc6c37b | 2016-09-27 09:34:10 -0400 | [diff] [blame] | 27 | virtual ~A() {} |
bsalomon@google.com | 4da34e3 | 2012-06-19 15:40:27 +0000 | [diff] [blame] | 28 | |
| 29 | void* operator new(size_t size) { |
Brian Salomon | 6986c65 | 2019-12-12 10:58:47 -0500 | [diff] [blame] | 30 | if (!gPool) { |
bsalomon@google.com | 4da34e3 | 2012-06-19 15:40:27 +0000 | [diff] [blame] | 31 | return ::operator new(size); |
| 32 | } else { |
| 33 | return gPool->allocate(size); |
| 34 | } |
| 35 | } |
| 36 | |
| 37 | void operator delete(void* p) { |
Brian Salomon | 6986c65 | 2019-12-12 10:58:47 -0500 | [diff] [blame] | 38 | if (!gPool) { |
bsalomon@google.com | 4da34e3 | 2012-06-19 15:40:27 +0000 | [diff] [blame] | 39 | ::operator delete(p); |
| 40 | } else { |
| 41 | return gPool->release(p); |
| 42 | } |
| 43 | } |
| 44 | |
commit-bot@chromium.org | e0e7cfe | 2013-09-09 20:09:12 +0000 | [diff] [blame] | 45 | static A* Create(SkRandom* r); |
bsalomon@google.com | 4da34e3 | 2012-06-19 15:40:27 +0000 | [diff] [blame] | 46 | |
| 47 | static void SetAllocator(size_t preallocSize, size_t minAllocSize) { |
Brian Salomon | 6986c65 | 2019-12-12 10:58:47 -0500 | [diff] [blame] | 48 | gPool = GrMemoryPool::Make(preallocSize, minAllocSize); |
bsalomon@google.com | 4da34e3 | 2012-06-19 15:40:27 +0000 | [diff] [blame] | 49 | } |
| 50 | |
Brian Salomon | 6986c65 | 2019-12-12 10:58:47 -0500 | [diff] [blame] | 51 | static void ResetAllocator() { gPool.reset(); } |
bsalomon@google.com | 4da34e3 | 2012-06-19 15:40:27 +0000 | [diff] [blame] | 52 | |
Michael Ludwig | cd01979 | 2020-03-17 10:14:48 -0400 | [diff] [blame] | 53 | static void ValidatePool() { |
| 54 | #ifdef SK_DEBUG |
| 55 | gPool->validate(); |
| 56 | #endif |
| 57 | } |
| 58 | |
bsalomon@google.com | 4da34e3 | 2012-06-19 15:40:27 +0000 | [diff] [blame] | 59 | private: |
Ben Wagner | 145dbcd | 2016-11-03 14:40:50 -0400 | [diff] [blame] | 60 | static std::unique_ptr<GrMemoryPool> gPool; |
bsalomon@google.com | 4da34e3 | 2012-06-19 15:40:27 +0000 | [diff] [blame] | 61 | char fChar; |
| 62 | }; |
commit-bot@chromium.org | ab1c138 | 2013-12-05 12:08:12 +0000 | [diff] [blame] | 63 | |
Ben Wagner | 145dbcd | 2016-11-03 14:40:50 -0400 | [diff] [blame] | 64 | std::unique_ptr<GrMemoryPool> A::gPool; |
bsalomon@google.com | 4da34e3 | 2012-06-19 15:40:27 +0000 | [diff] [blame] | 65 | |
| 66 | class B : public A { |
| 67 | public: |
Mike Klein | fc6c37b | 2016-09-27 09:34:10 -0400 | [diff] [blame] | 68 | B() {} |
Brian Salomon | d007281 | 2020-07-21 17:03:56 -0400 | [diff] [blame] | 69 | void setValues(int v) override { |
bsalomon@google.com | 4da34e3 | 2012-06-19 15:40:27 +0000 | [diff] [blame] | 70 | fDouble = static_cast<double>(v); |
| 71 | this->INHERITED::setValues(v); |
| 72 | } |
Brian Salomon | d007281 | 2020-07-21 17:03:56 -0400 | [diff] [blame] | 73 | bool checkValues(int v) override { |
bsalomon@google.com | 4da34e3 | 2012-06-19 15:40:27 +0000 | [diff] [blame] | 74 | return fDouble == static_cast<double>(v) && |
| 75 | this->INHERITED::checkValues(v); |
| 76 | } |
bsalomon@google.com | 4da34e3 | 2012-06-19 15:40:27 +0000 | [diff] [blame] | 77 | |
| 78 | private: |
| 79 | double fDouble; |
| 80 | |
John Stiles | 7571f9e | 2020-09-02 22:42:33 -0400 | [diff] [blame] | 81 | using INHERITED = A; |
bsalomon@google.com | 4da34e3 | 2012-06-19 15:40:27 +0000 | [diff] [blame] | 82 | }; |
| 83 | |
| 84 | class C : public A { |
| 85 | public: |
Mike Klein | fc6c37b | 2016-09-27 09:34:10 -0400 | [diff] [blame] | 86 | C() {} |
Brian Salomon | d007281 | 2020-07-21 17:03:56 -0400 | [diff] [blame] | 87 | void setValues(int v) override { |
bsalomon@google.com | 4da34e3 | 2012-06-19 15:40:27 +0000 | [diff] [blame] | 88 | fInt64 = static_cast<int64_t>(v); |
| 89 | this->INHERITED::setValues(v); |
| 90 | } |
Brian Salomon | d007281 | 2020-07-21 17:03:56 -0400 | [diff] [blame] | 91 | bool checkValues(int v) override { |
bsalomon@google.com | 4da34e3 | 2012-06-19 15:40:27 +0000 | [diff] [blame] | 92 | return fInt64 == static_cast<int64_t>(v) && |
| 93 | this->INHERITED::checkValues(v); |
| 94 | } |
bsalomon@google.com | 4da34e3 | 2012-06-19 15:40:27 +0000 | [diff] [blame] | 95 | |
| 96 | private: |
| 97 | int64_t fInt64; |
| 98 | |
John Stiles | 7571f9e | 2020-09-02 22:42:33 -0400 | [diff] [blame] | 99 | using INHERITED = A; |
bsalomon@google.com | 4da34e3 | 2012-06-19 15:40:27 +0000 | [diff] [blame] | 100 | }; |
| 101 | |
| 102 | // D derives from C and owns a dynamically created B |
| 103 | class D : public C { |
| 104 | public: |
| 105 | D() { |
| 106 | fB = new B(); |
| 107 | } |
Brian Salomon | d007281 | 2020-07-21 17:03:56 -0400 | [diff] [blame] | 108 | void setValues(int v) override { |
bsalomon | ebc1c10 | 2015-08-06 17:33:16 -0700 | [diff] [blame] | 109 | fVoidStar = reinterpret_cast<void*>(static_cast<intptr_t>(v)); |
bsalomon@google.com | 4da34e3 | 2012-06-19 15:40:27 +0000 | [diff] [blame] | 110 | this->INHERITED::setValues(v); |
| 111 | fB->setValues(v); |
| 112 | } |
Brian Salomon | d007281 | 2020-07-21 17:03:56 -0400 | [diff] [blame] | 113 | bool checkValues(int v) override { |
bsalomon | ebc1c10 | 2015-08-06 17:33:16 -0700 | [diff] [blame] | 114 | return fVoidStar == reinterpret_cast<void*>(static_cast<intptr_t>(v)) && |
bsalomon@google.com | 4da34e3 | 2012-06-19 15:40:27 +0000 | [diff] [blame] | 115 | fB->checkValues(v) && |
| 116 | this->INHERITED::checkValues(v); |
| 117 | } |
Brian Salomon | d007281 | 2020-07-21 17:03:56 -0400 | [diff] [blame] | 118 | ~D() override { |
bsalomon@google.com | 4da34e3 | 2012-06-19 15:40:27 +0000 | [diff] [blame] | 119 | delete fB; |
| 120 | } |
| 121 | private: |
| 122 | void* fVoidStar; |
| 123 | B* fB; |
| 124 | |
John Stiles | 7571f9e | 2020-09-02 22:42:33 -0400 | [diff] [blame] | 125 | using INHERITED = C; |
bsalomon@google.com | 4da34e3 | 2012-06-19 15:40:27 +0000 | [diff] [blame] | 126 | }; |
| 127 | |
| 128 | class E : public A { |
| 129 | public: |
| 130 | E() {} |
Brian Salomon | d007281 | 2020-07-21 17:03:56 -0400 | [diff] [blame] | 131 | void setValues(int v) override { |
bsalomon@google.com | 4da34e3 | 2012-06-19 15:40:27 +0000 | [diff] [blame] | 132 | for (size_t i = 0; i < SK_ARRAY_COUNT(fIntArray); ++i) { |
| 133 | fIntArray[i] = v; |
| 134 | } |
| 135 | this->INHERITED::setValues(v); |
| 136 | } |
Brian Salomon | d007281 | 2020-07-21 17:03:56 -0400 | [diff] [blame] | 137 | bool checkValues(int v) override { |
bsalomon@google.com | 4da34e3 | 2012-06-19 15:40:27 +0000 | [diff] [blame] | 138 | bool ok = true; |
| 139 | for (size_t i = 0; ok && i < SK_ARRAY_COUNT(fIntArray); ++i) { |
| 140 | if (fIntArray[i] != v) { |
| 141 | ok = false; |
| 142 | } |
| 143 | } |
| 144 | return ok && this->INHERITED::checkValues(v); |
| 145 | } |
bsalomon@google.com | 4da34e3 | 2012-06-19 15:40:27 +0000 | [diff] [blame] | 146 | private: |
| 147 | int fIntArray[20]; |
| 148 | |
John Stiles | 7571f9e | 2020-09-02 22:42:33 -0400 | [diff] [blame] | 149 | using INHERITED = A; |
bsalomon@google.com | 4da34e3 | 2012-06-19 15:40:27 +0000 | [diff] [blame] | 150 | }; |
| 151 | |
commit-bot@chromium.org | e0e7cfe | 2013-09-09 20:09:12 +0000 | [diff] [blame] | 152 | A* A::Create(SkRandom* r) { |
bsalomon@google.com | 4da34e3 | 2012-06-19 15:40:27 +0000 | [diff] [blame] | 153 | switch (r->nextRangeU(0, 4)) { |
| 154 | case 0: |
| 155 | return new A; |
| 156 | case 1: |
| 157 | return new B; |
| 158 | case 2: |
| 159 | return new C; |
| 160 | case 3: |
| 161 | return new D; |
| 162 | case 4: |
| 163 | return new E; |
| 164 | default: |
| 165 | // suppress warning |
halcanary | 96fcdcc | 2015-08-27 07:41:13 -0700 | [diff] [blame] | 166 | return nullptr; |
bsalomon@google.com | 4da34e3 | 2012-06-19 15:40:27 +0000 | [diff] [blame] | 167 | } |
| 168 | } |
commit-bot@chromium.org | ddf94cf | 2013-10-12 17:25:17 +0000 | [diff] [blame] | 169 | |
bsalomon@google.com | 4da34e3 | 2012-06-19 15:40:27 +0000 | [diff] [blame] | 170 | struct Rec { |
| 171 | A* fInstance; |
| 172 | int fValue; |
| 173 | }; |
| 174 | |
tfarina@chromium.org | e4fafb1 | 2013-12-12 21:11:12 +0000 | [diff] [blame] | 175 | DEF_TEST(GrMemoryPool, reporter) { |
bsalomon@google.com | 4da34e3 | 2012-06-19 15:40:27 +0000 | [diff] [blame] | 176 | // prealloc and min alloc sizes for the pool |
| 177 | static const size_t gSizes[][2] = { |
| 178 | {0, 0}, |
| 179 | {10 * sizeof(A), 20 * sizeof(A)}, |
| 180 | {100 * sizeof(A), 100 * sizeof(A)}, |
| 181 | {500 * sizeof(A), 500 * sizeof(A)}, |
| 182 | {10000 * sizeof(A), 0}, |
| 183 | {1, 100 * sizeof(A)}, |
| 184 | }; |
Michael Ludwig | cd01979 | 2020-03-17 10:14:48 -0400 | [diff] [blame] | 185 | |
bsalomon@google.com | 4da34e3 | 2012-06-19 15:40:27 +0000 | [diff] [blame] | 186 | // different percentages of creation vs deletion |
| 187 | static const float gCreateFraction[] = {1.f, .95f, 0.75f, .5f}; |
| 188 | // number of create/destroys per test |
| 189 | static const int kNumIters = 20000; |
| 190 | // check that all the values stored in A objects are correct after this |
| 191 | // number of iterations |
| 192 | static const int kCheckPeriod = 500; |
| 193 | |
commit-bot@chromium.org | e0e7cfe | 2013-09-09 20:09:12 +0000 | [diff] [blame] | 194 | SkRandom r; |
bsalomon@google.com | 4da34e3 | 2012-06-19 15:40:27 +0000 | [diff] [blame] | 195 | for (size_t s = 0; s < SK_ARRAY_COUNT(gSizes); ++s) { |
| 196 | A::SetAllocator(gSizes[s][0], gSizes[s][1]); |
Michael Ludwig | cd01979 | 2020-03-17 10:14:48 -0400 | [diff] [blame] | 197 | A::ValidatePool(); |
bsalomon@google.com | 4da34e3 | 2012-06-19 15:40:27 +0000 | [diff] [blame] | 198 | for (size_t c = 0; c < SK_ARRAY_COUNT(gCreateFraction); ++c) { |
| 199 | SkTDArray<Rec> instanceRecs; |
| 200 | for (int i = 0; i < kNumIters; ++i) { |
| 201 | float createOrDestroy = r.nextUScalar1(); |
| 202 | if (createOrDestroy < gCreateFraction[c] || |
| 203 | 0 == instanceRecs.count()) { |
| 204 | Rec* rec = instanceRecs.append(); |
| 205 | rec->fInstance = A::Create(&r); |
| 206 | rec->fValue = static_cast<int>(r.nextU()); |
| 207 | rec->fInstance->setValues(rec->fValue); |
| 208 | } else { |
| 209 | int d = r.nextRangeU(0, instanceRecs.count() - 1); |
| 210 | Rec& rec = instanceRecs[d]; |
| 211 | REPORTER_ASSERT(reporter, rec.fInstance->checkValues(rec.fValue)); |
| 212 | delete rec.fInstance; |
| 213 | instanceRecs.removeShuffle(d); |
| 214 | } |
| 215 | if (0 == i % kCheckPeriod) { |
Michael Ludwig | cd01979 | 2020-03-17 10:14:48 -0400 | [diff] [blame] | 216 | A::ValidatePool(); |
John Stiles | 9765973 | 2021-08-12 10:48:09 -0400 | [diff] [blame] | 217 | for (Rec& rec : instanceRecs) { |
bsalomon@google.com | 4da34e3 | 2012-06-19 15:40:27 +0000 | [diff] [blame] | 218 | REPORTER_ASSERT(reporter, rec.fInstance->checkValues(rec.fValue)); |
| 219 | } |
| 220 | } |
| 221 | } |
John Stiles | 9765973 | 2021-08-12 10:48:09 -0400 | [diff] [blame] | 222 | for (Rec& rec : instanceRecs) { |
bsalomon@google.com | 4da34e3 | 2012-06-19 15:40:27 +0000 | [diff] [blame] | 223 | REPORTER_ASSERT(reporter, rec.fInstance->checkValues(rec.fValue)); |
| 224 | delete rec.fInstance; |
| 225 | } |
bsalomon@google.com | 4da34e3 | 2012-06-19 15:40:27 +0000 | [diff] [blame] | 226 | } |
| 227 | } |
| 228 | } |
| 229 | |
dskiba | e4cd006 | 2016-11-29 06:50:35 -0800 | [diff] [blame] | 230 | // GrMemoryPool requires that it's empty at the point of destruction. This helps |
| 231 | // achieving that by releasing all added memory in the destructor. |
| 232 | class AutoPoolReleaser { |
| 233 | public: |
| 234 | AutoPoolReleaser(GrMemoryPool& pool): fPool(pool) { |
| 235 | } |
| 236 | ~AutoPoolReleaser() { |
| 237 | for (void* ptr: fAllocated) { |
| 238 | fPool.release(ptr); |
| 239 | } |
| 240 | } |
| 241 | void add(void* ptr) { |
| 242 | fAllocated.push_back(ptr); |
| 243 | } |
| 244 | private: |
| 245 | GrMemoryPool& fPool; |
| 246 | SkTArray<void*> fAllocated; |
| 247 | }; |
| 248 | |
| 249 | DEF_TEST(GrMemoryPoolAPI, reporter) { |
Brian Salomon | 6986c65 | 2019-12-12 10:58:47 -0500 | [diff] [blame] | 250 | constexpr size_t kSmallestMinAllocSize = GrMemoryPool::kMinAllocationSize; |
dskiba | e4cd006 | 2016-11-29 06:50:35 -0800 | [diff] [blame] | 251 | |
Brian Salomon | 6986c65 | 2019-12-12 10:58:47 -0500 | [diff] [blame] | 252 | // Allocates memory until pool adds a new block (pool->size() changes). |
dskiba | e4cd006 | 2016-11-29 06:50:35 -0800 | [diff] [blame] | 253 | auto allocateMemory = [](GrMemoryPool& pool, AutoPoolReleaser& r) { |
| 254 | size_t origPoolSize = pool.size(); |
| 255 | while (pool.size() == origPoolSize) { |
| 256 | r.add(pool.allocate(31)); |
| 257 | } |
| 258 | }; |
| 259 | |
Brian Salomon | 6986c65 | 2019-12-12 10:58:47 -0500 | [diff] [blame] | 260 | // Effective prealloc space capacity is >= kMinAllocationSize. |
dskiba | e4cd006 | 2016-11-29 06:50:35 -0800 | [diff] [blame] | 261 | { |
Brian Salomon | 6986c65 | 2019-12-12 10:58:47 -0500 | [diff] [blame] | 262 | auto pool = GrMemoryPool::Make(0, 0); |
| 263 | REPORTER_ASSERT(reporter, pool->preallocSize() == kSmallestMinAllocSize); |
dskiba | e4cd006 | 2016-11-29 06:50:35 -0800 | [diff] [blame] | 264 | } |
| 265 | |
Brian Salomon | 6986c65 | 2019-12-12 10:58:47 -0500 | [diff] [blame] | 266 | // Effective block size capacity >= kMinAllocationSize. |
dskiba | e4cd006 | 2016-11-29 06:50:35 -0800 | [diff] [blame] | 267 | { |
Brian Salomon | 6986c65 | 2019-12-12 10:58:47 -0500 | [diff] [blame] | 268 | auto pool = GrMemoryPool::Make(kSmallestMinAllocSize, kSmallestMinAllocSize / 2); |
| 269 | AutoPoolReleaser r(*pool); |
dskiba | e4cd006 | 2016-11-29 06:50:35 -0800 | [diff] [blame] | 270 | |
Brian Salomon | 6986c65 | 2019-12-12 10:58:47 -0500 | [diff] [blame] | 271 | allocateMemory(*pool, r); |
| 272 | REPORTER_ASSERT(reporter, pool->size() == kSmallestMinAllocSize); |
dskiba | e4cd006 | 2016-11-29 06:50:35 -0800 | [diff] [blame] | 273 | } |
| 274 | |
| 275 | // Pool allocates exactly preallocSize on creation. |
| 276 | { |
| 277 | constexpr size_t kPreallocSize = kSmallestMinAllocSize * 5; |
Brian Salomon | 6986c65 | 2019-12-12 10:58:47 -0500 | [diff] [blame] | 278 | auto pool = GrMemoryPool::Make(kPreallocSize, 0); |
| 279 | REPORTER_ASSERT(reporter, pool->preallocSize() == kPreallocSize); |
dskiba | e4cd006 | 2016-11-29 06:50:35 -0800 | [diff] [blame] | 280 | } |
| 281 | |
| 282 | // Pool allocates exactly minAllocSize when it expands. |
| 283 | { |
| 284 | constexpr size_t kMinAllocSize = kSmallestMinAllocSize * 7; |
Brian Salomon | 6986c65 | 2019-12-12 10:58:47 -0500 | [diff] [blame] | 285 | auto pool = GrMemoryPool::Make(0, kMinAllocSize); |
| 286 | AutoPoolReleaser r(*pool); |
Michael Ludwig | cd01979 | 2020-03-17 10:14:48 -0400 | [diff] [blame] | 287 | REPORTER_ASSERT(reporter, pool->size() == 0); |
dskiba | e4cd006 | 2016-11-29 06:50:35 -0800 | [diff] [blame] | 288 | |
Brian Salomon | 6986c65 | 2019-12-12 10:58:47 -0500 | [diff] [blame] | 289 | allocateMemory(*pool, r); |
| 290 | REPORTER_ASSERT(reporter, pool->size() == kMinAllocSize); |
dskiba | e4cd006 | 2016-11-29 06:50:35 -0800 | [diff] [blame] | 291 | |
Brian Salomon | 6986c65 | 2019-12-12 10:58:47 -0500 | [diff] [blame] | 292 | allocateMemory(*pool, r); |
| 293 | REPORTER_ASSERT(reporter, pool->size() == 2 * kMinAllocSize); |
dskiba | e4cd006 | 2016-11-29 06:50:35 -0800 | [diff] [blame] | 294 | } |
| 295 | |
| 296 | // When asked to allocate amount > minAllocSize, pool allocates larger block |
| 297 | // to accommodate all internal structures. |
| 298 | { |
| 299 | constexpr size_t kMinAllocSize = kSmallestMinAllocSize * 2; |
Brian Salomon | 6986c65 | 2019-12-12 10:58:47 -0500 | [diff] [blame] | 300 | auto pool = GrMemoryPool::Make(kSmallestMinAllocSize, kMinAllocSize); |
| 301 | AutoPoolReleaser r(*pool); |
dskiba | e4cd006 | 2016-11-29 06:50:35 -0800 | [diff] [blame] | 302 | |
Brian Salomon | 6986c65 | 2019-12-12 10:58:47 -0500 | [diff] [blame] | 303 | REPORTER_ASSERT(reporter, pool->size() == 0); |
dskiba | e4cd006 | 2016-11-29 06:50:35 -0800 | [diff] [blame] | 304 | |
| 305 | constexpr size_t hugeSize = 10 * kMinAllocSize; |
Brian Salomon | 6986c65 | 2019-12-12 10:58:47 -0500 | [diff] [blame] | 306 | r.add(pool->allocate(hugeSize)); |
| 307 | REPORTER_ASSERT(reporter, pool->size() > hugeSize); |
dskiba | e4cd006 | 2016-11-29 06:50:35 -0800 | [diff] [blame] | 308 | |
| 309 | // Block size allocated to accommodate huge request doesn't include any extra |
| 310 | // space, so next allocation request allocates a new block. |
Brian Salomon | 6986c65 | 2019-12-12 10:58:47 -0500 | [diff] [blame] | 311 | size_t hugeBlockSize = pool->size(); |
| 312 | r.add(pool->allocate(0)); |
| 313 | REPORTER_ASSERT(reporter, pool->size() == hugeBlockSize + kMinAllocSize); |
dskiba | e4cd006 | 2016-11-29 06:50:35 -0800 | [diff] [blame] | 314 | } |
| 315 | } |