diff options
author | Myles Borins <mylesborins@google.com> | 2018-04-10 21:39:51 -0400 |
---|---|---|
committer | Myles Borins <mylesborins@google.com> | 2018-04-11 13:22:42 -0400 |
commit | 12a1b9b8049462e47181a298120243dc83e81c55 (patch) | |
tree | 8605276308c8b4e3597516961266bae1af57557a /deps/v8/src/zone | |
parent | 78cd8263354705b767ef8c6a651740efe4931ba0 (diff) | |
download | android-node-v8-12a1b9b8049462e47181a298120243dc83e81c55.tar.gz android-node-v8-12a1b9b8049462e47181a298120243dc83e81c55.tar.bz2 android-node-v8-12a1b9b8049462e47181a298120243dc83e81c55.zip |
deps: update V8 to 6.6.346.23
PR-URL: https://github.com/nodejs/node/pull/19201
Reviewed-By: Ali Ijaz Sheikh <ofrobots@google.com>
Reviewed-By: Myles Borins <myles.borins@gmail.com>
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Diffstat (limited to 'deps/v8/src/zone')
-rw-r--r-- | deps/v8/src/zone/accounting-allocator.h | 1 | ||||
-rw-r--r-- | deps/v8/src/zone/zone-chunk-list.h | 281 | ||||
-rw-r--r-- | deps/v8/src/zone/zone-containers.h | 6 | ||||
-rw-r--r-- | deps/v8/src/zone/zone-handle-set.h | 4 |
4 files changed, 109 insertions, 183 deletions
diff --git a/deps/v8/src/zone/accounting-allocator.h b/deps/v8/src/zone/accounting-allocator.h index 53d30b3826..bf36a7ff95 100644 --- a/deps/v8/src/zone/accounting-allocator.h +++ b/deps/v8/src/zone/accounting-allocator.h @@ -6,6 +6,7 @@ #define V8_ZONE_ACCOUNTING_ALLOCATOR_H_ #include "include/v8-platform.h" +#include "include/v8.h" #include "src/base/atomic-utils.h" #include "src/base/atomicops.h" #include "src/base/macros.h" diff --git a/deps/v8/src/zone/zone-chunk-list.h b/deps/v8/src/zone/zone-chunk-list.h index a0aaca8b09..229a3f3f40 100644 --- a/deps/v8/src/zone/zone-chunk-list.h +++ b/deps/v8/src/zone/zone-chunk-list.h @@ -8,18 +8,14 @@ #include "src/utils.h" #include "src/zone/zone.h" -#ifndef V8_SRC_ZONE_ZONE_CHUNK_LIST_H_ -#define V8_SRC_ZONE_ZONE_CHUNK_LIST_H_ +#ifndef V8_ZONE_ZONE_CHUNK_LIST_H_ +#define V8_ZONE_ZONE_CHUNK_LIST_H_ namespace v8 { namespace internal { -template <typename T> +template <typename T, bool backwards, bool modifiable> class ZoneChunkListIterator; -template <typename T> -class ForwardZoneChunkListIterator; -template <typename T> -class ReverseZoneChunkListIterator; // A zone-backed hybrid of a vector and a linked list. Use it if you need a // collection that @@ -38,6 +34,11 @@ class ReverseZoneChunkListIterator; template <typename T> class ZoneChunkList : public ZoneObject { public: + using iterator = ZoneChunkListIterator<T, false, true>; + using const_iterator = ZoneChunkListIterator<T, false, false>; + using reverse_iterator = ZoneChunkListIterator<T, true, true>; + using const_reverse_iterator = ZoneChunkListIterator<T, true, false>; + enum class StartMode { // The list will not allocate a starting chunk. Use if you expect your // list to remain empty in many cases. @@ -58,7 +59,7 @@ class ZoneChunkList : public ZoneObject { } } - size_t size() const; + size_t size() const { return size_; } T& front() const; T& back() const; @@ -78,27 +79,31 @@ class ZoneChunkList : public ZoneObject { // Quickly scans the list to retrieve the element at the given index. Will // *not* check bounds. - ForwardZoneChunkListIterator<T> Find(const size_t index); - ForwardZoneChunkListIterator<const T> Find(const size_t index) const; + iterator Find(const size_t index); + const_iterator Find(const size_t index) const; // TODO(heimbuef): Add 'rFind', seeking from the end and returning a // reverse iterator. void CopyTo(T* ptr); - ForwardZoneChunkListIterator<T> begin(); - ForwardZoneChunkListIterator<T> end(); - ReverseZoneChunkListIterator<T> rbegin(); - ReverseZoneChunkListIterator<T> rend(); - ForwardZoneChunkListIterator<const T> begin() const; - ForwardZoneChunkListIterator<const T> end() const; - ReverseZoneChunkListIterator<const T> rbegin() const; - ReverseZoneChunkListIterator<const T> rend() const; + iterator begin() { return iterator::Begin(this); } + iterator end() { return iterator::End(this); } + reverse_iterator rbegin() { return reverse_iterator::Begin(this); } + reverse_iterator rend() { return reverse_iterator::End(this); } + const_iterator begin() const { return const_iterator::Begin(this); } + const_iterator end() const { return const_iterator::End(this); } + const_reverse_iterator rbegin() const { + return const_reverse_iterator::Begin(this); + } + const_reverse_iterator rend() const { + return const_reverse_iterator::End(this); + } private: - friend class ZoneChunkListIterator<T>; - friend class ForwardZoneChunkListIterator<T>; - friend class ReverseZoneChunkListIterator<T>; - static const uint32_t kMaxChunkCapacity = 256u; + template <typename S, bool backwards, bool modifiable> + friend class ZoneChunkListIterator; + + static constexpr uint32_t kMaxChunkCapacity = 256u; STATIC_ASSERT(kMaxChunkCapacity == static_cast<uint32_t>(StartMode::kBig)); @@ -108,6 +113,7 @@ class ZoneChunkList : public ZoneObject { Chunk* next_ = nullptr; Chunk* previous_ = nullptr; T* items() { return reinterpret_cast<T*>(this + 1); } + const T* items() const { return reinterpret_cast<const T*>(this + 1); } }; Chunk* NewChunk(const uint32_t capacity) { @@ -135,152 +141,108 @@ class ZoneChunkList : public ZoneObject { DISALLOW_COPY_AND_ASSIGN(ZoneChunkList); }; -template <typename T> +template <typename T, bool backwards, bool modifiable> class ZoneChunkListIterator { + private: + template <typename S> + using maybe_const = + typename std::conditional<modifiable, S, + typename std::add_const<S>::type>::type; + using Chunk = maybe_const<typename ZoneChunkList<T>::Chunk>; + using ChunkList = maybe_const<ZoneChunkList<T>>; + public: - T& operator*() { return current_->items()[position_]; } - bool operator==(const ZoneChunkListIterator& other) { + maybe_const<T>& operator*() { return current_->items()[position_]; } + bool operator==(const ZoneChunkListIterator& other) const { return other.current_ == current_ && other.position_ == position_; } - bool operator!=(const ZoneChunkListIterator& other) { + bool operator!=(const ZoneChunkListIterator& other) const { return !operator==(other); } - protected: - ZoneChunkListIterator(typename ZoneChunkList<T>::Chunk* current, - size_t position) - : current_(current), position_(position) {} - - void MoveNext() { - ++position_; - if (position_ >= current_->capacity_) { - current_ = current_->next_; - position_ = 0; - } - } - - void MoveRNext() { - if (position_ == 0) { - current_ = current_->previous_; - position_ = current_ ? current_->capacity_ - 1 : 0; - } else { - --position_; - } - } - - typename ZoneChunkList<T>::Chunk* current_; - size_t position_; -}; - -template <typename T> -class ForwardZoneChunkListIterator : public ZoneChunkListIterator<T> { - using ZoneChunkListIterator<T>::current_; - using ZoneChunkListIterator<T>::position_; - using ZoneChunkListIterator<T>::MoveNext; - using ZoneChunkListIterator<T>::MoveRNext; - - public: - ForwardZoneChunkListIterator(typename ZoneChunkList<T>::Chunk* current, - size_t position) - : ZoneChunkListIterator<T>(current, position) {} - - ForwardZoneChunkListIterator& operator++() { - MoveNext(); + ZoneChunkListIterator& operator++() { + Move<backwards>(); return *this; } - ForwardZoneChunkListIterator operator++(int) { - ForwardZoneChunkListIterator<T> clone(*this); - MoveNext(); + ZoneChunkListIterator operator++(int) { + ZoneChunkListIterator clone(*this); + Move<backwards>(); return clone; } - ForwardZoneChunkListIterator& operator--() { - MoveRNext(); + ZoneChunkListIterator& operator--() { + Move<!backwards>(); return *this; } - ForwardZoneChunkListIterator operator--(int) { - ForwardZoneChunkListIterator<T> clone(*this); - MoveRNext(); + ZoneChunkListIterator operator--(int) { + ZoneChunkListIterator clone(*this); + Move<!backwards>(); return clone; } private: friend class ZoneChunkList<T>; - static ForwardZoneChunkListIterator<T> Begin(ZoneChunkList<T>* list) { - return ForwardZoneChunkListIterator<T>(list->front_, 0); - } - static ForwardZoneChunkListIterator<T> End(ZoneChunkList<T>* list) { - if (list->back_ == nullptr) return Begin(list); - DCHECK_LE(list->back_->position_, list->back_->capacity_); - if (list->back_->position_ == list->back_->capacity_) { - return ForwardZoneChunkListIterator<T>(nullptr, 0); - } + static ZoneChunkListIterator Begin(ChunkList* list) { + // Forward iterator: + if (!backwards) return ZoneChunkListIterator(list->front_, 0); - return ForwardZoneChunkListIterator<T>(list->back_, list->back_->position_); + // Backward iterator: + if (list->back_ == nullptr) return End(list); + if (list->back_->position_ == 0) { + if (list->back_->previous_ != nullptr) { + return ZoneChunkListIterator(list->back_->previous_, + list->back_->previous_->capacity_ - 1); + } else { + return End(list); + } + } + return ZoneChunkListIterator(list->back_, list->back_->position_ - 1); } -}; -template <typename T> -class ReverseZoneChunkListIterator : public ZoneChunkListIterator<T> { - using ZoneChunkListIterator<T>::current_; - using ZoneChunkListIterator<T>::position_; - using ZoneChunkListIterator<T>::MoveNext; - using ZoneChunkListIterator<T>::MoveRNext; + static ZoneChunkListIterator End(ChunkList* list) { + // Backward iterator: + if (backwards) return ZoneChunkListIterator(nullptr, 0); - public: - ReverseZoneChunkListIterator(typename ZoneChunkList<T>::Chunk* current, - size_t position) - : ZoneChunkListIterator<T>(current, position) {} - - ReverseZoneChunkListIterator& operator++() { - MoveRNext(); - return *this; - } + // Forward iterator: + if (list->back_ == nullptr) return Begin(list); - ReverseZoneChunkListIterator operator++(int) { - ReverseZoneChunkListIterator<T> clone(*this); - MoveRNext(); - return clone; - } + DCHECK_LE(list->back_->position_, list->back_->capacity_); + if (list->back_->position_ == list->back_->capacity_) { + return ZoneChunkListIterator(list->back_->next_, 0); + } - ReverseZoneChunkListIterator& operator--() { - MoveNext(); - return *this; + return ZoneChunkListIterator(list->back_, list->back_->position_); } - ReverseZoneChunkListIterator operator--(int) { - ForwardZoneChunkListIterator<T> clone(*this); - MoveNext(); - return clone; - } + ZoneChunkListIterator(Chunk* current, size_t position) + : current_(current), position_(position) {} - private: - friend class ZoneChunkList<T>; - static ReverseZoneChunkListIterator<T> Begin(ZoneChunkList<T>* list) { - if (list->back_ == nullptr) return End(list); - if (list->back_->position_ == 0) { - if (list->back_->previous_ != nullptr) { - return ReverseZoneChunkListIterator<T>( - list->back_->previous_, list->back_->previous_->capacity_ - 1); + template <bool move_backward> + void Move() { + if (move_backward) { + // Move backwards. + if (position_ == 0) { + current_ = current_->previous_; + position_ = current_ ? current_->capacity_ - 1 : 0; } else { - return End(list); + --position_; + } + } else { + // Move forwards. + ++position_; + if (position_ >= current_->capacity_) { + current_ = current_->next_; + position_ = 0; } } - return ReverseZoneChunkListIterator<T>(list->back_, - list->back_->position_ - 1); - } - static ReverseZoneChunkListIterator<T> End(ZoneChunkList<T>* list) { - return ReverseZoneChunkListIterator<T>(nullptr, 0); } -}; -template <typename T> -size_t ZoneChunkList<T>::size() const { - return size_; -} + Chunk* current_; + size_t position_; +}; template <typename T> T& ZoneChunkList<T>::front() const { @@ -327,6 +289,7 @@ void ZoneChunkList<T>::pop_back() { back_ = back_->previous_; } --back_->position_; + --size_; } template <typename T> @@ -380,18 +343,18 @@ void ZoneChunkList<T>::Rewind(const size_t limit) { } template <typename T> -ForwardZoneChunkListIterator<T> ZoneChunkList<T>::Find(const size_t index) { +typename ZoneChunkList<T>::iterator ZoneChunkList<T>::Find(const size_t index) { SeekResult seek_result = SeekIndex(index); - return ForwardZoneChunkListIterator<T>(seek_result.chunk_, - seek_result.chunk_index_); + return typename ZoneChunkList<T>::iterator(seek_result.chunk_, + seek_result.chunk_index_); } template <typename T> -ForwardZoneChunkListIterator<const T> ZoneChunkList<T>::Find( +typename ZoneChunkList<T>::const_iterator ZoneChunkList<T>::Find( const size_t index) const { SeekResult seek_result = SeekIndex(index); - return ForwardZoneChunkListIterator<const T>(seek_result.chunk_, - seek_result.chunk_index_); + return typename ZoneChunkList<T>::const_iterator(seek_result.chunk_, + seek_result.chunk_index_); } template <typename T> @@ -407,47 +370,7 @@ void ZoneChunkList<T>::CopyTo(T* ptr) { } } -template <typename T> -ForwardZoneChunkListIterator<T> ZoneChunkList<T>::begin() { - return ForwardZoneChunkListIterator<T>::Begin(this); -} - -template <typename T> -ForwardZoneChunkListIterator<T> ZoneChunkList<T>::end() { - return ForwardZoneChunkListIterator<T>::End(this); -} - -template <typename T> -ReverseZoneChunkListIterator<T> ZoneChunkList<T>::rbegin() { - return ReverseZoneChunkListIterator<T>::Begin(this); -} - -template <typename T> -ReverseZoneChunkListIterator<T> ZoneChunkList<T>::rend() { - return ReverseZoneChunkListIterator<T>::End(this); -} - -template <typename T> -ForwardZoneChunkListIterator<const T> ZoneChunkList<T>::begin() const { - return ForwardZoneChunkListIterator<const T>::Begin(this); -} - -template <typename T> -ForwardZoneChunkListIterator<const T> ZoneChunkList<T>::end() const { - return ForwardZoneChunkListIterator<const T>::End(this); -} - -template <typename T> -ReverseZoneChunkListIterator<const T> ZoneChunkList<T>::rbegin() const { - return ReverseZoneChunkListIterator<const T>::Begin(this); -} - -template <typename T> -ReverseZoneChunkListIterator<const T> ZoneChunkList<T>::rend() const { - return ReverseZoneChunkListIterator<const T>::End(this); -} - } // namespace internal } // namespace v8 -#endif // V8_SRC_ZONE_ZONE_CHUNK_LIST_H_ +#endif // V8_ZONE_ZONE_CHUNK_LIST_H_ diff --git a/deps/v8/src/zone/zone-containers.h b/deps/v8/src/zone/zone-containers.h index 5e9fd0440a..c899bf340d 100644 --- a/deps/v8/src/zone/zone-containers.h +++ b/deps/v8/src/zone/zone-containers.h @@ -2,8 +2,8 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#ifndef V8_SRC_ZONE_ZONE_CONTAINERS_H_ -#define V8_SRC_ZONE_ZONE_CONTAINERS_H_ +#ifndef V8_ZONE_ZONE_CONTAINERS_H_ +#define V8_ZONE_ZONE_CONTAINERS_H_ #include <deque> #include <forward_list> @@ -190,4 +190,4 @@ typedef ZoneVector<int> IntVector; } // namespace internal } // namespace v8 -#endif // V8_SRC_ZONE_ZONE_CONTAINERS_H_ +#endif // V8_ZONE_ZONE_CONTAINERS_H_ diff --git a/deps/v8/src/zone/zone-handle-set.h b/deps/v8/src/zone/zone-handle-set.h index 9abc89a30e..c5297902d8 100644 --- a/deps/v8/src/zone/zone-handle-set.h +++ b/deps/v8/src/zone/zone-handle-set.h @@ -195,11 +195,13 @@ class ZoneHandleSet<T>::const_iterator { typedef std::forward_iterator_tag iterator_category; typedef std::ptrdiff_t difference_type; typedef Handle<T> value_type; + typedef value_type reference; + typedef value_type* pointer; const_iterator(const const_iterator& other) : set_(other.set_), current_(other.current_) {} - Handle<T> operator*() const { return (*set_)[current_]; } + reference operator*() const { return (*set_)[current_]; } bool operator==(const const_iterator& other) const { return set_ == other.set_ && current_ == other.current_; } |