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