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 #include <stdlib.h> | 5 #include <stdlib.h> |
6 | 6 |
7 #include "src/globals.h" | 7 #include "src/globals.h" |
8 #include "src/zone/zone.h" | 8 #include "src/zone/zone.h" |
9 | 9 |
10 #ifndef V8_SRC_ZONE_ZONE_CHUNK_LIST_H_ | 10 #ifndef V8_SRC_ZONE_ZONE_CHUNK_LIST_H_ |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
75 // free the actual memory, since it is zone allocated. | 75 // free the actual memory, since it is zone allocated. |
76 void Rewind(const size_t limit = 0); | 76 void Rewind(const size_t limit = 0); |
77 | 77 |
78 // Quickly scans the list to retrieve the element at the given index. Will | 78 // Quickly scans the list to retrieve the element at the given index. Will |
79 // *not* check bounds. | 79 // *not* check bounds. |
80 ForwardZoneChunkListIterator<T> Find(const size_t index); | 80 ForwardZoneChunkListIterator<T> Find(const size_t index); |
81 ForwardZoneChunkListIterator<const T> Find(const size_t index) const; | 81 ForwardZoneChunkListIterator<const T> Find(const size_t index) const; |
82 // TODO(heimbuef): Add 'rFind', seeking from the end and returning a | 82 // TODO(heimbuef): Add 'rFind', seeking from the end and returning a |
83 // reverse iterator. | 83 // reverse iterator. |
84 | 84 |
| 85 void CopyTo(T* ptr); |
| 86 |
85 ForwardZoneChunkListIterator<T> begin(); | 87 ForwardZoneChunkListIterator<T> begin(); |
86 ForwardZoneChunkListIterator<T> end(); | 88 ForwardZoneChunkListIterator<T> end(); |
87 ReverseZoneChunkListIterator<T> rbegin(); | 89 ReverseZoneChunkListIterator<T> rbegin(); |
88 ReverseZoneChunkListIterator<T> rend(); | 90 ReverseZoneChunkListIterator<T> rend(); |
89 ForwardZoneChunkListIterator<const T> begin() const; | 91 ForwardZoneChunkListIterator<const T> begin() const; |
90 ForwardZoneChunkListIterator<const T> end() const; | 92 ForwardZoneChunkListIterator<const T> end() const; |
91 ReverseZoneChunkListIterator<const T> rbegin() const; | 93 ReverseZoneChunkListIterator<const T> rbegin() const; |
92 ReverseZoneChunkListIterator<const T> rend() const; | 94 ReverseZoneChunkListIterator<const T> rend() const; |
93 | 95 |
94 private: | 96 private: |
(...skipping 290 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
385 | 387 |
386 template <typename T> | 388 template <typename T> |
387 ForwardZoneChunkListIterator<const T> ZoneChunkList<T>::Find( | 389 ForwardZoneChunkListIterator<const T> ZoneChunkList<T>::Find( |
388 const size_t index) const { | 390 const size_t index) const { |
389 SeekResult seek_result = SeekIndex(index); | 391 SeekResult seek_result = SeekIndex(index); |
390 return ForwardZoneChunkListIterator<const T>(seek_result.chunk_, | 392 return ForwardZoneChunkListIterator<const T>(seek_result.chunk_, |
391 seek_result.chunk_index_); | 393 seek_result.chunk_index_); |
392 } | 394 } |
393 | 395 |
394 template <typename T> | 396 template <typename T> |
| 397 void ZoneChunkList<T>::CopyTo(T* ptr) { |
| 398 for (Chunk* current = front_; current != nullptr; current = current->next_) { |
| 399 void* start = current->items(); |
| 400 void* end = current->items() + current->position_; |
| 401 size_t bytes = static_cast<size_t>(reinterpret_cast<uintptr_t>(end) - |
| 402 reinterpret_cast<uintptr_t>(start)); |
| 403 |
| 404 MemCopy(ptr, current->items(), bytes); |
| 405 ptr += current->position_; |
| 406 } |
| 407 } |
| 408 |
| 409 template <typename T> |
395 ForwardZoneChunkListIterator<T> ZoneChunkList<T>::begin() { | 410 ForwardZoneChunkListIterator<T> ZoneChunkList<T>::begin() { |
396 return ForwardZoneChunkListIterator<T>::Begin(this); | 411 return ForwardZoneChunkListIterator<T>::Begin(this); |
397 } | 412 } |
398 | 413 |
399 template <typename T> | 414 template <typename T> |
400 ForwardZoneChunkListIterator<T> ZoneChunkList<T>::end() { | 415 ForwardZoneChunkListIterator<T> ZoneChunkList<T>::end() { |
401 return ForwardZoneChunkListIterator<T>::End(this); | 416 return ForwardZoneChunkListIterator<T>::End(this); |
402 } | 417 } |
403 | 418 |
404 template <typename T> | 419 template <typename T> |
(...skipping 23 matching lines...) Expand all Loading... |
428 | 443 |
429 template <typename T> | 444 template <typename T> |
430 ReverseZoneChunkListIterator<const T> ZoneChunkList<T>::rend() const { | 445 ReverseZoneChunkListIterator<const T> ZoneChunkList<T>::rend() const { |
431 return ReverseZoneChunkListIterator<const T>::End(this); | 446 return ReverseZoneChunkListIterator<const T>::End(this); |
432 } | 447 } |
433 | 448 |
434 } // namespace internal | 449 } // namespace internal |
435 } // namespace v8 | 450 } // namespace v8 |
436 | 451 |
437 #endif // V8_SRC_ZONE_ZONE_CHUNK_LIST_H_ | 452 #endif // V8_SRC_ZONE_ZONE_CHUNK_LIST_H_ |
OLD | NEW |