blob: b84e29f7cee30f9ef06c09a8e04220c9f079e133 [file] [log] [blame]
buzbee862a7602013-04-05 10:58:54 -07001/*
2 * Copyright (C) 2013 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
Vladimir Marko83cc7ae2014-02-12 18:02:05 +000017#include <algorithm>
Ian Rogers6f3dbba2014-10-14 17:41:57 -070018#include <iomanip>
Vladimir Marko83cc7ae2014-02-12 18:02:05 +000019#include <numeric>
20
buzbee862a7602013-04-05 10:58:54 -070021#include "arena_allocator.h"
Mathieu Chartierb666f482015-02-18 14:33:14 -080022#include "logging.h"
Vladimir Marko3481ba22015-04-13 12:22:36 +010023#include "mem_map.h"
Mathieu Chartierb666f482015-02-18 14:33:14 -080024#include "mutex.h"
Ian Rogers02ed4c02013-09-06 13:10:04 -070025#include "thread-inl.h"
Mathieu Chartier32ce2ad2016-03-04 14:58:03 -080026#include "systrace.h"
buzbee862a7602013-04-05 10:58:54 -070027
28namespace art {
29
Evgenii Stepanov1e133742015-05-20 12:30:59 -070030static constexpr size_t kMemoryToolRedZoneBytes = 8;
Mark Mendell45c11652013-12-11 12:27:35 -080031constexpr size_t Arena::kDefaultSize;
Mathieu Chartierf6c4b3b2013-08-24 16:11:37 -070032
Vladimir Markobd9e9db2014-03-07 19:41:05 +000033template <bool kCount>
Vladimir Marko8dea81c2014-06-06 14:50:36 +010034const char* const ArenaAllocatorStatsImpl<kCount>::kAllocNames[] = {
Vladimir Markof9f64412015-09-02 14:05:49 +010035 "Misc ",
Vladimir Markof9f64412015-09-02 14:05:49 +010036 "SwitchTbl ",
Vladimir Markof9f64412015-09-02 14:05:49 +010037 "SlowPaths ",
Vladimir Markof9f64412015-09-02 14:05:49 +010038 "GrowBitMap ",
Vladimir Markof9f64412015-09-02 14:05:49 +010039 "STL ",
Vladimir Marko2aaa4b52015-09-17 17:03:26 +010040 "GraphBuilder ",
Vladimir Markof9f64412015-09-02 14:05:49 +010041 "Graph ",
42 "BasicBlock ",
Vladimir Markofa6b93c2015-09-15 10:15:55 +010043 "BlockList ",
44 "RevPostOrder ",
45 "LinearOrder ",
46 "ConstantsMap ",
Vladimir Marko60584552015-09-03 13:35:12 +000047 "Predecessors ",
48 "Successors ",
49 "Dominated ",
Vladimir Markof9f64412015-09-02 14:05:49 +010050 "Instruction ",
Vladimir Markofa6b93c2015-09-15 10:15:55 +010051 "InvokeInputs ",
52 "PhiInputs ",
Vladimir Markof9f64412015-09-02 14:05:49 +010053 "LoopInfo ",
Vladimir Markofa6b93c2015-09-15 10:15:55 +010054 "LIBackEdges ",
Vladimir Markof9f64412015-09-02 14:05:49 +010055 "TryCatchInf ",
56 "UseListNode ",
57 "Environment ",
Vladimir Markofa6b93c2015-09-15 10:15:55 +010058 "EnvVRegs ",
59 "EnvLocations ",
Vladimir Marko2aaa4b52015-09-17 17:03:26 +010060 "LocSummary ",
Vladimir Marko71bf8092015-09-15 15:33:14 +010061 "SsaBuilder ",
Vladimir Markof9f64412015-09-02 14:05:49 +010062 "MoveOperands ",
63 "CodeBuffer ",
64 "StackMaps ",
Vladimir Markof9f64412015-09-02 14:05:49 +010065 "Optimization ",
Vladimir Marko2aaa4b52015-09-17 17:03:26 +010066 "GVN ",
Vladimir Marko5233f932015-09-29 19:01:15 +010067 "InductionVar ",
68 "BCE ",
Vladimir Markof6a35de2016-03-21 12:01:50 +000069 "DCE ",
70 "LSE ",
71 "LICM ",
Vladimir Marko2aaa4b52015-09-17 17:03:26 +010072 "SsaLiveness ",
73 "SsaPhiElim ",
74 "RefTypeProp ",
Vladimir Marko2aaa4b52015-09-17 17:03:26 +010075 "SideEffects ",
76 "RegAllocator ",
Vladimir Markof6a35de2016-03-21 12:01:50 +000077 "RegAllocVldt ",
Vladimir Marko225b6462015-09-28 12:17:40 +010078 "StackMapStm ",
79 "CodeGen ",
Vladimir Marko93205e32016-04-13 11:59:46 +010080 "Assembler ",
Vladimir Marko225b6462015-09-28 12:17:40 +010081 "ParallelMove ",
Vladimir Marko655e5852015-10-12 10:38:28 +010082 "GraphChecker ",
Mathieu Chartierde40d472015-10-15 17:47:48 -070083 "Verifier ",
Vladimir Marko93205e32016-04-13 11:59:46 +010084 "CallingConv ",
buzbee862a7602013-04-05 10:58:54 -070085};
86
Vladimir Marko83cc7ae2014-02-12 18:02:05 +000087template <bool kCount>
88ArenaAllocatorStatsImpl<kCount>::ArenaAllocatorStatsImpl()
89 : num_allocations_(0u) {
90 std::fill_n(alloc_stats_, arraysize(alloc_stats_), 0u);
91}
92
93template <bool kCount>
94void ArenaAllocatorStatsImpl<kCount>::Copy(const ArenaAllocatorStatsImpl& other) {
95 num_allocations_ = other.num_allocations_;
96 std::copy(other.alloc_stats_, other.alloc_stats_ + arraysize(alloc_stats_), alloc_stats_);
97}
98
99template <bool kCount>
100void ArenaAllocatorStatsImpl<kCount>::RecordAlloc(size_t bytes, ArenaAllocKind kind) {
101 alloc_stats_[kind] += bytes;
102 ++num_allocations_;
103}
104
105template <bool kCount>
106size_t ArenaAllocatorStatsImpl<kCount>::NumAllocations() const {
107 return num_allocations_;
108}
109
110template <bool kCount>
111size_t ArenaAllocatorStatsImpl<kCount>::BytesAllocated() const {
112 const size_t init = 0u; // Initial value of the correct type.
113 return std::accumulate(alloc_stats_, alloc_stats_ + arraysize(alloc_stats_), init);
114}
115
116template <bool kCount>
117void ArenaAllocatorStatsImpl<kCount>::Dump(std::ostream& os, const Arena* first,
118 ssize_t lost_bytes_adjustment) const {
119 size_t malloc_bytes = 0u;
120 size_t lost_bytes = 0u;
121 size_t num_arenas = 0u;
122 for (const Arena* arena = first; arena != nullptr; arena = arena->next_) {
123 malloc_bytes += arena->Size();
124 lost_bytes += arena->RemainingSpace();
125 ++num_arenas;
126 }
127 // The lost_bytes_adjustment is used to make up for the fact that the current arena
128 // may not have the bytes_allocated_ updated correctly.
129 lost_bytes += lost_bytes_adjustment;
130 const size_t bytes_allocated = BytesAllocated();
131 os << " MEM: used: " << bytes_allocated << ", allocated: " << malloc_bytes
132 << ", lost: " << lost_bytes << "\n";
Vladimir Markobd9e9db2014-03-07 19:41:05 +0000133 size_t num_allocations = NumAllocations();
Vladimir Marko83cc7ae2014-02-12 18:02:05 +0000134 if (num_allocations != 0) {
135 os << "Number of arenas allocated: " << num_arenas << ", Number of allocations: "
136 << num_allocations << ", avg size: " << bytes_allocated / num_allocations << "\n";
137 }
138 os << "===== Allocation by kind\n";
Andreas Gampe785d2f22014-11-03 22:57:30 -0800139 static_assert(arraysize(kAllocNames) == kNumArenaAllocKinds, "arraysize of kAllocNames");
Vladimir Marko83cc7ae2014-02-12 18:02:05 +0000140 for (int i = 0; i < kNumArenaAllocKinds; i++) {
Vladimir Markobd9e9db2014-03-07 19:41:05 +0000141 os << kAllocNames[i] << std::setw(10) << alloc_stats_[i] << "\n";
Vladimir Marko83cc7ae2014-02-12 18:02:05 +0000142 }
143}
144
145// Explicitly instantiate the used implementation.
146template class ArenaAllocatorStatsImpl<kArenaAllocatorCountAllocations>;
147
Vladimir Marko7bda3b62015-10-07 12:44:31 +0000148void ArenaAllocatorMemoryTool::DoMakeDefined(void* ptr, size_t size) {
149 MEMORY_TOOL_MAKE_DEFINED(ptr, size);
150}
151
152void ArenaAllocatorMemoryTool::DoMakeUndefined(void* ptr, size_t size) {
153 MEMORY_TOOL_MAKE_UNDEFINED(ptr, size);
154}
155
156void ArenaAllocatorMemoryTool::DoMakeInaccessible(void* ptr, size_t size) {
157 MEMORY_TOOL_MAKE_NOACCESS(ptr, size);
158}
159
Mathieu Chartierc6201fa2015-03-12 10:06:33 -0700160Arena::Arena() : bytes_allocated_(0), next_(nullptr) {
Ian Rogerse7a5b7d2013-04-18 20:09:02 -0700161}
162
Mathieu Chartierc6201fa2015-03-12 10:06:33 -0700163MallocArena::MallocArena(size_t size) {
164 memory_ = reinterpret_cast<uint8_t*>(calloc(1, size));
Vladimir Marko3e0e7172016-04-22 18:07:13 +0100165 CHECK(memory_ != nullptr); // Abort on OOM.
Mathieu Chartierc6201fa2015-03-12 10:06:33 -0700166 size_ = size;
buzbee862a7602013-04-05 10:58:54 -0700167}
168
Mathieu Chartierc6201fa2015-03-12 10:06:33 -0700169MallocArena::~MallocArena() {
170 free(reinterpret_cast<void*>(memory_));
171}
172
Nicolas Geoffray25e04562016-03-01 13:17:58 +0000173MemMapArena::MemMapArena(size_t size, bool low_4gb, const char* name) {
Mathieu Chartierc6201fa2015-03-12 10:06:33 -0700174 std::string error_msg;
Mathieu Chartierc7853442015-03-27 14:35:38 -0700175 map_.reset(MemMap::MapAnonymous(
Nicolas Geoffray25e04562016-03-01 13:17:58 +0000176 name, nullptr, size, PROT_READ | PROT_WRITE, low_4gb, false, &error_msg));
Mathieu Chartierc6201fa2015-03-12 10:06:33 -0700177 CHECK(map_.get() != nullptr) << error_msg;
178 memory_ = map_->Begin();
179 size_ = map_->Size();
180}
181
Vladimir Marko3481ba22015-04-13 12:22:36 +0100182MemMapArena::~MemMapArena() {
183 // Destroys MemMap via std::unique_ptr<>.
184}
185
Mathieu Chartierc6201fa2015-03-12 10:06:33 -0700186void MemMapArena::Release() {
187 if (bytes_allocated_ > 0) {
Mathieu Chartier9b34b242015-03-09 11:30:17 -0700188 map_->MadviseDontNeedAndZero();
189 bytes_allocated_ = 0;
190 }
191}
192
Mathieu Chartierf6c4b3b2013-08-24 16:11:37 -0700193void Arena::Reset() {
Mathieu Chartier9b34b242015-03-09 11:30:17 -0700194 if (bytes_allocated_ > 0) {
Mathieu Chartierc6201fa2015-03-12 10:06:33 -0700195 memset(Begin(), 0, bytes_allocated_);
Mathieu Chartierf6c4b3b2013-08-24 16:11:37 -0700196 bytes_allocated_ = 0;
buzbee862a7602013-04-05 10:58:54 -0700197 }
buzbee862a7602013-04-05 10:58:54 -0700198}
199
Nicolas Geoffray25e04562016-03-01 13:17:58 +0000200ArenaPool::ArenaPool(bool use_malloc, bool low_4gb, const char* name)
201 : use_malloc_(use_malloc),
202 lock_("Arena pool lock", kArenaPoolLock),
203 free_arenas_(nullptr),
204 low_4gb_(low_4gb),
205 name_(name) {
Mathieu Chartierc7853442015-03-27 14:35:38 -0700206 if (low_4gb) {
207 CHECK(!use_malloc) << "low4gb must use map implementation";
208 }
Mathieu Chartierc6201fa2015-03-12 10:06:33 -0700209 if (!use_malloc) {
Mathieu Chartier9b34b242015-03-09 11:30:17 -0700210 MemMap::Init();
211 }
Mathieu Chartierf6c4b3b2013-08-24 16:11:37 -0700212}
213
214ArenaPool::~ArenaPool() {
Jean-Philippe Halimica76a1a2016-02-02 19:48:52 +0100215 ReclaimMemory();
216}
217
218void ArenaPool::ReclaimMemory() {
Mathieu Chartierf6c4b3b2013-08-24 16:11:37 -0700219 while (free_arenas_ != nullptr) {
220 auto* arena = free_arenas_;
221 free_arenas_ = free_arenas_->next_;
222 delete arena;
223 }
224}
225
Jean-Philippe Halimica76a1a2016-02-02 19:48:52 +0100226void ArenaPool::LockReclaimMemory() {
227 MutexLock lock(Thread::Current(), lock_);
228 ReclaimMemory();
229}
230
Mathieu Chartierf6c4b3b2013-08-24 16:11:37 -0700231Arena* ArenaPool::AllocArena(size_t size) {
232 Thread* self = Thread::Current();
233 Arena* ret = nullptr;
234 {
235 MutexLock lock(self, lock_);
236 if (free_arenas_ != nullptr && LIKELY(free_arenas_->Size() >= size)) {
237 ret = free_arenas_;
238 free_arenas_ = free_arenas_->next_;
239 }
240 }
241 if (ret == nullptr) {
Mathieu Chartierc7853442015-03-27 14:35:38 -0700242 ret = use_malloc_ ? static_cast<Arena*>(new MallocArena(size)) :
Nicolas Geoffray25e04562016-03-01 13:17:58 +0000243 new MemMapArena(size, low_4gb_, name_);
Mathieu Chartierf6c4b3b2013-08-24 16:11:37 -0700244 }
245 ret->Reset();
246 return ret;
247}
248
Mathieu Chartier9b34b242015-03-09 11:30:17 -0700249void ArenaPool::TrimMaps() {
Mathieu Chartierc6201fa2015-03-12 10:06:33 -0700250 if (!use_malloc_) {
Mathieu Chartier32ce2ad2016-03-04 14:58:03 -0800251 ScopedTrace trace(__PRETTY_FUNCTION__);
Mathieu Chartierc6201fa2015-03-12 10:06:33 -0700252 // Doesn't work for malloc.
253 MutexLock lock(Thread::Current(), lock_);
254 for (auto* arena = free_arenas_; arena != nullptr; arena = arena->next_) {
255 arena->Release();
256 }
Mathieu Chartier9b34b242015-03-09 11:30:17 -0700257 }
258}
259
Mathieu Chartier49285c52014-12-02 15:43:48 -0800260size_t ArenaPool::GetBytesAllocated() const {
261 size_t total = 0;
262 MutexLock lock(Thread::Current(), lock_);
263 for (Arena* arena = free_arenas_; arena != nullptr; arena = arena->next_) {
264 total += arena->GetBytesAllocated();
265 }
266 return total;
267}
268
Vladimir Marko83cc7ae2014-02-12 18:02:05 +0000269void ArenaPool::FreeArenaChain(Arena* first) {
Evgenii Stepanov1e133742015-05-20 12:30:59 -0700270 if (UNLIKELY(RUNNING_ON_MEMORY_TOOL > 0)) {
Vladimir Marko83cc7ae2014-02-12 18:02:05 +0000271 for (Arena* arena = first; arena != nullptr; arena = arena->next_) {
Evgenii Stepanov1e133742015-05-20 12:30:59 -0700272 MEMORY_TOOL_MAKE_UNDEFINED(arena->memory_, arena->bytes_allocated_);
Vladimir Marko83cc7ae2014-02-12 18:02:05 +0000273 }
Mathieu Chartier75165d02013-09-12 14:00:31 -0700274 }
Vladimir Marko83cc7ae2014-02-12 18:02:05 +0000275 if (first != nullptr) {
276 Arena* last = first;
277 while (last->next_ != nullptr) {
278 last = last->next_;
279 }
280 Thread* self = Thread::Current();
Mathieu Chartierf6c4b3b2013-08-24 16:11:37 -0700281 MutexLock lock(self, lock_);
Vladimir Marko83cc7ae2014-02-12 18:02:05 +0000282 last->next_ = free_arenas_;
283 free_arenas_ = first;
Mathieu Chartierf6c4b3b2013-08-24 16:11:37 -0700284 }
285}
286
287size_t ArenaAllocator::BytesAllocated() const {
Vladimir Marko83cc7ae2014-02-12 18:02:05 +0000288 return ArenaAllocatorStats::BytesAllocated();
Mathieu Chartierf6c4b3b2013-08-24 16:11:37 -0700289}
290
Mathieu Chartierc7853442015-03-27 14:35:38 -0700291size_t ArenaAllocator::BytesUsed() const {
292 size_t total = ptr_ - begin_;
293 if (arena_head_ != nullptr) {
294 for (Arena* cur_arena = arena_head_->next_; cur_arena != nullptr;
295 cur_arena = cur_arena->next_) {
296 total += cur_arena->GetBytesAllocated();
297 }
298 }
299 return total;
300}
301
Mathieu Chartierf6c4b3b2013-08-24 16:11:37 -0700302ArenaAllocator::ArenaAllocator(ArenaPool* pool)
303 : pool_(pool),
304 begin_(nullptr),
305 end_(nullptr),
306 ptr_(nullptr),
Vladimir Marko2a408a32015-09-18 14:11:00 +0100307 arena_head_(nullptr) {
Mathieu Chartierf6c4b3b2013-08-24 16:11:37 -0700308}
309
310void ArenaAllocator::UpdateBytesAllocated() {
311 if (arena_head_ != nullptr) {
312 // Update how many bytes we have allocated into the arena so that the arena pool knows how
313 // much memory to zero out.
314 arena_head_->bytes_allocated_ = ptr_ - begin_;
315 }
316}
317
Vladimir Marko2a408a32015-09-18 14:11:00 +0100318void* ArenaAllocator::AllocWithMemoryTool(size_t bytes, ArenaAllocKind kind) {
Vladimir Marko75001932015-11-10 20:54:22 +0000319 // We mark all memory for a newly retrieved arena as inaccessible and then
320 // mark only the actually allocated memory as defined. That leaves red zones
321 // and padding between allocations marked as inaccessible.
Evgenii Stepanov1e133742015-05-20 12:30:59 -0700322 size_t rounded_bytes = RoundUp(bytes + kMemoryToolRedZoneBytes, 8);
Vladimir Marko83cc7ae2014-02-12 18:02:05 +0000323 ArenaAllocatorStats::RecordAlloc(rounded_bytes, kind);
Vladimir Marko3f84f2c2016-04-25 19:40:34 +0100324 uint8_t* ret;
Vladimir Marko3e0e7172016-04-22 18:07:13 +0100325 if (UNLIKELY(rounded_bytes > static_cast<size_t>(end_ - ptr_))) {
Vladimir Marko3f84f2c2016-04-25 19:40:34 +0100326 ret = AllocFromNewArena(rounded_bytes);
327 uint8_t* noaccess_begin = ret + bytes;
328 uint8_t* noaccess_end;
Vladimir Marko3e0e7172016-04-22 18:07:13 +0100329 if (ret == arena_head_->Begin()) {
330 DCHECK(ptr_ - rounded_bytes == ret);
Vladimir Marko3f84f2c2016-04-25 19:40:34 +0100331 noaccess_end = end_;
Vladimir Marko3e0e7172016-04-22 18:07:13 +0100332 } else {
333 // We're still using the old arena but `ret` comes from a new one just after it.
334 DCHECK(arena_head_->next_ != nullptr);
335 DCHECK(ret == arena_head_->next_->Begin());
336 DCHECK_EQ(rounded_bytes, arena_head_->next_->GetBytesAllocated());
Vladimir Marko3f84f2c2016-04-25 19:40:34 +0100337 noaccess_end = arena_head_->next_->End();
Vladimir Marko3e0e7172016-04-22 18:07:13 +0100338 }
Vladimir Marko3f84f2c2016-04-25 19:40:34 +0100339 MEMORY_TOOL_MAKE_NOACCESS(noaccess_begin, noaccess_end - noaccess_begin);
340 } else {
341 ret = ptr_;
342 ptr_ += rounded_bytes;
Vladimir Marko3e0e7172016-04-22 18:07:13 +0100343 }
Vladimir Marko2a408a32015-09-18 14:11:00 +0100344 MEMORY_TOOL_MAKE_DEFINED(ret, bytes);
Vladimir Marko75001932015-11-10 20:54:22 +0000345 // Check that the memory is already zeroed out.
346 DCHECK(std::all_of(ret, ret + bytes, [](uint8_t val) { return val == 0u; }));
Mathieu Chartier75165d02013-09-12 14:00:31 -0700347 return ret;
348}
349
Mathieu Chartierf6c4b3b2013-08-24 16:11:37 -0700350ArenaAllocator::~ArenaAllocator() {
351 // Reclaim all the arenas by giving them back to the thread pool.
352 UpdateBytesAllocated();
Vladimir Marko83cc7ae2014-02-12 18:02:05 +0000353 pool_->FreeArenaChain(arena_head_);
Mathieu Chartierf6c4b3b2013-08-24 16:11:37 -0700354}
355
Vladimir Marko3f84f2c2016-04-25 19:40:34 +0100356uint8_t* ArenaAllocator::AllocFromNewArena(size_t bytes) {
Vladimir Marko3e0e7172016-04-22 18:07:13 +0100357 Arena* new_arena = pool_->AllocArena(std::max(Arena::kDefaultSize, bytes));
358 DCHECK(new_arena != nullptr);
359 DCHECK_LE(bytes, new_arena->Size());
360 if (static_cast<size_t>(end_ - ptr_) > new_arena->Size() - bytes) {
361 // The old arena has more space remaining than the new one, so keep using it.
362 // This can happen when the requested size is over half of the default size.
363 DCHECK(arena_head_ != nullptr);
364 new_arena->bytes_allocated_ = bytes; // UpdateBytesAllocated() on the new_arena.
365 new_arena->next_ = arena_head_->next_;
366 arena_head_->next_ = new_arena;
367 } else {
368 UpdateBytesAllocated();
369 new_arena->next_ = arena_head_;
370 arena_head_ = new_arena;
371 // Update our internal data structures.
372 begin_ = new_arena->Begin();
373 ptr_ = begin_ + bytes;
374 end_ = new_arena->End();
375 }
376 return new_arena->Begin();
Mathieu Chartierf6c4b3b2013-08-24 16:11:37 -0700377}
378
Mathieu Chartiere401d142015-04-22 13:56:20 -0700379bool ArenaAllocator::Contains(const void* ptr) const {
380 if (ptr >= begin_ && ptr < end_) {
381 return true;
382 }
383 for (const Arena* cur_arena = arena_head_; cur_arena != nullptr; cur_arena = cur_arena->next_) {
384 if (cur_arena->Contains(ptr)) {
385 return true;
386 }
387 }
388 return false;
389}
390
Vladimir Marko83cc7ae2014-02-12 18:02:05 +0000391MemStats::MemStats(const char* name, const ArenaAllocatorStats* stats, const Arena* first_arena,
392 ssize_t lost_bytes_adjustment)
393 : name_(name),
394 stats_(stats),
395 first_arena_(first_arena),
396 lost_bytes_adjustment_(lost_bytes_adjustment) {
397}
398
399void MemStats::Dump(std::ostream& os) const {
400 os << name_ << " stats:\n";
401 stats_->Dump(os, first_arena_, lost_bytes_adjustment_);
402}
403
Mathieu Chartierf6c4b3b2013-08-24 16:11:37 -0700404// Dump memory usage stats.
Vladimir Marko83cc7ae2014-02-12 18:02:05 +0000405MemStats ArenaAllocator::GetMemStats() const {
406 ssize_t lost_bytes_adjustment =
407 (arena_head_ == nullptr) ? 0 : (end_ - ptr_) - arena_head_->RemainingSpace();
408 return MemStats("ArenaAllocator", this, arena_head_, lost_bytes_adjustment);
buzbee862a7602013-04-05 10:58:54 -0700409}
410
411} // namespace art