OLD | NEW |
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 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_H_ | 5 #ifndef V8_ZONE_H_ |
6 #define V8_ZONE_H_ | 6 #define V8_ZONE_H_ |
7 | 7 |
8 #include <limits> | 8 #include <limits> |
9 | 9 |
10 #include "src/base/accounting-allocator.h" | 10 #include "src/base/accounting-allocator.h" |
(...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
151 | 151 |
152 Zone* zone() const { return zone_; } | 152 Zone* zone() const { return zone_; } |
153 | 153 |
154 private: | 154 private: |
155 Zone* zone_; | 155 Zone* zone_; |
156 }; | 156 }; |
157 | 157 |
158 | 158 |
159 // The ZoneAllocationPolicy is used to specialize generic data | 159 // The ZoneAllocationPolicy is used to specialize generic data |
160 // structures to allocate themselves and their elements in the Zone. | 160 // structures to allocate themselves and their elements in the Zone. |
161 class ZoneAllocationPolicy final { | 161 class ZoneAllocationPolicy { |
162 public: | 162 public: |
163 explicit ZoneAllocationPolicy(Zone* zone) : zone_(zone) { } | 163 explicit ZoneAllocationPolicy(Zone* zone) : zone_(zone) { } |
164 void* New(size_t size) { return zone()->New(size); } | 164 void* New(size_t size) { return zone()->New(size); } |
165 static void Delete(void* pointer) {} | 165 static void Delete(void* pointer) {} |
166 Zone* zone() const { return zone_; } | 166 Zone* zone() const { return zone_; } |
167 | 167 |
168 private: | 168 private: |
169 Zone* zone_; | 169 Zone* zone_; |
170 }; | 170 }; |
171 | 171 |
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
243 void operator delete(void* pointer) { UNREACHABLE(); } | 243 void operator delete(void* pointer) { UNREACHABLE(); } |
244 void operator delete(void* pointer, Zone* zone) { UNREACHABLE(); } | 244 void operator delete(void* pointer, Zone* zone) { UNREACHABLE(); } |
245 }; | 245 }; |
246 | 246 |
247 typedef base::TemplateHashMapImpl<ZoneAllocationPolicy> ZoneHashMap; | 247 typedef base::TemplateHashMapImpl<ZoneAllocationPolicy> ZoneHashMap; |
248 | 248 |
249 } // namespace internal | 249 } // namespace internal |
250 } // namespace v8 | 250 } // namespace v8 |
251 | 251 |
252 #endif // V8_ZONE_H_ | 252 #endif // V8_ZONE_H_ |
OLD | NEW |