| OLD | NEW |
| 1 // Copyright 2014 the V8 project authors. All rights reserved. | 1 // Copyright 2014 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_ZONE_ALLOCATOR_H_ | 5 #ifndef V8_ZONE_ZONE_ALLOCATOR_H_ |
| 6 #define V8_ZONE_ZONE_ALLOCATOR_H_ | 6 #define V8_ZONE_ZONE_ALLOCATOR_H_ |
| 7 #include <limits> | 7 #include <limits> |
| 8 | 8 |
| 9 #include "src/zone/zone.h" | 9 #include "src/zone/zone.h" |
| 10 | 10 |
| 11 namespace v8 { | 11 namespace v8 { |
| 12 namespace internal { | 12 namespace internal { |
| 13 | 13 |
| 14 template <typename T> | 14 template <typename T> |
| 15 class zone_allocator { | 15 class zone_allocator { |
| 16 public: | 16 public: |
| 17 typedef T* pointer; | 17 typedef T* pointer; |
| 18 typedef const T* const_pointer; | 18 typedef const T* const_pointer; |
| 19 typedef T& reference; | 19 typedef T& reference; |
| 20 typedef const T& const_reference; | 20 typedef const T& const_reference; |
| 21 typedef T value_type; | 21 typedef T value_type; |
| 22 typedef size_t size_type; | 22 typedef size_t size_type; |
| 23 typedef ptrdiff_t difference_type; | 23 typedef ptrdiff_t difference_type; |
| 24 template <class O> | 24 template <class O> |
| 25 struct rebind { | 25 struct rebind { |
| 26 typedef zone_allocator<O> other; | 26 typedef zone_allocator<O> other; |
| 27 }; | 27 }; |
| 28 | 28 |
| 29 // TODO(bbudge) Remove when V8 updates to MSVS 2015. See crbug.com/603131. |
| 30 zone_allocator() : zone_(nullptr) { UNREACHABLE(); } |
| 29 explicit zone_allocator(Zone* zone) throw() : zone_(zone) {} | 31 explicit zone_allocator(Zone* zone) throw() : zone_(zone) {} |
| 30 explicit zone_allocator(const zone_allocator& other) throw() | 32 explicit zone_allocator(const zone_allocator& other) throw() |
| 31 : zone_(other.zone_) {} | 33 : zone_(other.zone_) {} |
| 32 template <typename U> | 34 template <typename U> |
| 33 zone_allocator(const zone_allocator<U>& other) throw() : zone_(other.zone_) {} | 35 zone_allocator(const zone_allocator<U>& other) throw() : zone_(other.zone_) {} |
| 34 template <typename U> | 36 template <typename U> |
| 35 friend class zone_allocator; | 37 friend class zone_allocator; |
| 36 | 38 |
| 37 pointer address(reference x) const { return &x; } | 39 pointer address(reference x) const { return &x; } |
| 38 const_pointer address(const_reference x) const { return &x; } | 40 const_pointer address(const_reference x) const { return &x; } |
| (...skipping 16 matching lines...) Expand all Loading... |
| 55 bool operator==(zone_allocator const& other) const { | 57 bool operator==(zone_allocator const& other) const { |
| 56 return zone_ == other.zone_; | 58 return zone_ == other.zone_; |
| 57 } | 59 } |
| 58 bool operator!=(zone_allocator const& other) const { | 60 bool operator!=(zone_allocator const& other) const { |
| 59 return zone_ != other.zone_; | 61 return zone_ != other.zone_; |
| 60 } | 62 } |
| 61 | 63 |
| 62 Zone* zone() { return zone_; } | 64 Zone* zone() { return zone_; } |
| 63 | 65 |
| 64 private: | 66 private: |
| 65 zone_allocator(); | |
| 66 Zone* zone_; | 67 Zone* zone_; |
| 67 }; | 68 }; |
| 68 | 69 |
| 69 typedef zone_allocator<bool> ZoneBoolAllocator; | 70 typedef zone_allocator<bool> ZoneBoolAllocator; |
| 70 typedef zone_allocator<int> ZoneIntAllocator; | 71 typedef zone_allocator<int> ZoneIntAllocator; |
| 71 } // namespace internal | 72 } // namespace internal |
| 72 } // namespace v8 | 73 } // namespace v8 |
| 73 | 74 |
| 74 #endif // V8_ZONE_ZONE_ALLOCATOR_H_ | 75 #endif // V8_ZONE_ZONE_ALLOCATOR_H_ |
| OLD | NEW |