summaryrefslogtreecommitdiff
path: root/deps/v8/src/zone
diff options
context:
space:
mode:
authorMichaƫl Zasso <targos@protonmail.com>2018-01-24 20:16:06 +0100
committerMyles Borins <mylesborins@google.com>2018-01-24 15:02:20 -0800
commit4c4af643e5042d615a60c6bbc05aee9d81b903e5 (patch)
tree3fb0a97988fe4439ae3ae06f26915d1dcf8cab92 /deps/v8/src/zone
parentfa9f31a4fda5a3782c652e56e394465805ebb50f (diff)
downloadandroid-node-v8-4c4af643e5042d615a60c6bbc05aee9d81b903e5.tar.gz
android-node-v8-4c4af643e5042d615a60c6bbc05aee9d81b903e5.tar.bz2
android-node-v8-4c4af643e5042d615a60c6bbc05aee9d81b903e5.zip
deps: update V8 to 6.4.388.40
PR-URL: https://github.com/nodejs/node/pull/17489 Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Matteo Collina <matteo.collina@gmail.com> Reviewed-By: Myles Borins <myles.borins@gmail.com> Reviewed-By: Ali Ijaz Sheikh <ofrobots@google.com>
Diffstat (limited to 'deps/v8/src/zone')
-rw-r--r--deps/v8/src/zone/zone-handle-set.h59
-rw-r--r--deps/v8/src/zone/zone-list-inl.h2
-rw-r--r--deps/v8/src/zone/zone.cc2
-rw-r--r--deps/v8/src/zone/zone.h17
4 files changed, 55 insertions, 25 deletions
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<T> at(size_t i) const {
@@ -46,34 +47,35 @@ class ZoneHandleSet final {
data_ = bit_cast<intptr_t>(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<intptr_t>(list), kPointerAlignment));
data_ = bit_cast<intptr_t>(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<intptr_t>(new_list), kPointerAlignment));
data_ = bit_cast<intptr_t>(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<T> other) const {
+ if (data_ == kEmptyTag) return false;
+ if ((data_ & kTagMask) == kSingletonTag) {
+ return singleton() == bit_cast<T**>(other.address());
+ }
+ DCHECK_EQ(kListTag, data_ & kTagMask);
+ return std::find(list()->begin(), list()->end(),
+ bit_cast<T**>(other.address())) != list()->end();
+ }
+
void remove(Handle<T> handle, Zone* zone) {
// TODO(bmeurer): Optimize this case.
ZoneHandleSet<T> 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<T**> List;
+ typedef ZoneVector<T**> 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<T>::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<ZoneAllocationPolicy>
} // 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 <class T, typename = typename std::enable_if<std::is_convertible<
+ T, const v8::internal::Zone*>::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_