blob: 6c1a8984cdeead0f64877d16bafe9bcff21220ca [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
Mathieu Chartierb666f482015-02-18 14:33:14 -080017#ifndef ART_RUNTIME_BASE_ARENA_ALLOCATOR_H_
18#define ART_RUNTIME_BASE_ARENA_ALLOCATOR_H_
buzbee862a7602013-04-05 10:58:54 -070019
20#include <stdint.h>
21#include <stddef.h>
Mathieu Chartierf6c4b3b2013-08-24 16:11:37 -070022
Vladimir Marko80afd022015-05-19 18:08:00 +010023#include "base/bit_utils.h"
Vladimir Marko2a408a32015-09-18 14:11:00 +010024#include "base/memory_tool.h"
Mathieu Chartierb666f482015-02-18 14:33:14 -080025#include "debug_stack.h"
26#include "macros.h"
Mathieu Chartierb666f482015-02-18 14:33:14 -080027#include "mutex.h"
buzbee862a7602013-04-05 10:58:54 -070028
29namespace art {
30
Mathieu Chartierf6c4b3b2013-08-24 16:11:37 -070031class Arena;
32class ArenaPool;
33class ArenaAllocator;
Vladimir Marko83cc7ae2014-02-12 18:02:05 +000034class ArenaStack;
35class ScopedArenaAllocator;
Vladimir Marko3481ba22015-04-13 12:22:36 +010036class MemMap;
Vladimir Marko83cc7ae2014-02-12 18:02:05 +000037class MemStats;
38
Vladimir Marko8081d2b2014-07-31 15:33:43 +010039template <typename T>
40class ArenaAllocatorAdapter;
41
Vladimir Marko83cc7ae2014-02-12 18:02:05 +000042static constexpr bool kArenaAllocatorCountAllocations = false;
43
44// Type of allocation for memory tuning.
45enum ArenaAllocKind {
46 kArenaAllocMisc,
Vladimir Markoe39c54e2014-09-22 14:50:02 +010047 kArenaAllocSwitchTable,
Vladimir Markoe39c54e2014-09-22 14:50:02 +010048 kArenaAllocSlowPaths,
Vladimir Marko83cc7ae2014-02-12 18:02:05 +000049 kArenaAllocGrowableBitMap,
Vladimir Marko83cc7ae2014-02-12 18:02:05 +000050 kArenaAllocSTL,
Vladimir Marko2aaa4b52015-09-17 17:03:26 +010051 kArenaAllocGraphBuilder,
Vladimir Markof9f64412015-09-02 14:05:49 +010052 kArenaAllocGraph,
53 kArenaAllocBasicBlock,
Vladimir Markofa6b93c2015-09-15 10:15:55 +010054 kArenaAllocBlockList,
55 kArenaAllocReversePostOrder,
56 kArenaAllocLinearOrder,
57 kArenaAllocConstantsMap,
Vladimir Marko60584552015-09-03 13:35:12 +000058 kArenaAllocPredecessors,
59 kArenaAllocSuccessors,
60 kArenaAllocDominated,
Vladimir Markof9f64412015-09-02 14:05:49 +010061 kArenaAllocInstruction,
Vladimir Markofa6b93c2015-09-15 10:15:55 +010062 kArenaAllocInvokeInputs,
63 kArenaAllocPhiInputs,
Vladimir Markof9f64412015-09-02 14:05:49 +010064 kArenaAllocLoopInfo,
Vladimir Markofa6b93c2015-09-15 10:15:55 +010065 kArenaAllocLoopInfoBackEdges,
Vladimir Markof9f64412015-09-02 14:05:49 +010066 kArenaAllocTryCatchInfo,
67 kArenaAllocUseListNode,
68 kArenaAllocEnvironment,
Vladimir Markofa6b93c2015-09-15 10:15:55 +010069 kArenaAllocEnvironmentVRegs,
70 kArenaAllocEnvironmentLocations,
Vladimir Marko2aaa4b52015-09-17 17:03:26 +010071 kArenaAllocLocationSummary,
Vladimir Marko71bf8092015-09-15 15:33:14 +010072 kArenaAllocSsaBuilder,
Vladimir Markof9f64412015-09-02 14:05:49 +010073 kArenaAllocMoveOperands,
74 kArenaAllocCodeBuffer,
75 kArenaAllocStackMaps,
Vladimir Markof9f64412015-09-02 14:05:49 +010076 kArenaAllocOptimization,
Vladimir Marko2aaa4b52015-09-17 17:03:26 +010077 kArenaAllocGvn,
Vladimir Marko5233f932015-09-29 19:01:15 +010078 kArenaAllocInductionVarAnalysis,
79 kArenaAllocBoundsCheckElimination,
Vladimir Markof6a35de2016-03-21 12:01:50 +000080 kArenaAllocDCE,
81 kArenaAllocLSE,
82 kArenaAllocLICM,
Vladimir Marko2aaa4b52015-09-17 17:03:26 +010083 kArenaAllocSsaLiveness,
84 kArenaAllocSsaPhiElimination,
85 kArenaAllocReferenceTypePropagation,
Vladimir Marko2aaa4b52015-09-17 17:03:26 +010086 kArenaAllocSideEffectsAnalysis,
87 kArenaAllocRegisterAllocator,
Vladimir Markof6a35de2016-03-21 12:01:50 +000088 kArenaAllocRegisterAllocatorValidate,
Vladimir Marko225b6462015-09-28 12:17:40 +010089 kArenaAllocStackMapStream,
90 kArenaAllocCodeGenerator,
Vladimir Marko93205e32016-04-13 11:59:46 +010091 kArenaAllocAssembler,
Vladimir Marko225b6462015-09-28 12:17:40 +010092 kArenaAllocParallelMoveResolver,
Vladimir Marko655e5852015-10-12 10:38:28 +010093 kArenaAllocGraphChecker,
Mathieu Chartierde40d472015-10-15 17:47:48 -070094 kArenaAllocVerifier,
Vladimir Marko93205e32016-04-13 11:59:46 +010095 kArenaAllocCallingConvention,
Vladimir Marko83cc7ae2014-02-12 18:02:05 +000096 kNumArenaAllocKinds
97};
98
99template <bool kCount>
100class ArenaAllocatorStatsImpl;
101
102template <>
103class ArenaAllocatorStatsImpl<false> {
104 public:
105 ArenaAllocatorStatsImpl() = default;
106 ArenaAllocatorStatsImpl(const ArenaAllocatorStatsImpl& other) = default;
107 ArenaAllocatorStatsImpl& operator = (const ArenaAllocatorStatsImpl& other) = delete;
108
Roland Levillain4b8f1ec2015-08-26 18:34:03 +0100109 void Copy(const ArenaAllocatorStatsImpl& other ATTRIBUTE_UNUSED) {}
110 void RecordAlloc(size_t bytes ATTRIBUTE_UNUSED, ArenaAllocKind kind ATTRIBUTE_UNUSED) {}
Vladimir Marko83cc7ae2014-02-12 18:02:05 +0000111 size_t NumAllocations() const { return 0u; }
112 size_t BytesAllocated() const { return 0u; }
Roland Levillain4b8f1ec2015-08-26 18:34:03 +0100113 void Dump(std::ostream& os ATTRIBUTE_UNUSED,
114 const Arena* first ATTRIBUTE_UNUSED,
115 ssize_t lost_bytes_adjustment ATTRIBUTE_UNUSED) const {}
Vladimir Marko83cc7ae2014-02-12 18:02:05 +0000116};
117
118template <bool kCount>
119class ArenaAllocatorStatsImpl {
120 public:
121 ArenaAllocatorStatsImpl();
122 ArenaAllocatorStatsImpl(const ArenaAllocatorStatsImpl& other) = default;
123 ArenaAllocatorStatsImpl& operator = (const ArenaAllocatorStatsImpl& other) = delete;
124
125 void Copy(const ArenaAllocatorStatsImpl& other);
126 void RecordAlloc(size_t bytes, ArenaAllocKind kind);
127 size_t NumAllocations() const;
128 size_t BytesAllocated() const;
129 void Dump(std::ostream& os, const Arena* first, ssize_t lost_bytes_adjustment) const;
130
131 private:
132 size_t num_allocations_;
133 // TODO: Use std::array<size_t, kNumArenaAllocKinds> from C++11 when we upgrade the STL.
134 size_t alloc_stats_[kNumArenaAllocKinds]; // Bytes used by various allocation kinds.
Vladimir Markobd9e9db2014-03-07 19:41:05 +0000135
Vladimir Marko8dea81c2014-06-06 14:50:36 +0100136 static const char* const kAllocNames[];
Vladimir Marko83cc7ae2014-02-12 18:02:05 +0000137};
138
139typedef ArenaAllocatorStatsImpl<kArenaAllocatorCountAllocations> ArenaAllocatorStats;
buzbee862a7602013-04-05 10:58:54 -0700140
Vladimir Marko2a408a32015-09-18 14:11:00 +0100141template <bool kAvailable, bool kValgrind>
142class ArenaAllocatorMemoryToolCheckImpl {
143 // This is the generic template but since there is a partial specialization
144 // for kValgrind == false, this can be instantiated only for kValgrind == true.
145 static_assert(kValgrind, "This template can be instantiated only for Valgrind.");
146 static_assert(kAvailable, "Valgrind implies memory tool availability.");
147
148 public:
149 ArenaAllocatorMemoryToolCheckImpl() : is_running_on_valgrind_(RUNNING_ON_MEMORY_TOOL) { }
150 bool IsRunningOnMemoryTool() { return is_running_on_valgrind_; }
151
152 private:
153 const bool is_running_on_valgrind_;
154};
155
156template <bool kAvailable>
157class ArenaAllocatorMemoryToolCheckImpl<kAvailable, false> {
158 public:
159 ArenaAllocatorMemoryToolCheckImpl() { }
160 bool IsRunningOnMemoryTool() { return kAvailable; }
161};
162
163typedef ArenaAllocatorMemoryToolCheckImpl<kMemoryToolIsAvailable, kMemoryToolIsValgrind>
164 ArenaAllocatorMemoryToolCheck;
165
166class ArenaAllocatorMemoryTool : private ArenaAllocatorMemoryToolCheck {
167 public:
168 using ArenaAllocatorMemoryToolCheck::IsRunningOnMemoryTool;
169
170 void MakeDefined(void* ptr, size_t size) {
Vladimir Marko7bda3b62015-10-07 12:44:31 +0000171 if (UNLIKELY(IsRunningOnMemoryTool())) {
172 DoMakeDefined(ptr, size);
Vladimir Marko2a408a32015-09-18 14:11:00 +0100173 }
174 }
175 void MakeUndefined(void* ptr, size_t size) {
Vladimir Marko7bda3b62015-10-07 12:44:31 +0000176 if (UNLIKELY(IsRunningOnMemoryTool())) {
177 DoMakeUndefined(ptr, size);
Vladimir Marko2a408a32015-09-18 14:11:00 +0100178 }
179 }
180 void MakeInaccessible(void* ptr, size_t size) {
Vladimir Marko7bda3b62015-10-07 12:44:31 +0000181 if (UNLIKELY(IsRunningOnMemoryTool())) {
182 DoMakeInaccessible(ptr, size);
Vladimir Marko2a408a32015-09-18 14:11:00 +0100183 }
184 }
Vladimir Marko7bda3b62015-10-07 12:44:31 +0000185
186 private:
187 void DoMakeDefined(void* ptr, size_t size);
188 void DoMakeUndefined(void* ptr, size_t size);
189 void DoMakeInaccessible(void* ptr, size_t size);
Vladimir Marko2a408a32015-09-18 14:11:00 +0100190};
191
Mathieu Chartierf6c4b3b2013-08-24 16:11:37 -0700192class Arena {
193 public:
194 static constexpr size_t kDefaultSize = 128 * KB;
Mathieu Chartierc6201fa2015-03-12 10:06:33 -0700195 Arena();
196 virtual ~Arena() { }
Mathieu Chartier9b34b242015-03-09 11:30:17 -0700197 // Reset is for pre-use and uses memset for performance.
Mathieu Chartierf6c4b3b2013-08-24 16:11:37 -0700198 void Reset();
Mathieu Chartier9b34b242015-03-09 11:30:17 -0700199 // Release is used inbetween uses and uses madvise for memory usage.
Mathieu Chartierc6201fa2015-03-12 10:06:33 -0700200 virtual void Release() { }
Mathieu Chartierf6c4b3b2013-08-24 16:11:37 -0700201 uint8_t* Begin() {
202 return memory_;
buzbee862a7602013-04-05 10:58:54 -0700203 }
204
Mathieu Chartierf6c4b3b2013-08-24 16:11:37 -0700205 uint8_t* End() {
206 return memory_ + size_;
207 }
208
209 size_t Size() const {
210 return size_;
211 }
212
213 size_t RemainingSpace() const {
214 return Size() - bytes_allocated_;
215 }
216
Mathieu Chartier49285c52014-12-02 15:43:48 -0800217 size_t GetBytesAllocated() const {
218 return bytes_allocated_;
219 }
220
Mathieu Chartiere401d142015-04-22 13:56:20 -0700221 // Return true if ptr is contained in the arena.
222 bool Contains(const void* ptr) const {
223 return memory_ <= ptr && ptr < memory_ + bytes_allocated_;
224 }
225
Mathieu Chartierc6201fa2015-03-12 10:06:33 -0700226 protected:
Mathieu Chartierf6c4b3b2013-08-24 16:11:37 -0700227 size_t bytes_allocated_;
228 uint8_t* memory_;
229 size_t size_;
Mathieu Chartierf6c4b3b2013-08-24 16:11:37 -0700230 Arena* next_;
231 friend class ArenaPool;
232 friend class ArenaAllocator;
Vladimir Marko83cc7ae2014-02-12 18:02:05 +0000233 friend class ArenaStack;
234 friend class ScopedArenaAllocator;
235 template <bool kCount> friend class ArenaAllocatorStatsImpl;
Mathieu Chartierc6201fa2015-03-12 10:06:33 -0700236
Vladimir Marko3e0e7172016-04-22 18:07:13 +0100237 friend class ArenaAllocatorTest;
238
Mathieu Chartierc6201fa2015-03-12 10:06:33 -0700239 private:
Mathieu Chartierf6c4b3b2013-08-24 16:11:37 -0700240 DISALLOW_COPY_AND_ASSIGN(Arena);
241};
242
Mathieu Chartierc6201fa2015-03-12 10:06:33 -0700243class MallocArena FINAL : public Arena {
244 public:
245 explicit MallocArena(size_t size = Arena::kDefaultSize);
246 virtual ~MallocArena();
247};
248
249class MemMapArena FINAL : public Arena {
250 public:
Nicolas Geoffray25e04562016-03-01 13:17:58 +0000251 MemMapArena(size_t size, bool low_4gb, const char* name);
Vladimir Marko3481ba22015-04-13 12:22:36 +0100252 virtual ~MemMapArena();
Mathieu Chartierc6201fa2015-03-12 10:06:33 -0700253 void Release() OVERRIDE;
254
255 private:
256 std::unique_ptr<MemMap> map_;
257};
258
Mathieu Chartierf6c4b3b2013-08-24 16:11:37 -0700259class ArenaPool {
260 public:
Nicolas Geoffray25e04562016-03-01 13:17:58 +0000261 ArenaPool(bool use_malloc = true,
262 bool low_4gb = false,
263 const char* name = "LinearAlloc");
Mathieu Chartierf6c4b3b2013-08-24 16:11:37 -0700264 ~ArenaPool();
Mathieu Chartier90443472015-07-16 20:32:27 -0700265 Arena* AllocArena(size_t size) REQUIRES(!lock_);
266 void FreeArenaChain(Arena* first) REQUIRES(!lock_);
267 size_t GetBytesAllocated() const REQUIRES(!lock_);
Jean-Philippe Halimica76a1a2016-02-02 19:48:52 +0100268 void ReclaimMemory() NO_THREAD_SAFETY_ANALYSIS;
269 void LockReclaimMemory() REQUIRES(!lock_);
Mathieu Chartierc6201fa2015-03-12 10:06:33 -0700270 // Trim the maps in arenas by madvising, used by JIT to reduce memory usage. This only works
271 // use_malloc is false.
Mathieu Chartier90443472015-07-16 20:32:27 -0700272 void TrimMaps() REQUIRES(!lock_);
Mathieu Chartierf6c4b3b2013-08-24 16:11:37 -0700273
274 private:
Mathieu Chartierc6201fa2015-03-12 10:06:33 -0700275 const bool use_malloc_;
Mathieu Chartier49285c52014-12-02 15:43:48 -0800276 mutable Mutex lock_ DEFAULT_MUTEX_ACQUIRED_AFTER;
Mathieu Chartierf6c4b3b2013-08-24 16:11:37 -0700277 Arena* free_arenas_ GUARDED_BY(lock_);
Mathieu Chartierc7853442015-03-27 14:35:38 -0700278 const bool low_4gb_;
Nicolas Geoffray25e04562016-03-01 13:17:58 +0000279 const char* name_;
Mathieu Chartierf6c4b3b2013-08-24 16:11:37 -0700280 DISALLOW_COPY_AND_ASSIGN(ArenaPool);
281};
282
Vladimir Markofda04322015-11-11 18:45:50 +0000283// Fast single-threaded allocator for zero-initialized memory chunks.
284//
285// Memory is allocated from ArenaPool in large chunks and then rationed through
286// the ArenaAllocator. It's returned to the ArenaPool only when the ArenaAllocator
287// is destroyed.
Vladimir Marko2a408a32015-09-18 14:11:00 +0100288class ArenaAllocator
289 : private DebugStackRefCounter, private ArenaAllocatorStats, private ArenaAllocatorMemoryTool {
Mathieu Chartierf6c4b3b2013-08-24 16:11:37 -0700290 public:
Mathieu Chartierf6c4b3b2013-08-24 16:11:37 -0700291 explicit ArenaAllocator(ArenaPool* pool);
292 ~ArenaAllocator();
293
Vladimir Marko2a408a32015-09-18 14:11:00 +0100294 using ArenaAllocatorMemoryTool::IsRunningOnMemoryTool;
295 using ArenaAllocatorMemoryTool::MakeDefined;
296 using ArenaAllocatorMemoryTool::MakeUndefined;
297 using ArenaAllocatorMemoryTool::MakeInaccessible;
298
Vladimir Marko8081d2b2014-07-31 15:33:43 +0100299 // Get adapter for use in STL containers. See arena_containers.h .
300 ArenaAllocatorAdapter<void> Adapter(ArenaAllocKind kind = kArenaAllocSTL);
301
Mathieu Chartierf6c4b3b2013-08-24 16:11:37 -0700302 // Returns zeroed memory.
Vladimir Markoe4fcc5b2015-02-13 10:28:29 +0000303 void* Alloc(size_t bytes, ArenaAllocKind kind = kArenaAllocMisc) ALWAYS_INLINE {
Vladimir Marko2a408a32015-09-18 14:11:00 +0100304 if (UNLIKELY(IsRunningOnMemoryTool())) {
305 return AllocWithMemoryTool(bytes, kind);
Mathieu Chartier75165d02013-09-12 14:00:31 -0700306 }
Mathieu Chartierb666f482015-02-18 14:33:14 -0800307 bytes = RoundUp(bytes, kAlignment);
Vladimir Marko83cc7ae2014-02-12 18:02:05 +0000308 ArenaAllocatorStats::RecordAlloc(bytes, kind);
Vladimir Marko3e0e7172016-04-22 18:07:13 +0100309 if (UNLIKELY(bytes > static_cast<size_t>(end_ - ptr_))) {
310 return AllocFromNewArena(bytes);
311 }
Mathieu Chartierf6c4b3b2013-08-24 16:11:37 -0700312 uint8_t* ret = ptr_;
313 ptr_ += bytes;
314 return ret;
315 }
316
Mathieu Chartiere401d142015-04-22 13:56:20 -0700317 // Realloc never frees the input pointer, it is the caller's job to do this if necessary.
318 void* Realloc(void* ptr, size_t ptr_size, size_t new_size,
319 ArenaAllocKind kind = kArenaAllocMisc) ALWAYS_INLINE {
320 DCHECK_GE(new_size, ptr_size);
321 DCHECK_EQ(ptr == nullptr, ptr_size == 0u);
322 auto* end = reinterpret_cast<uint8_t*>(ptr) + ptr_size;
323 // If we haven't allocated anything else, we can safely extend.
324 if (end == ptr_) {
Vladimir Marko2a408a32015-09-18 14:11:00 +0100325 DCHECK(!IsRunningOnMemoryTool()); // Red zone prevents end == ptr_.
Mathieu Chartiere401d142015-04-22 13:56:20 -0700326 const size_t size_delta = new_size - ptr_size;
327 // Check remain space.
328 const size_t remain = end_ - ptr_;
329 if (remain >= size_delta) {
330 ptr_ += size_delta;
331 ArenaAllocatorStats::RecordAlloc(size_delta, kind);
332 return ptr;
333 }
334 }
335 auto* new_ptr = Alloc(new_size, kind);
336 memcpy(new_ptr, ptr, ptr_size);
337 // TODO: Call free on ptr if linear alloc supports free.
338 return new_ptr;
339 }
340
Vladimir Markoe4fcc5b2015-02-13 10:28:29 +0000341 template <typename T>
Vladimir Markof6a35de2016-03-21 12:01:50 +0000342 T* Alloc(ArenaAllocKind kind = kArenaAllocMisc) {
343 return AllocArray<T>(1, kind);
344 }
345
346 template <typename T>
Vladimir Markoe4fcc5b2015-02-13 10:28:29 +0000347 T* AllocArray(size_t length, ArenaAllocKind kind = kArenaAllocMisc) {
348 return static_cast<T*>(Alloc(length * sizeof(T), kind));
Nicolas Geoffraya7062e02014-05-22 12:50:17 +0100349 }
350
Mathieu Chartierf6c4b3b2013-08-24 16:11:37 -0700351 size_t BytesAllocated() const;
Mathieu Chartiere401d142015-04-22 13:56:20 -0700352
Vladimir Marko83cc7ae2014-02-12 18:02:05 +0000353 MemStats GetMemStats() const;
Mathieu Chartiere401d142015-04-22 13:56:20 -0700354
Mathieu Chartierc7853442015-03-27 14:35:38 -0700355 // The BytesUsed method sums up bytes allocated from arenas in arena_head_ and nodes.
356 // TODO: Change BytesAllocated to this behavior?
357 size_t BytesUsed() const;
buzbee862a7602013-04-05 10:58:54 -0700358
Mathieu Chartiere401d142015-04-22 13:56:20 -0700359 ArenaPool* GetArenaPool() const {
360 return pool_;
361 }
362
363 bool Contains(const void* ptr) const;
364
Mathieu Chartierf6c4b3b2013-08-24 16:11:37 -0700365 private:
Vladimir Marko3e0e7172016-04-22 18:07:13 +0100366 void* AllocWithMemoryTool(size_t bytes, ArenaAllocKind kind);
Vladimir Marko3f84f2c2016-04-25 19:40:34 +0100367 uint8_t* AllocFromNewArena(size_t bytes);
Vladimir Marko3e0e7172016-04-22 18:07:13 +0100368
Mathieu Chartierb666f482015-02-18 14:33:14 -0800369 static constexpr size_t kAlignment = 8;
370
Mathieu Chartierf6c4b3b2013-08-24 16:11:37 -0700371 void UpdateBytesAllocated();
buzbee862a7602013-04-05 10:58:54 -0700372
Mathieu Chartierf6c4b3b2013-08-24 16:11:37 -0700373 ArenaPool* pool_;
374 uint8_t* begin_;
375 uint8_t* end_;
376 uint8_t* ptr_;
377 Arena* arena_head_;
Mathieu Chartierf6c4b3b2013-08-24 16:11:37 -0700378
Vladimir Marko8081d2b2014-07-31 15:33:43 +0100379 template <typename U>
380 friend class ArenaAllocatorAdapter;
381
Vladimir Marko3e0e7172016-04-22 18:07:13 +0100382 friend class ArenaAllocatorTest;
383
Mathieu Chartierf6c4b3b2013-08-24 16:11:37 -0700384 DISALLOW_COPY_AND_ASSIGN(ArenaAllocator);
buzbee862a7602013-04-05 10:58:54 -0700385}; // ArenaAllocator
386
Vladimir Marko83cc7ae2014-02-12 18:02:05 +0000387class MemStats {
388 public:
389 MemStats(const char* name, const ArenaAllocatorStats* stats, const Arena* first_arena,
390 ssize_t lost_bytes_adjustment = 0);
391 void Dump(std::ostream& os) const;
392
393 private:
394 const char* const name_;
395 const ArenaAllocatorStats* const stats_;
396 const Arena* const first_arena_;
397 const ssize_t lost_bytes_adjustment_;
Brian Carlstrom7934ac22013-07-26 10:54:15 -0700398}; // MemStats
buzbee862a7602013-04-05 10:58:54 -0700399
400} // namespace art
401
Mathieu Chartierb666f482015-02-18 14:33:14 -0800402#endif // ART_RUNTIME_BASE_ARENA_ALLOCATOR_H_