| 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 #include "testing/gtest/include/gtest/gtest_prod.h" | 16 #include "testing/gtest/include/gtest/gtest_prod.h" |
| 17 | 17 |
| 18 namespace v8 { | 18 namespace v8 { |
| 19 namespace internal { | 19 namespace internal { |
| 20 | 20 |
| 21 class V8_EXPORT_PRIVATE AccountingAllocator { | 21 class V8_EXPORT_PRIVATE AccountingAllocator { |
| 22 public: | 22 public: |
| 23 static const size_t kMaxPoolSizeLowMemoryDevice = 8ul * KB; | 23 static const size_t kMaxPoolSizeLowMemoryDevice = 8ul * KB; |
| 24 static const size_t kMaxPoolSizeMediumMemoryDevice = 1ul * MB; | 24 static const size_t kMaxPoolSizeMediumMemoryDevice = 8ul * KB; |
| 25 static const size_t kMaxPoolSizeHighMemoryDevice = 2ul * MB; | 25 static const size_t kMaxPoolSizeHighMemoryDevice = 8ul * KB; |
| 26 static const size_t kMaxPoolSizeHugeMemoryDevice = 3ul * MB; | 26 static const size_t kMaxPoolSizeHugeMemoryDevice = 8ul * KB; |
| 27 | 27 |
| 28 AccountingAllocator(); | 28 AccountingAllocator(); |
| 29 virtual ~AccountingAllocator(); | 29 virtual ~AccountingAllocator(); |
| 30 | 30 |
| 31 // Gets an empty segment from the pool or creates a new one. | 31 // Gets an empty segment from the pool or creates a new one. |
| 32 virtual Segment* GetSegment(size_t bytes); | 32 virtual Segment* GetSegment(size_t bytes); |
| 33 // Return unneeded segments to either insert them into the pool or release | 33 // Return unneeded segments to either insert them into the pool or release |
| 34 // them if the pool is already full or memory pressure is high. | 34 // them if the pool is already full or memory pressure is high. |
| 35 virtual void ReturnSegment(Segment* memory); | 35 virtual void ReturnSegment(Segment* memory); |
| 36 | 36 |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 85 | 85 |
| 86 base::AtomicValue<MemoryPressureLevel> memory_pressure_level_; | 86 base::AtomicValue<MemoryPressureLevel> memory_pressure_level_; |
| 87 | 87 |
| 88 DISALLOW_COPY_AND_ASSIGN(AccountingAllocator); | 88 DISALLOW_COPY_AND_ASSIGN(AccountingAllocator); |
| 89 }; | 89 }; |
| 90 | 90 |
| 91 } // namespace internal | 91 } // namespace internal |
| 92 } // namespace v8 | 92 } // namespace v8 |
| 93 | 93 |
| 94 #endif // V8_ZONE_ACCOUNTING_ALLOCATOR_H_ | 94 #endif // V8_ZONE_ACCOUNTING_ALLOCATOR_H_ |
| OLD | NEW |