From 60d1aac8d225e844e68ae48e8f3d58802e635fbe Mon Sep 17 00:00:00 2001 From: Michaƫl Zasso Date: Tue, 2 May 2017 10:50:00 +0200 Subject: deps: update V8 to 5.8.283.38 PR-URL: https://github.com/nodejs/node/pull/12784 Reviewed-By: Ben Noordhuis Reviewed-By: Gibson Fahnestock --- deps/v8/src/zone/accounting-allocator.cc | 4 +++- deps/v8/src/zone/zone-allocator.h | 15 +++++++++++---- deps/v8/src/zone/zone.cc | 9 ++++++--- deps/v8/src/zone/zone.h | 4 ++++ 4 files changed, 24 insertions(+), 8 deletions(-) (limited to 'deps/v8/src/zone') diff --git a/deps/v8/src/zone/accounting-allocator.cc b/deps/v8/src/zone/accounting-allocator.cc index 587e09d585..c06306309d 100644 --- a/deps/v8/src/zone/accounting-allocator.cc +++ b/deps/v8/src/zone/accounting-allocator.cc @@ -73,7 +73,9 @@ Segment* AccountingAllocator::GetSegment(size_t bytes) { Segment* result = GetSegmentFromPool(bytes); if (result == nullptr) { result = AllocateSegment(bytes); - result->Initialize(bytes); + if (result != nullptr) { + result->Initialize(bytes); + } } return result; diff --git a/deps/v8/src/zone/zone-allocator.h b/deps/v8/src/zone/zone-allocator.h index 1e2862a2c1..5852ca918c 100644 --- a/deps/v8/src/zone/zone-allocator.h +++ b/deps/v8/src/zone/zone-allocator.h @@ -26,8 +26,10 @@ class zone_allocator { typedef zone_allocator other; }; - // TODO(bbudge) Remove when V8 updates to MSVS 2015. See crbug.com/603131. +#ifdef V8_CC_MSVC + // MSVS unfortunately requires the default constructor to be defined. zone_allocator() : zone_(nullptr) { UNREACHABLE(); } +#endif explicit zone_allocator(Zone* zone) throw() : zone_(zone) {} explicit zone_allocator(const zone_allocator& other) throw() : zone_(other.zone_) {} @@ -49,10 +51,15 @@ class zone_allocator { size_type max_size() const throw() { return std::numeric_limits::max() / sizeof(value_type); } - void construct(pointer p, const T& val) { - new (static_cast(p)) T(val); + template + void construct(U* p, Args&&... args) { + void* v_p = const_cast(static_cast(p)); + new (v_p) U(std::forward(args)...); + } + template + void destroy(U* p) { + p->~U(); } - void destroy(pointer p) { p->~T(); } bool operator==(zone_allocator const& other) const { return zone_ == other.zone_; diff --git a/deps/v8/src/zone/zone.cc b/deps/v8/src/zone/zone.cc index 8dd96dc1cd..d2dd9ce068 100644 --- a/deps/v8/src/zone/zone.cc +++ b/deps/v8/src/zone/zone.cc @@ -49,7 +49,8 @@ Zone::Zone(AccountingAllocator* allocator, const char* name) limit_(0), allocator_(allocator), segment_head_(nullptr), - name_(name) { + name_(name), + sealed_(false) { allocator_->ZoneCreation(this); } @@ -62,6 +63,8 @@ Zone::~Zone() { } void* Zone::New(size_t size) { + CHECK(!sealed_); + // Round up the requested size to fit the alignment. size = RoundUp(size, kAlignmentInBytes); @@ -111,9 +114,9 @@ void Zone::DeleteAll() { // of the segment chain. Returns the new segment. Segment* Zone::NewSegment(size_t requested_size) { Segment* result = allocator_->GetSegment(requested_size); - DCHECK_GE(result->size(), requested_size); - segment_bytes_allocated_ += result->size(); if (result != nullptr) { + DCHECK_GE(result->size(), requested_size); + segment_bytes_allocated_ += result->size(); result->set_zone(this); result->set_next(segment_head_); segment_head_ = result; diff --git a/deps/v8/src/zone/zone.h b/deps/v8/src/zone/zone.h index dbc1dadadd..c916972dcf 100644 --- a/deps/v8/src/zone/zone.h +++ b/deps/v8/src/zone/zone.h @@ -50,6 +50,9 @@ class V8_EXPORT_PRIVATE Zone final { return static_cast(New(length * sizeof(T))); } + // Seals the zone to prevent any further allocation. + void Seal() { sealed_ = true; } + // Returns true if more memory has been allocated in zones than // the limit allows. bool excess_allocation() const { @@ -106,6 +109,7 @@ class V8_EXPORT_PRIVATE Zone final { Segment* segment_head_; const char* name_; + bool sealed_; }; // ZoneObject is an abstraction that helps define classes of objects -- cgit v1.2.3