Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1)

Side by Side Diff: src/zone/zone-containers.h

Issue 2452403003: Changed statement ZoneList to a ZoneChunkList
Patch Set: Created 4 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « src/zone/zone-allocator.h ('k') | test/cctest/test-liveedit.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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_SRC_ZONE_ZONE_CONTAINERS_H_ 5 #ifndef V8_SRC_ZONE_ZONE_CONTAINERS_H_
6 #define V8_SRC_ZONE_ZONE_CONTAINERS_H_ 6 #define V8_SRC_ZONE_ZONE_CONTAINERS_H_
7 7
8 #include <deque> 8 #include <deque>
9 #include <list> 9 #include <list>
10 #include <map> 10 #include <map>
11 #include <queue> 11 #include <queue>
12 #include <set> 12 #include <set>
13 #include <stack> 13 #include <stack>
14 #include <vector> 14 #include <vector>
15 15
16 #include "src/zone/zone-allocator.h" 16 #include "src/zone/zone-allocator.h"
17 17
18 namespace v8 { 18 namespace v8 {
19 namespace internal { 19 namespace internal {
20 20
21 // A wrapper subclass for std::vector to make it easy to construct one 21 // A wrapper subclass for std::vector to make it easy to construct one
22 // that uses a zone allocator. 22 // that uses a zone allocator.
23 template <typename T> 23 template <typename T>
24 class ZoneVector : public std::vector<T, zone_allocator<T>> { 24 class ZoneVector : public std::vector<T, zone_allocator<T>>, public ZoneObject {
25 public: 25 public:
26 // Constructs an empty vector. 26 // Constructs an empty vector.
27 explicit ZoneVector(Zone* zone) 27 explicit ZoneVector(Zone* zone)
28 : std::vector<T, zone_allocator<T>>(zone_allocator<T>(zone)) {} 28 : std::vector<T, zone_allocator<T>>(zone_allocator<T>(zone)) {}
29 29
30 // Constructs a new vector and fills it with {size} elements, each 30 // Constructs a new vector and fills it with {size} elements, each
31 // constructed via the default constructor. 31 // constructed via the default constructor.
32 ZoneVector(size_t size, Zone* zone) 32 ZoneVector(size_t size, Zone* zone)
33 : std::vector<T, zone_allocator<T>>(size, T(), zone_allocator<T>(zone)) {} 33 : std::vector<T, zone_allocator<T>>(size, T(), zone_allocator<T>(zone)) {}
34 34
35 // Constructs a new vector and fills it with {size} elements, each 35 // Constructs a new vector and fills it with {size} elements, each
36 // having the value {def}. 36 // having the value {def}.
37 ZoneVector(size_t size, T def, Zone* zone) 37 ZoneVector(size_t size, T def, Zone* zone)
38 : std::vector<T, zone_allocator<T>>(size, def, zone_allocator<T>(zone)) {} 38 : std::vector<T, zone_allocator<T>>(size, def, zone_allocator<T>(zone)) {}
39 }; 39 };
40 40
41 // A wrapper subclass std::deque to make it easy to construct one 41 // A wrapper subclass std::deque to make it easy to construct one
42 // that uses a zone allocator. 42 // that uses a zone allocator.
43 template <typename T> 43 template <typename T>
44 class ZoneDeque : public std::deque<T, zone_allocator<T>> { 44 class ZoneDeque : public std::deque<T, zone_allocator<T>>, public ZoneObject {
45 public: 45 public:
46 // Constructs an empty deque. 46 // Constructs an empty deque.
47 explicit ZoneDeque(Zone* zone) 47 explicit ZoneDeque(Zone* zone)
48 : std::deque<T, zone_allocator<T>>(zone_allocator<T>(zone)) {} 48 : std::deque<T, zone_allocator<T>>(zone_allocator<T>(zone)) {}
49 }; 49 };
50 50
51 // A wrapper subclass std::list to make it easy to construct one 51 // A wrapper subclass std::list to make it easy to construct one
52 // that uses a zone allocator. 52 // that uses a zone allocator.
53 // TODO(mstarzinger): This should be renamed to ZoneList once we got rid of our 53 // TODO(mstarzinger): This should be renamed to ZoneList once we got rid of our
54 // own home-grown ZoneList that actually is a ZoneVector. 54 // own home-grown ZoneList that actually is a ZoneVector.
55 template <typename T> 55 template <typename T>
56 class ZoneLinkedList : public std::list<T, zone_allocator<T>> { 56 class ZoneLinkedList : public std::list<T, zone_allocator<T>>,
57 public ZoneObject {
57 public: 58 public:
58 // Constructs an empty list. 59 // Constructs an empty list.
59 explicit ZoneLinkedList(Zone* zone) 60 explicit ZoneLinkedList(Zone* zone)
60 : std::list<T, zone_allocator<T>>(zone_allocator<T>(zone)) {} 61 : std::list<T, zone_allocator<T>>(zone_allocator<T>(zone)) {}
61 }; 62 };
62 63
63 // A wrapper subclass std::priority_queue to make it easy to construct one 64 // A wrapper subclass std::priority_queue to make it easy to construct one
64 // that uses a zone allocator. 65 // that uses a zone allocator.
65 template <typename T, typename Compare = std::less<T>> 66 template <typename T, typename Compare = std::less<T>>
66 class ZonePriorityQueue 67 class ZonePriorityQueue : public std::priority_queue<T, ZoneVector<T>, Compare>,
67 : public std::priority_queue<T, ZoneVector<T>, Compare> { 68 public ZoneObject {
68 public: 69 public:
69 // Constructs an empty list. 70 // Constructs an empty list.
70 explicit ZonePriorityQueue(Zone* zone) 71 explicit ZonePriorityQueue(Zone* zone)
71 : std::priority_queue<T, ZoneVector<T>, Compare>(Compare(), 72 : std::priority_queue<T, ZoneVector<T>, Compare>(Compare(),
72 ZoneVector<T>(zone)) {} 73 ZoneVector<T>(zone)) {}
73 }; 74 };
74 75
75 // A wrapper subclass for std::queue to make it easy to construct one 76 // A wrapper subclass for std::queue to make it easy to construct one
76 // that uses a zone allocator. 77 // that uses a zone allocator.
77 template <typename T> 78 template <typename T>
78 class ZoneQueue : public std::queue<T, ZoneDeque<T>> { 79 class ZoneQueue : public std::queue<T, ZoneDeque<T>>, public ZoneObject {
79 public: 80 public:
80 // Constructs an empty queue. 81 // Constructs an empty queue.
81 explicit ZoneQueue(Zone* zone) 82 explicit ZoneQueue(Zone* zone)
82 : std::queue<T, ZoneDeque<T>>(ZoneDeque<T>(zone)) {} 83 : std::queue<T, ZoneDeque<T>>(ZoneDeque<T>(zone)) {}
83 }; 84 };
84 85
85 // A wrapper subclass for std::stack to make it easy to construct one that uses 86 // A wrapper subclass for std::stack to make it easy to construct one that uses
86 // a zone allocator. 87 // a zone allocator.
87 template <typename T> 88 template <typename T>
88 class ZoneStack : public std::stack<T, ZoneDeque<T>> { 89 class ZoneStack : public std::stack<T, ZoneDeque<T>>, public ZoneObject {
89 public: 90 public:
90 // Constructs an empty stack. 91 // Constructs an empty stack.
91 explicit ZoneStack(Zone* zone) 92 explicit ZoneStack(Zone* zone)
92 : std::stack<T, ZoneDeque<T>>(ZoneDeque<T>(zone)) {} 93 : std::stack<T, ZoneDeque<T>>(ZoneDeque<T>(zone)) {}
93 }; 94 };
94 95
95 // A wrapper subclass for std::set to make it easy to construct one that uses 96 // A wrapper subclass for std::set to make it easy to construct one that uses
96 // a zone allocator. 97 // a zone allocator.
97 template <typename K, typename Compare = std::less<K>> 98 template <typename K, typename Compare = std::less<K>>
98 class ZoneSet : public std::set<K, Compare, zone_allocator<K>> { 99 class ZoneSet : public std::set<K, Compare, zone_allocator<K>>,
100 public ZoneObject {
99 public: 101 public:
100 // Constructs an empty set. 102 // Constructs an empty set.
101 explicit ZoneSet(Zone* zone) 103 explicit ZoneSet(Zone* zone)
102 : std::set<K, Compare, zone_allocator<K>>(Compare(), 104 : std::set<K, Compare, zone_allocator<K>>(Compare(),
103 zone_allocator<K>(zone)) {} 105 zone_allocator<K>(zone)) {}
104 }; 106 };
105 107
106 // A wrapper subclass for std::map to make it easy to construct one that uses 108 // A wrapper subclass for std::map to make it easy to construct one that uses
107 // a zone allocator. 109 // a zone allocator.
108 template <typename K, typename V, typename Compare = std::less<K>> 110 template <typename K, typename V, typename Compare = std::less<K>>
109 class ZoneMap 111 class ZoneMap
110 : public std::map<K, V, Compare, zone_allocator<std::pair<const K, V>>> { 112 : public std::map<K, V, Compare, zone_allocator<std::pair<const K, V>>>,
113 public ZoneObject {
111 public: 114 public:
112 // Constructs an empty map. 115 // Constructs an empty map.
113 explicit ZoneMap(Zone* zone) 116 explicit ZoneMap(Zone* zone)
114 : std::map<K, V, Compare, zone_allocator<std::pair<const K, V>>>( 117 : std::map<K, V, Compare, zone_allocator<std::pair<const K, V>>>(
115 Compare(), zone_allocator<std::pair<const K, V>>(zone)) {} 118 Compare(), zone_allocator<std::pair<const K, V>>(zone)) {}
116 }; 119 };
117 120
118 // A wrapper subclass for std::multimap to make it easy to construct one that 121 // A wrapper subclass for std::multimap to make it easy to construct one that
119 // uses a zone allocator. 122 // uses a zone allocator.
120 template <typename K, typename V, typename Compare = std::less<K>> 123 template <typename K, typename V, typename Compare = std::less<K>>
121 class ZoneMultimap 124 class ZoneMultimap
122 : public std::multimap<K, V, Compare, 125 : public std::multimap<K, V, Compare,
123 zone_allocator<std::pair<const K, V>>> { 126 zone_allocator<std::pair<const K, V>>>,
127 public ZoneObject {
124 public: 128 public:
125 // Constructs an empty multimap. 129 // Constructs an empty multimap.
126 explicit ZoneMultimap(Zone* zone) 130 explicit ZoneMultimap(Zone* zone)
127 : std::multimap<K, V, Compare, zone_allocator<std::pair<const K, V>>>( 131 : std::multimap<K, V, Compare, zone_allocator<std::pair<const K, V>>>(
128 Compare(), zone_allocator<std::pair<const K, V>>(zone)) {} 132 Compare(), zone_allocator<std::pair<const K, V>>(zone)) {}
129 }; 133 };
130 134
131 // Typedefs to shorten commonly used vectors. 135 // Typedefs to shorten commonly used vectors.
132 typedef ZoneVector<bool> BoolVector; 136 typedef ZoneVector<bool> BoolVector;
133 typedef ZoneVector<int> IntVector; 137 typedef ZoneVector<int> IntVector;
134 138
135 } // namespace internal 139 } // namespace internal
136 } // namespace v8 140 } // namespace v8
137 141
138 #endif // V8_SRC_ZONE_ZONE_CONTAINERS_H_ 142 #endif // V8_SRC_ZONE_ZONE_CONTAINERS_H_
OLDNEW
« no previous file with comments | « src/zone/zone-allocator.h ('k') | test/cctest/test-liveedit.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698