Home | History | Annotate | Download | only in base

Lines Matching full:arena

26   size_t NumberOfArenas(ArenaAllocator* arena) {
28 for (Arena* a = arena->arena_head_; a != nullptr; a = a->next_) {
37 ArenaAllocator arena(&pool);
38 ArenaBitVector bv(&arena, 10, true);
52 // Allocate a small array from an arena and release it.
53 ArenaAllocator arena(&pool);
54 small_array = arena.AllocArray<uint32_t>(kSmallArraySize);
58 // Reuse the previous arena and allocate more than previous allocation including red zone.
59 ArenaAllocator arena(&pool);
60 uint32_t* large_array = arena.AllocArray<uint32_t>(kLargeArraySize);
62 // Verify that the allocation was made on the same arena.
70 ArenaAllocator arena(&pool);
72 void* alloc1 = arena.Alloc(Arena::kDefaultSize * 5 / 8);
73 void* alloc2 = arena.Alloc(Arena::kDefaultSize * 2 / 8);
75 ASSERT_EQ(1u, NumberOfArenas(&arena));
79 ArenaAllocator arena(&pool);
80 void* alloc1 = arena.Alloc(Arena::kDefaultSize * 13 / 16);
81 void* alloc2 = arena.Alloc(Arena::kDefaultSize * 11 / 16);
83 ASSERT_EQ(2u, NumberOfArenas(&arena));
84 void* alloc3 = arena.Alloc(Arena::kDefaultSize * 7 / 16);
87 ASSERT_EQ(3u, NumberOfArenas(&arena));
91 ArenaAllocator arena(&pool);
92 void* alloc1 = arena.Alloc(Arena::kDefaultSize * 13 / 16);
93 void* alloc2 = arena.Alloc(Arena::kDefaultSize * 9 / 16);
95 ASSERT_EQ(2u, NumberOfArenas(&arena));
97 void* alloc3 = arena.Alloc(Arena::kDefaultSize * 5 / 16);
100 ASSERT_EQ(2u, NumberOfArenas(&arena));
104 ArenaAllocator arena(&pool);
105 void* alloc1 = arena.Alloc(Arena::kDefaultSize * 9 / 16);
106 void* alloc2 = arena.Alloc(Arena::kDefaultSize * 13 / 16);
108 ASSERT_EQ(2u, NumberOfArenas(&arena));
110 void* alloc3 = arena.Alloc(Arena::kDefaultSize * 5 / 16);
113 ASSERT_EQ(2u, NumberOfArenas(&arena));
117 ArenaAllocator arena(&pool);
120 arena.Alloc(Arena::kDefaultSize * 1 / 16); // Allocate 15 times from the same arena.
121 ASSERT_EQ(i + 1u, NumberOfArenas(&arena));
122 arena.Alloc(Arena::kDefaultSize * 17 / 16); // Allocate a separate arena.
123 ASSERT_EQ(i + 2u, NumberOfArenas(&arena));
130 ArenaAllocator arena(&pool);
133 void* allocation = arena.Alloc(size);
148 // Case 1: small aligned allocation, aligned extend inside arena.
150 ArenaAllocator arena(&pool);
153 void* original_allocation = arena.Alloc(original_size);
156 void* realloc_allocation = arena.Realloc(original_allocation, original_size, new_size);
161 // Case 2: small aligned allocation, non-aligned extend inside arena.
163 ArenaAllocator arena(&pool);
166 void* original_allocation = arena.Alloc(original_size);
169 void* realloc_allocation = arena.Realloc(original_allocation, original_size, new_size);
174 // Case 3: small non-aligned allocation, aligned extend inside arena.
176 ArenaAllocator arena(&pool);
179 void* original_allocation = arena.Alloc(original_size);
182 void* realloc_allocation = arena.Realloc(original_allocation, original_size, new_size);
187 // Case 4: small non-aligned allocation, aligned non-extend inside arena.
189 ArenaAllocator arena(&pool);
192 void* original_allocation = arena.Alloc(original_size);
195 void* realloc_allocation = arena.Realloc(original_allocation, original_size, new_size);
199 // The next part is brittle, as the default size for an arena is variable, and we don't know about
203 // Case 5: large allocation, aligned extend into next arena.
205 ArenaAllocator arena(&pool);
207 const size_t original_size = Arena::kDefaultSize - ArenaAllocator::kAlignment * 5;
208 void* original_allocation = arena.Alloc(original_size);
210 const size_t new_size = Arena::kDefaultSize + ArenaAllocator::kAlignment * 2;
211 void* realloc_allocation = arena.Realloc(original_allocation, original_size, new_size);
216 // Case 6: large allocation, non-aligned extend into next arena.
218 ArenaAllocator arena(&pool);
220 const size_t original_size = Arena::kDefaultSize -
223 void* original_allocation = arena.Alloc(original_size);
225 const size_t new_size = Arena::kDefaultSize +
228 void* realloc_allocation = arena.Realloc(original_allocation, original_size, new_size);
235 // Case 1: small aligned allocation, aligned extend inside arena.
237 ArenaAllocator arena(&pool);
240 void* original_allocation = arena.Alloc(original_size);
244 void* realloc_allocation = arena.Realloc(original_allocation, original_size, new_size);
247 void* after_alloc = arena.Alloc(1);
252 // Case 2: small aligned allocation, non-aligned extend inside arena.
254 ArenaAllocator arena(&pool);
257 void* original_allocation = arena.Alloc(original_size);
261 void* realloc_allocation = arena.Realloc(original_allocation, original_size, new_size);
264 void* after_alloc = arena.Alloc(1);
269 // Case 3: small non-aligned allocation, aligned extend inside arena.
271 ArenaAllocator arena(&pool);
274 void* original_allocation = arena.Alloc(original_size);
278 void* realloc_allocation = arena.Realloc(original_allocation, original_size, new_size);
281 void* after_alloc = arena.Alloc(1);
286 // Case 4: small non-aligned allocation, aligned non-extend inside arena.
288 ArenaAllocator arena(&pool);
291 void* original_allocation = arena.Alloc(original_size);
295 void* realloc_allocation = arena.Realloc(original_allocation, original_size, new_size);
298 void* after_alloc = arena.Alloc(1);
302 // The next part is brittle, as the default size for an arena is variable, and we don't know about
306 // Case 5: large allocation, aligned extend into next arena.
308 ArenaAllocator arena(&pool);
310 const size_t original_size = Arena::kDefaultSize - ArenaAllocator::kAlignment * 5;
311 void* original_allocation = arena.Alloc(original_size);
314 const size_t new_size = Arena::kDefaultSize + ArenaAllocator::kAlignment * 2;
315 void* realloc_allocation = arena.Realloc(original_allocation, original_size, new_size);
318 void* after_alloc = arena.Alloc(1);
323 // Case 6: large allocation, non-aligned extend into next arena.
325 ArenaAllocator arena(&pool);
327 const size_t original_size = Arena::kDefaultSize -
330 void* original_allocation = arena.Alloc(original_size);
333 const size_t new_size = Arena::kDefaultSize +
336 void* realloc_allocation = arena.Realloc(original_allocation, original_size, new_size);
339 void* after_alloc = arena.Alloc(1);