OLD | NEW |
1 // Copyright 2011 the V8 project authors. All rights reserved. | 1 // Copyright 2011 the V8 project authors. All rights reserved. |
2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
4 // met: | 4 // met: |
5 // | 5 // |
6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
(...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
189 // Inlined implementation of ResizeAdd, shared by inlined and | 189 // Inlined implementation of ResizeAdd, shared by inlined and |
190 // non-inlined versions of ResizeAdd. | 190 // non-inlined versions of ResizeAdd. |
191 void ResizeAddInternal(const T& element, AllocationPolicy allocator); | 191 void ResizeAddInternal(const T& element, AllocationPolicy allocator); |
192 | 192 |
193 // Resize the list. | 193 // Resize the list. |
194 void Resize(int new_capacity, AllocationPolicy allocator); | 194 void Resize(int new_capacity, AllocationPolicy allocator); |
195 | 195 |
196 DISALLOW_COPY_AND_ASSIGN(List); | 196 DISALLOW_COPY_AND_ASSIGN(List); |
197 }; | 197 }; |
198 | 198 |
| 199 |
| 200 template<typename T, class P> |
| 201 size_t GetMemoryUsedByList(const List<T, P>& list) { |
| 202 return list.length() * sizeof(T) + sizeof(list); |
| 203 } |
| 204 |
| 205 |
199 class Map; | 206 class Map; |
200 class Type; | 207 class Type; |
201 class Code; | 208 class Code; |
202 template<typename T> class Handle; | 209 template<typename T> class Handle; |
203 typedef List<Map*> MapList; | 210 typedef List<Map*> MapList; |
204 typedef List<Code*> CodeList; | 211 typedef List<Code*> CodeList; |
205 typedef List<Handle<Map> > MapHandleList; | 212 typedef List<Handle<Map> > MapHandleList; |
206 typedef List<Handle<Type> > TypeHandleList; | 213 typedef List<Handle<Type> > TypeHandleList; |
207 typedef List<Handle<Code> > CodeHandleList; | 214 typedef List<Handle<Code> > CodeHandleList; |
208 | 215 |
209 // Perform binary search for an element in an already sorted | 216 // Perform binary search for an element in an already sorted |
210 // list. Returns the index of the element of -1 if it was not found. | 217 // list. Returns the index of the element of -1 if it was not found. |
211 // |cmp| is a predicate that takes a pointer to an element of the List | 218 // |cmp| is a predicate that takes a pointer to an element of the List |
212 // and returns +1 if it is greater, -1 if it is less than the element | 219 // and returns +1 if it is greater, -1 if it is less than the element |
213 // being searched. | 220 // being searched. |
214 template <typename T, class P> | 221 template <typename T, class P> |
215 int SortedListBSearch(const List<T>& list, P cmp); | 222 int SortedListBSearch(const List<T>& list, P cmp); |
216 template <typename T> | 223 template <typename T> |
217 int SortedListBSearch(const List<T>& list, T elem); | 224 int SortedListBSearch(const List<T>& list, T elem); |
218 | 225 |
219 | 226 |
220 } } // namespace v8::internal | 227 } } // namespace v8::internal |
221 | 228 |
222 | 229 |
223 #endif // V8_LIST_H_ | 230 #endif // V8_LIST_H_ |
OLD | NEW |