From 4c4af643e5042d615a60c6bbc05aee9d81b903e5 Mon Sep 17 00:00:00 2001 From: Michaƫl Zasso Date: Wed, 24 Jan 2018 20:16:06 +0100 Subject: deps: update V8 to 6.4.388.40 PR-URL: https://github.com/nodejs/node/pull/17489 Reviewed-By: Colin Ihrig Reviewed-By: Matteo Collina Reviewed-By: Myles Borins Reviewed-By: Ali Ijaz Sheikh --- deps/v8/src/zone/zone-handle-set.h | 59 ++++++++++++++++++++++++-------------- deps/v8/src/zone/zone-list-inl.h | 2 +- deps/v8/src/zone/zone.cc | 2 +- deps/v8/src/zone/zone.h | 17 +++++++++-- 4 files changed, 55 insertions(+), 25 deletions(-) (limited to 'deps/v8/src/zone') diff --git a/deps/v8/src/zone/zone-handle-set.h b/deps/v8/src/zone/zone-handle-set.h index e2cc1c6dc3..9abc89a30e 100644 --- a/deps/v8/src/zone/zone-handle-set.h +++ b/deps/v8/src/zone/zone-handle-set.h @@ -6,6 +6,7 @@ #define V8_ZONE_ZONE_HANDLE_SET_H_ #include "src/handles.h" +#include "src/zone/zone-containers.h" #include "src/zone/zone.h" namespace v8 { @@ -25,7 +26,7 @@ class ZoneHandleSet final { size_t size() const { if ((data_ & kTagMask) == kEmptyTag) return 0; if ((data_ & kTagMask) == kSingletonTag) return 1; - return list()->length(); + return list()->size(); } Handle at(size_t i) const { @@ -46,34 +47,35 @@ class ZoneHandleSet final { data_ = bit_cast(value) | kSingletonTag; } else if ((data_ & kTagMask) == kSingletonTag) { if (singleton() == value) return; - List* list = new (zone) List(2, zone); + List* list = new (zone->New(sizeof(List))) List(zone); if (singleton() < value) { - list->Add(singleton(), zone); - list->Add(value, zone); + list->push_back(singleton()); + list->push_back(value); } else { - list->Add(value, zone); - list->Add(singleton(), zone); + list->push_back(value); + list->push_back(singleton()); } DCHECK(IsAligned(bit_cast(list), kPointerAlignment)); data_ = bit_cast(list) | kListTag; } else { DCHECK_EQ(kListTag, data_ & kTagMask); List const* const old_list = list(); - for (int i = 0; i < old_list->length(); ++i) { + for (size_t i = 0; i < old_list->size(); ++i) { if (old_list->at(i) == value) return; if (old_list->at(i) > value) break; } - List* new_list = new (zone) List(old_list->length() + 1, zone); - int i = 0; - for (; i < old_list->length(); ++i) { + List* new_list = new (zone->New(sizeof(List))) List(zone); + new_list->reserve(old_list->size() + 1); + size_t i = 0; + for (; i < old_list->size(); ++i) { if (old_list->at(i) > value) break; - new_list->Add(old_list->at(i), zone); + new_list->push_back(old_list->at(i)); } - new_list->Add(value, zone); - for (; i < old_list->length(); ++i) { - new_list->Add(old_list->at(i), zone); + new_list->push_back(value); + for (; i < old_list->size(); ++i) { + new_list->push_back(old_list->at(i)); } - DCHECK_EQ(old_list->length() + 1, new_list->length()); + DCHECK_EQ(old_list->size() + 1, new_list->size()); DCHECK(IsAligned(bit_cast(new_list), kPointerAlignment)); data_ = bit_cast(new_list) | kListTag; } @@ -85,17 +87,32 @@ class ZoneHandleSet final { if (other.data_ == kEmptyTag) return true; if ((data_ & kTagMask) == kSingletonTag) return false; DCHECK_EQ(kListTag, data_ & kTagMask); + List const* cached_list = list(); if ((other.data_ & kTagMask) == kSingletonTag) { - return list()->Contains(other.singleton()); + return std::find(cached_list->begin(), cached_list->end(), + other.singleton()) != cached_list->end(); } DCHECK_EQ(kListTag, other.data_ & kTagMask); // TODO(bmeurer): Optimize this case. - for (int i = 0; i < other.list()->length(); ++i) { - if (!list()->Contains(other.list()->at(i))) return false; + for (size_t i = 0; i < other.list()->size(); ++i) { + if (std::find(cached_list->begin(), cached_list->end(), + other.list()->at(i)) == cached_list->end()) { + return false; + } } return true; } + bool contains(Handle other) const { + if (data_ == kEmptyTag) return false; + if ((data_ & kTagMask) == kSingletonTag) { + return singleton() == bit_cast(other.address()); + } + DCHECK_EQ(kListTag, data_ & kTagMask); + return std::find(list()->begin(), list()->end(), + bit_cast(other.address())) != list()->end(); + } + void remove(Handle handle, Zone* zone) { // TODO(bmeurer): Optimize this case. ZoneHandleSet that; @@ -115,8 +132,8 @@ class ZoneHandleSet final { (rhs.data_ & kTagMask) == kListTag) { List const* const lhs_list = lhs.list(); List const* const rhs_list = rhs.list(); - if (lhs_list->length() == rhs_list->length()) { - for (int i = 0; i < lhs_list->length(); ++i) { + if (lhs_list->size() == rhs_list->size()) { + for (size_t i = 0; i < lhs_list->size(); ++i) { if (lhs_list->at(i) != rhs_list->at(i)) return false; } return true; @@ -139,7 +156,7 @@ class ZoneHandleSet final { inline const_iterator end() const; private: - typedef ZoneList List; + typedef ZoneVector List; List const* list() const { DCHECK_EQ(kListTag, data_ & kTagMask); diff --git a/deps/v8/src/zone/zone-list-inl.h b/deps/v8/src/zone/zone-list-inl.h index efae3971a3..d90c9a28fe 100644 --- a/deps/v8/src/zone/zone-list-inl.h +++ b/deps/v8/src/zone/zone-list-inl.h @@ -111,7 +111,7 @@ void ZoneList::Clear() { DeleteData(data_); // We don't call Initialize(0) since that requires passing a Zone, // which we don't really need. - data_ = NULL; + data_ = nullptr; capacity_ = 0; length_ = 0; } diff --git a/deps/v8/src/zone/zone.cc b/deps/v8/src/zone/zone.cc index d9113a8f76..de8146de05 100644 --- a/deps/v8/src/zone/zone.cc +++ b/deps/v8/src/zone/zone.cc @@ -59,7 +59,7 @@ Zone::~Zone() { DeleteAll(); - DCHECK(segment_bytes_allocated_ == 0); + DCHECK_EQ(segment_bytes_allocated_, 0); } void* Zone::New(size_t size) { diff --git a/deps/v8/src/zone/zone.h b/deps/v8/src/zone/zone.h index ba79cfa666..c8c1fe3515 100644 --- a/deps/v8/src/zone/zone.h +++ b/deps/v8/src/zone/zone.h @@ -204,8 +204,8 @@ class ZoneList final { INLINE(void Initialize(int capacity, Zone* zone)) { DCHECK_GE(capacity, 0); - data_ = - (capacity > 0) ? NewData(capacity, ZoneAllocationPolicy(zone)) : NULL; + data_ = (capacity > 0) ? NewData(capacity, ZoneAllocationPolicy(zone)) + : nullptr; capacity_ = capacity; length_ = 0; } @@ -314,4 +314,17 @@ typedef base::CustomMatcherTemplateHashMapImpl } // namespace internal } // namespace v8 +// The accidential pattern +// new (zone) SomeObject() +// where SomeObject does not inherit from ZoneObject leads to nasty crashes. +// This triggers a compile-time error instead. +template ::value>::type> +void* operator new(size_t size, T zone) { + static_assert(false && sizeof(T), + "Placement new with a zone is only permitted for classes " + "inheriting from ZoneObject"); + UNREACHABLE(); +} + #endif // V8_ZONE_ZONE_H_ -- cgit v1.2.3