buzbee | 862a760 | 2013-04-05 10:58:54 -0700 | [diff] [blame] | 1 | /* |
| 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 Chartier | b666f48 | 2015-02-18 14:33:14 -0800 | [diff] [blame] | 17 | #ifndef ART_RUNTIME_BASE_ARENA_ALLOCATOR_H_ |
| 18 | #define ART_RUNTIME_BASE_ARENA_ALLOCATOR_H_ |
buzbee | 862a760 | 2013-04-05 10:58:54 -0700 | [diff] [blame] | 19 | |
| 20 | #include <stdint.h> |
| 21 | #include <stddef.h> |
Mathieu Chartier | f6c4b3b | 2013-08-24 16:11:37 -0700 | [diff] [blame] | 22 | |
Vladimir Marko | 80afd02 | 2015-05-19 18:08:00 +0100 | [diff] [blame] | 23 | #include "base/bit_utils.h" |
Mathieu Chartier | b666f48 | 2015-02-18 14:33:14 -0800 | [diff] [blame] | 24 | #include "debug_stack.h" |
| 25 | #include "macros.h" |
Mathieu Chartier | b666f48 | 2015-02-18 14:33:14 -0800 | [diff] [blame] | 26 | #include "mutex.h" |
buzbee | 862a760 | 2013-04-05 10:58:54 -0700 | [diff] [blame] | 27 | |
| 28 | namespace art { |
| 29 | |
Mathieu Chartier | f6c4b3b | 2013-08-24 16:11:37 -0700 | [diff] [blame] | 30 | class Arena; |
| 31 | class ArenaPool; |
| 32 | class ArenaAllocator; |
Vladimir Marko | 83cc7ae | 2014-02-12 18:02:05 +0000 | [diff] [blame] | 33 | class ArenaStack; |
| 34 | class ScopedArenaAllocator; |
Vladimir Marko | 3481ba2 | 2015-04-13 12:22:36 +0100 | [diff] [blame] | 35 | class MemMap; |
Vladimir Marko | 83cc7ae | 2014-02-12 18:02:05 +0000 | [diff] [blame] | 36 | class MemStats; |
| 37 | |
Vladimir Marko | 8081d2b | 2014-07-31 15:33:43 +0100 | [diff] [blame] | 38 | template <typename T> |
| 39 | class ArenaAllocatorAdapter; |
| 40 | |
Vladimir Marko | 83cc7ae | 2014-02-12 18:02:05 +0000 | [diff] [blame] | 41 | static constexpr bool kArenaAllocatorCountAllocations = false; |
| 42 | |
| 43 | // Type of allocation for memory tuning. |
| 44 | enum ArenaAllocKind { |
| 45 | kArenaAllocMisc, |
Vladimir Marko | e39c54e | 2014-09-22 14:50:02 +0100 | [diff] [blame] | 46 | kArenaAllocBBList, |
| 47 | kArenaAllocBBPredecessors, |
| 48 | kArenaAllocDfsPreOrder, |
| 49 | kArenaAllocDfsPostOrder, |
| 50 | kArenaAllocDomPostOrder, |
| 51 | kArenaAllocTopologicalSortOrder, |
| 52 | kArenaAllocLoweringInfo, |
Vladimir Marko | 83cc7ae | 2014-02-12 18:02:05 +0000 | [diff] [blame] | 53 | kArenaAllocLIR, |
Vladimir Marko | 8dea81c | 2014-06-06 14:50:36 +0100 | [diff] [blame] | 54 | kArenaAllocLIRResourceMask, |
Vladimir Marko | e39c54e | 2014-09-22 14:50:02 +0100 | [diff] [blame] | 55 | kArenaAllocSwitchTable, |
| 56 | kArenaAllocFillArrayData, |
| 57 | kArenaAllocSlowPaths, |
Vladimir Marko | 83cc7ae | 2014-02-12 18:02:05 +0000 | [diff] [blame] | 58 | kArenaAllocMIR, |
| 59 | kArenaAllocDFInfo, |
| 60 | kArenaAllocGrowableArray, |
| 61 | kArenaAllocGrowableBitMap, |
Vladimir Marko | e39c54e | 2014-09-22 14:50:02 +0100 | [diff] [blame] | 62 | kArenaAllocSSAToDalvikMap, |
Vladimir Marko | 83cc7ae | 2014-02-12 18:02:05 +0000 | [diff] [blame] | 63 | kArenaAllocDalvikToSSAMap, |
| 64 | kArenaAllocDebugInfo, |
Vladimir Marko | 83cc7ae | 2014-02-12 18:02:05 +0000 | [diff] [blame] | 65 | kArenaAllocRegAlloc, |
| 66 | kArenaAllocData, |
Vladimir Marko | 83cc7ae | 2014-02-12 18:02:05 +0000 | [diff] [blame] | 67 | kArenaAllocSTL, |
Vladimir Marko | f9f6441 | 2015-09-02 14:05:49 +0100 | [diff] [blame] | 68 | kArenaAllocGraph, |
| 69 | kArenaAllocBasicBlock, |
Vladimir Marko | 6058455 | 2015-09-03 13:35:12 +0000 | [diff] [blame^] | 70 | kArenaAllocPredecessors, |
| 71 | kArenaAllocSuccessors, |
| 72 | kArenaAllocDominated, |
Vladimir Marko | f9f6441 | 2015-09-02 14:05:49 +0100 | [diff] [blame] | 73 | kArenaAllocInstruction, |
| 74 | kArenaAllocLoopInfo, |
| 75 | kArenaAllocTryCatchInfo, |
| 76 | kArenaAllocUseListNode, |
| 77 | kArenaAllocEnvironment, |
| 78 | kArenaAllocMoveOperands, |
| 79 | kArenaAllocCodeBuffer, |
| 80 | kArenaAllocStackMaps, |
| 81 | kArenaAllocBaselineMaps, |
| 82 | kArenaAllocOptimization, |
Vladimir Marko | 83cc7ae | 2014-02-12 18:02:05 +0000 | [diff] [blame] | 83 | kNumArenaAllocKinds |
| 84 | }; |
| 85 | |
| 86 | template <bool kCount> |
| 87 | class ArenaAllocatorStatsImpl; |
| 88 | |
| 89 | template <> |
| 90 | class ArenaAllocatorStatsImpl<false> { |
| 91 | public: |
| 92 | ArenaAllocatorStatsImpl() = default; |
| 93 | ArenaAllocatorStatsImpl(const ArenaAllocatorStatsImpl& other) = default; |
| 94 | ArenaAllocatorStatsImpl& operator = (const ArenaAllocatorStatsImpl& other) = delete; |
| 95 | |
| 96 | void Copy(const ArenaAllocatorStatsImpl& other) { UNUSED(other); } |
Ian Rogers | 6a3c1fc | 2014-10-31 00:33:20 -0700 | [diff] [blame] | 97 | void RecordAlloc(size_t bytes, ArenaAllocKind kind) { UNUSED(bytes, kind); } |
Vladimir Marko | 83cc7ae | 2014-02-12 18:02:05 +0000 | [diff] [blame] | 98 | size_t NumAllocations() const { return 0u; } |
| 99 | size_t BytesAllocated() const { return 0u; } |
| 100 | void Dump(std::ostream& os, const Arena* first, ssize_t lost_bytes_adjustment) const { |
| 101 | UNUSED(os); UNUSED(first); UNUSED(lost_bytes_adjustment); |
| 102 | } |
| 103 | }; |
| 104 | |
| 105 | template <bool kCount> |
| 106 | class ArenaAllocatorStatsImpl { |
| 107 | public: |
| 108 | ArenaAllocatorStatsImpl(); |
| 109 | ArenaAllocatorStatsImpl(const ArenaAllocatorStatsImpl& other) = default; |
| 110 | ArenaAllocatorStatsImpl& operator = (const ArenaAllocatorStatsImpl& other) = delete; |
| 111 | |
| 112 | void Copy(const ArenaAllocatorStatsImpl& other); |
| 113 | void RecordAlloc(size_t bytes, ArenaAllocKind kind); |
| 114 | size_t NumAllocations() const; |
| 115 | size_t BytesAllocated() const; |
| 116 | void Dump(std::ostream& os, const Arena* first, ssize_t lost_bytes_adjustment) const; |
| 117 | |
| 118 | private: |
| 119 | size_t num_allocations_; |
| 120 | // TODO: Use std::array<size_t, kNumArenaAllocKinds> from C++11 when we upgrade the STL. |
| 121 | size_t alloc_stats_[kNumArenaAllocKinds]; // Bytes used by various allocation kinds. |
Vladimir Marko | bd9e9db | 2014-03-07 19:41:05 +0000 | [diff] [blame] | 122 | |
Vladimir Marko | 8dea81c | 2014-06-06 14:50:36 +0100 | [diff] [blame] | 123 | static const char* const kAllocNames[]; |
Vladimir Marko | 83cc7ae | 2014-02-12 18:02:05 +0000 | [diff] [blame] | 124 | }; |
| 125 | |
| 126 | typedef ArenaAllocatorStatsImpl<kArenaAllocatorCountAllocations> ArenaAllocatorStats; |
buzbee | 862a760 | 2013-04-05 10:58:54 -0700 | [diff] [blame] | 127 | |
Mathieu Chartier | f6c4b3b | 2013-08-24 16:11:37 -0700 | [diff] [blame] | 128 | class Arena { |
| 129 | public: |
| 130 | static constexpr size_t kDefaultSize = 128 * KB; |
Mathieu Chartier | c6201fa | 2015-03-12 10:06:33 -0700 | [diff] [blame] | 131 | Arena(); |
| 132 | virtual ~Arena() { } |
Mathieu Chartier | 9b34b24 | 2015-03-09 11:30:17 -0700 | [diff] [blame] | 133 | // Reset is for pre-use and uses memset for performance. |
Mathieu Chartier | f6c4b3b | 2013-08-24 16:11:37 -0700 | [diff] [blame] | 134 | void Reset(); |
Mathieu Chartier | 9b34b24 | 2015-03-09 11:30:17 -0700 | [diff] [blame] | 135 | // Release is used inbetween uses and uses madvise for memory usage. |
Mathieu Chartier | c6201fa | 2015-03-12 10:06:33 -0700 | [diff] [blame] | 136 | virtual void Release() { } |
Mathieu Chartier | f6c4b3b | 2013-08-24 16:11:37 -0700 | [diff] [blame] | 137 | uint8_t* Begin() { |
| 138 | return memory_; |
buzbee | 862a760 | 2013-04-05 10:58:54 -0700 | [diff] [blame] | 139 | } |
| 140 | |
Mathieu Chartier | f6c4b3b | 2013-08-24 16:11:37 -0700 | [diff] [blame] | 141 | uint8_t* End() { |
| 142 | return memory_ + size_; |
| 143 | } |
| 144 | |
| 145 | size_t Size() const { |
| 146 | return size_; |
| 147 | } |
| 148 | |
| 149 | size_t RemainingSpace() const { |
| 150 | return Size() - bytes_allocated_; |
| 151 | } |
| 152 | |
Mathieu Chartier | 49285c5 | 2014-12-02 15:43:48 -0800 | [diff] [blame] | 153 | size_t GetBytesAllocated() const { |
| 154 | return bytes_allocated_; |
| 155 | } |
| 156 | |
Mathieu Chartier | e401d14 | 2015-04-22 13:56:20 -0700 | [diff] [blame] | 157 | // Return true if ptr is contained in the arena. |
| 158 | bool Contains(const void* ptr) const { |
| 159 | return memory_ <= ptr && ptr < memory_ + bytes_allocated_; |
| 160 | } |
| 161 | |
Mathieu Chartier | c6201fa | 2015-03-12 10:06:33 -0700 | [diff] [blame] | 162 | protected: |
Mathieu Chartier | f6c4b3b | 2013-08-24 16:11:37 -0700 | [diff] [blame] | 163 | size_t bytes_allocated_; |
| 164 | uint8_t* memory_; |
| 165 | size_t size_; |
Mathieu Chartier | f6c4b3b | 2013-08-24 16:11:37 -0700 | [diff] [blame] | 166 | Arena* next_; |
| 167 | friend class ArenaPool; |
| 168 | friend class ArenaAllocator; |
Vladimir Marko | 83cc7ae | 2014-02-12 18:02:05 +0000 | [diff] [blame] | 169 | friend class ArenaStack; |
| 170 | friend class ScopedArenaAllocator; |
| 171 | template <bool kCount> friend class ArenaAllocatorStatsImpl; |
Mathieu Chartier | c6201fa | 2015-03-12 10:06:33 -0700 | [diff] [blame] | 172 | |
| 173 | private: |
Mathieu Chartier | f6c4b3b | 2013-08-24 16:11:37 -0700 | [diff] [blame] | 174 | DISALLOW_COPY_AND_ASSIGN(Arena); |
| 175 | }; |
| 176 | |
Mathieu Chartier | c6201fa | 2015-03-12 10:06:33 -0700 | [diff] [blame] | 177 | class MallocArena FINAL : public Arena { |
| 178 | public: |
| 179 | explicit MallocArena(size_t size = Arena::kDefaultSize); |
| 180 | virtual ~MallocArena(); |
| 181 | }; |
| 182 | |
| 183 | class MemMapArena FINAL : public Arena { |
| 184 | public: |
Roland Levillain | 3887c46 | 2015-08-12 18:15:42 +0100 | [diff] [blame] | 185 | MemMapArena(size_t size, bool low_4gb); |
Vladimir Marko | 3481ba2 | 2015-04-13 12:22:36 +0100 | [diff] [blame] | 186 | virtual ~MemMapArena(); |
Mathieu Chartier | c6201fa | 2015-03-12 10:06:33 -0700 | [diff] [blame] | 187 | void Release() OVERRIDE; |
| 188 | |
| 189 | private: |
| 190 | std::unique_ptr<MemMap> map_; |
| 191 | }; |
| 192 | |
Mathieu Chartier | f6c4b3b | 2013-08-24 16:11:37 -0700 | [diff] [blame] | 193 | class ArenaPool { |
| 194 | public: |
Mathieu Chartier | c785344 | 2015-03-27 14:35:38 -0700 | [diff] [blame] | 195 | explicit ArenaPool(bool use_malloc = true, bool low_4gb = false); |
Mathieu Chartier | f6c4b3b | 2013-08-24 16:11:37 -0700 | [diff] [blame] | 196 | ~ArenaPool(); |
Mathieu Chartier | 9044347 | 2015-07-16 20:32:27 -0700 | [diff] [blame] | 197 | Arena* AllocArena(size_t size) REQUIRES(!lock_); |
| 198 | void FreeArenaChain(Arena* first) REQUIRES(!lock_); |
| 199 | size_t GetBytesAllocated() const REQUIRES(!lock_); |
Mathieu Chartier | c6201fa | 2015-03-12 10:06:33 -0700 | [diff] [blame] | 200 | // Trim the maps in arenas by madvising, used by JIT to reduce memory usage. This only works |
| 201 | // use_malloc is false. |
Mathieu Chartier | 9044347 | 2015-07-16 20:32:27 -0700 | [diff] [blame] | 202 | void TrimMaps() REQUIRES(!lock_); |
Mathieu Chartier | f6c4b3b | 2013-08-24 16:11:37 -0700 | [diff] [blame] | 203 | |
| 204 | private: |
Mathieu Chartier | c6201fa | 2015-03-12 10:06:33 -0700 | [diff] [blame] | 205 | const bool use_malloc_; |
Mathieu Chartier | 49285c5 | 2014-12-02 15:43:48 -0800 | [diff] [blame] | 206 | mutable Mutex lock_ DEFAULT_MUTEX_ACQUIRED_AFTER; |
Mathieu Chartier | f6c4b3b | 2013-08-24 16:11:37 -0700 | [diff] [blame] | 207 | Arena* free_arenas_ GUARDED_BY(lock_); |
Mathieu Chartier | c785344 | 2015-03-27 14:35:38 -0700 | [diff] [blame] | 208 | const bool low_4gb_; |
Mathieu Chartier | f6c4b3b | 2013-08-24 16:11:37 -0700 | [diff] [blame] | 209 | DISALLOW_COPY_AND_ASSIGN(ArenaPool); |
| 210 | }; |
| 211 | |
Vladimir Marko | 8081d2b | 2014-07-31 15:33:43 +0100 | [diff] [blame] | 212 | class ArenaAllocator : private DebugStackRefCounter, private ArenaAllocatorStats { |
Mathieu Chartier | f6c4b3b | 2013-08-24 16:11:37 -0700 | [diff] [blame] | 213 | public: |
Mathieu Chartier | f6c4b3b | 2013-08-24 16:11:37 -0700 | [diff] [blame] | 214 | explicit ArenaAllocator(ArenaPool* pool); |
| 215 | ~ArenaAllocator(); |
| 216 | |
Vladimir Marko | 8081d2b | 2014-07-31 15:33:43 +0100 | [diff] [blame] | 217 | // Get adapter for use in STL containers. See arena_containers.h . |
| 218 | ArenaAllocatorAdapter<void> Adapter(ArenaAllocKind kind = kArenaAllocSTL); |
| 219 | |
Mathieu Chartier | f6c4b3b | 2013-08-24 16:11:37 -0700 | [diff] [blame] | 220 | // Returns zeroed memory. |
Vladimir Marko | e4fcc5b | 2015-02-13 10:28:29 +0000 | [diff] [blame] | 221 | void* Alloc(size_t bytes, ArenaAllocKind kind = kArenaAllocMisc) ALWAYS_INLINE { |
Evgenii Stepanov | 1e13374 | 2015-05-20 12:30:59 -0700 | [diff] [blame] | 222 | if (UNLIKELY(is_running_on_memory_tool_)) { |
Mathieu Chartier | 75165d0 | 2013-09-12 14:00:31 -0700 | [diff] [blame] | 223 | return AllocValgrind(bytes, kind); |
| 224 | } |
Mathieu Chartier | b666f48 | 2015-02-18 14:33:14 -0800 | [diff] [blame] | 225 | bytes = RoundUp(bytes, kAlignment); |
Mathieu Chartier | f6c4b3b | 2013-08-24 16:11:37 -0700 | [diff] [blame] | 226 | if (UNLIKELY(ptr_ + bytes > end_)) { |
| 227 | // Obtain a new block. |
| 228 | ObtainNewArenaForAllocation(bytes); |
| 229 | if (UNLIKELY(ptr_ == nullptr)) { |
| 230 | return nullptr; |
| 231 | } |
| 232 | } |
Vladimir Marko | 83cc7ae | 2014-02-12 18:02:05 +0000 | [diff] [blame] | 233 | ArenaAllocatorStats::RecordAlloc(bytes, kind); |
Mathieu Chartier | f6c4b3b | 2013-08-24 16:11:37 -0700 | [diff] [blame] | 234 | uint8_t* ret = ptr_; |
| 235 | ptr_ += bytes; |
| 236 | return ret; |
| 237 | } |
| 238 | |
Mathieu Chartier | e401d14 | 2015-04-22 13:56:20 -0700 | [diff] [blame] | 239 | // Realloc never frees the input pointer, it is the caller's job to do this if necessary. |
| 240 | void* Realloc(void* ptr, size_t ptr_size, size_t new_size, |
| 241 | ArenaAllocKind kind = kArenaAllocMisc) ALWAYS_INLINE { |
| 242 | DCHECK_GE(new_size, ptr_size); |
| 243 | DCHECK_EQ(ptr == nullptr, ptr_size == 0u); |
| 244 | auto* end = reinterpret_cast<uint8_t*>(ptr) + ptr_size; |
| 245 | // If we haven't allocated anything else, we can safely extend. |
| 246 | if (end == ptr_) { |
| 247 | const size_t size_delta = new_size - ptr_size; |
| 248 | // Check remain space. |
| 249 | const size_t remain = end_ - ptr_; |
| 250 | if (remain >= size_delta) { |
| 251 | ptr_ += size_delta; |
| 252 | ArenaAllocatorStats::RecordAlloc(size_delta, kind); |
| 253 | return ptr; |
| 254 | } |
| 255 | } |
| 256 | auto* new_ptr = Alloc(new_size, kind); |
| 257 | memcpy(new_ptr, ptr, ptr_size); |
| 258 | // TODO: Call free on ptr if linear alloc supports free. |
| 259 | return new_ptr; |
| 260 | } |
| 261 | |
Vladimir Marko | e4fcc5b | 2015-02-13 10:28:29 +0000 | [diff] [blame] | 262 | template <typename T> |
| 263 | T* AllocArray(size_t length, ArenaAllocKind kind = kArenaAllocMisc) { |
| 264 | return static_cast<T*>(Alloc(length * sizeof(T), kind)); |
Nicolas Geoffray | a7062e0 | 2014-05-22 12:50:17 +0100 | [diff] [blame] | 265 | } |
| 266 | |
Mathieu Chartier | 75165d0 | 2013-09-12 14:00:31 -0700 | [diff] [blame] | 267 | void* AllocValgrind(size_t bytes, ArenaAllocKind kind); |
Mathieu Chartier | e401d14 | 2015-04-22 13:56:20 -0700 | [diff] [blame] | 268 | |
Mathieu Chartier | f6c4b3b | 2013-08-24 16:11:37 -0700 | [diff] [blame] | 269 | void ObtainNewArenaForAllocation(size_t allocation_size); |
Mathieu Chartier | e401d14 | 2015-04-22 13:56:20 -0700 | [diff] [blame] | 270 | |
Mathieu Chartier | f6c4b3b | 2013-08-24 16:11:37 -0700 | [diff] [blame] | 271 | size_t BytesAllocated() const; |
Mathieu Chartier | e401d14 | 2015-04-22 13:56:20 -0700 | [diff] [blame] | 272 | |
Vladimir Marko | 83cc7ae | 2014-02-12 18:02:05 +0000 | [diff] [blame] | 273 | MemStats GetMemStats() const; |
Mathieu Chartier | e401d14 | 2015-04-22 13:56:20 -0700 | [diff] [blame] | 274 | |
Mathieu Chartier | c785344 | 2015-03-27 14:35:38 -0700 | [diff] [blame] | 275 | // The BytesUsed method sums up bytes allocated from arenas in arena_head_ and nodes. |
| 276 | // TODO: Change BytesAllocated to this behavior? |
| 277 | size_t BytesUsed() const; |
buzbee | 862a760 | 2013-04-05 10:58:54 -0700 | [diff] [blame] | 278 | |
Mathieu Chartier | e401d14 | 2015-04-22 13:56:20 -0700 | [diff] [blame] | 279 | ArenaPool* GetArenaPool() const { |
| 280 | return pool_; |
| 281 | } |
| 282 | |
| 283 | bool Contains(const void* ptr) const; |
| 284 | |
Mathieu Chartier | f6c4b3b | 2013-08-24 16:11:37 -0700 | [diff] [blame] | 285 | private: |
Mathieu Chartier | b666f48 | 2015-02-18 14:33:14 -0800 | [diff] [blame] | 286 | static constexpr size_t kAlignment = 8; |
| 287 | |
Mathieu Chartier | f6c4b3b | 2013-08-24 16:11:37 -0700 | [diff] [blame] | 288 | void UpdateBytesAllocated(); |
buzbee | 862a760 | 2013-04-05 10:58:54 -0700 | [diff] [blame] | 289 | |
Mathieu Chartier | f6c4b3b | 2013-08-24 16:11:37 -0700 | [diff] [blame] | 290 | ArenaPool* pool_; |
| 291 | uint8_t* begin_; |
| 292 | uint8_t* end_; |
| 293 | uint8_t* ptr_; |
| 294 | Arena* arena_head_; |
Evgenii Stepanov | 1e13374 | 2015-05-20 12:30:59 -0700 | [diff] [blame] | 295 | bool is_running_on_memory_tool_; |
Mathieu Chartier | f6c4b3b | 2013-08-24 16:11:37 -0700 | [diff] [blame] | 296 | |
Vladimir Marko | 8081d2b | 2014-07-31 15:33:43 +0100 | [diff] [blame] | 297 | template <typename U> |
| 298 | friend class ArenaAllocatorAdapter; |
| 299 | |
Mathieu Chartier | f6c4b3b | 2013-08-24 16:11:37 -0700 | [diff] [blame] | 300 | DISALLOW_COPY_AND_ASSIGN(ArenaAllocator); |
buzbee | 862a760 | 2013-04-05 10:58:54 -0700 | [diff] [blame] | 301 | }; // ArenaAllocator |
| 302 | |
Vladimir Marko | 83cc7ae | 2014-02-12 18:02:05 +0000 | [diff] [blame] | 303 | class MemStats { |
| 304 | public: |
| 305 | MemStats(const char* name, const ArenaAllocatorStats* stats, const Arena* first_arena, |
| 306 | ssize_t lost_bytes_adjustment = 0); |
| 307 | void Dump(std::ostream& os) const; |
| 308 | |
| 309 | private: |
| 310 | const char* const name_; |
| 311 | const ArenaAllocatorStats* const stats_; |
| 312 | const Arena* const first_arena_; |
| 313 | const ssize_t lost_bytes_adjustment_; |
Brian Carlstrom | 7934ac2 | 2013-07-26 10:54:15 -0700 | [diff] [blame] | 314 | }; // MemStats |
buzbee | 862a760 | 2013-04-05 10:58:54 -0700 | [diff] [blame] | 315 | |
| 316 | } // namespace art |
| 317 | |
Mathieu Chartier | b666f48 | 2015-02-18 14:33:14 -0800 | [diff] [blame] | 318 | #endif // ART_RUNTIME_BASE_ARENA_ALLOCATOR_H_ |