| 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" |
| (...skipping 17 matching lines...) Expand all Loading... |
| 28 // them if the pool is already full or memory pressure is high. | 28 // them if the pool is already full or memory pressure is high. |
| 29 virtual void ReturnSegment(Segment* memory); | 29 virtual void ReturnSegment(Segment* memory); |
| 30 | 30 |
| 31 size_t GetCurrentMemoryUsage() const; | 31 size_t GetCurrentMemoryUsage() const; |
| 32 size_t GetMaxMemoryUsage() const; | 32 size_t GetMaxMemoryUsage() const; |
| 33 | 33 |
| 34 size_t GetCurrentPoolSize() const; | 34 size_t GetCurrentPoolSize() const; |
| 35 | 35 |
| 36 void MemoryPressureNotification(MemoryPressureLevel level); | 36 void MemoryPressureNotification(MemoryPressureLevel level); |
| 37 | 37 |
| 38 virtual void ZoneCreation(const Zone* zone) {} |
| 39 virtual void ZoneDestruction(const Zone* zone) {} |
| 40 |
| 38 private: | 41 private: |
| 39 static const uint8_t kMinSegmentSizePower = 13; | 42 static const uint8_t kMinSegmentSizePower = 13; |
| 40 static const uint8_t kMaxSegmentSizePower = 18; | 43 static const uint8_t kMaxSegmentSizePower = 18; |
| 41 static const uint8_t kMaxSegmentsPerBucket = 5; | 44 static const uint8_t kMaxSegmentsPerBucket = 5; |
| 42 | 45 |
| 43 STATIC_ASSERT(kMinSegmentSizePower <= kMaxSegmentSizePower); | 46 STATIC_ASSERT(kMinSegmentSizePower <= kMaxSegmentSizePower); |
| 44 | 47 |
| 45 // Allocates a new segment. Returns nullptr on failed allocation. | 48 // Allocates a new segment. Returns nullptr on failed allocation. |
| 46 Segment* AllocateSegment(size_t bytes); | 49 Segment* AllocateSegment(size_t bytes); |
| 47 void FreeSegment(Segment* memory); | 50 void FreeSegment(Segment* memory); |
| (...skipping 19 matching lines...) Expand all Loading... |
| 67 | 70 |
| 68 base::AtomicValue<MemoryPressureLevel> memory_pressure_level_; | 71 base::AtomicValue<MemoryPressureLevel> memory_pressure_level_; |
| 69 | 72 |
| 70 DISALLOW_COPY_AND_ASSIGN(AccountingAllocator); | 73 DISALLOW_COPY_AND_ASSIGN(AccountingAllocator); |
| 71 }; | 74 }; |
| 72 | 75 |
| 73 } // namespace internal | 76 } // namespace internal |
| 74 } // namespace v8 | 77 } // namespace v8 |
| 75 | 78 |
| 76 #endif // V8_ZONE_ACCOUNTING_ALLOCATOR_H_ | 79 #endif // V8_ZONE_ACCOUNTING_ALLOCATOR_H_ |
| OLD | NEW |