OLD | NEW |
(Empty) | |
| 1 // Copyright 2016 the V8 project authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #ifndef V8_ZONE_ACCOUNTING_ALLOCATOR_H_ |
| 6 #define V8_ZONE_ACCOUNTING_ALLOCATOR_H_ |
| 7 |
| 8 #include "include/v8-platform.h" |
| 9 #include "src/base/atomic-utils.h" |
| 10 #include "src/base/atomicops.h" |
| 11 #include "src/base/macros.h" |
| 12 #include "src/base/platform/mutex.h" |
| 13 #include "src/base/platform/semaphore.h" |
| 14 #include "src/base/platform/time.h" |
| 15 #include "src/zone/zone-segment.h" |
| 16 |
| 17 namespace v8 { |
| 18 namespace internal { |
| 19 |
| 20 class AccountingAllocator { |
| 21 public: |
| 22 AccountingAllocator() = default; |
| 23 virtual ~AccountingAllocator() = default; |
| 24 |
| 25 virtual Segment* AllocateSegment(size_t bytes); |
| 26 virtual void FreeSegment(Segment* memory); |
| 27 |
| 28 size_t GetCurrentMemoryUsage() const; |
| 29 size_t GetMaxMemoryUsage() const; |
| 30 |
| 31 private: |
| 32 base::AtomicWord current_memory_usage_ = 0; |
| 33 base::AtomicWord max_memory_usage_ = 0; |
| 34 |
| 35 DISALLOW_COPY_AND_ASSIGN(AccountingAllocator); |
| 36 }; |
| 37 |
| 38 } // namespace internal |
| 39 } // namespace v8 |
| 40 |
| 41 #endif // V8_ZONE_ACCOUNTING_ALLOCATOR_H_ |
OLD | NEW |