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