From 3d1b3df9486c0e7708065257f7311902f6b7b366 Mon Sep 17 00:00:00 2001 From: MichaĆ«l Zasso Date: Wed, 18 Oct 2017 15:03:02 -0700 Subject: deps: update V8 to 6.2.414.32 PR-URL: https://github.com/nodejs/node/pull/15362 Reviewed-By: Myles Borins Reviewed-By: Colin Ihrig Reviewed-By: Matteo Collina Reviewed-By: Ben Noordhuis --- deps/v8/src/zone/accounting-allocator.cc | 6 +++++- deps/v8/src/zone/zone-chunk-list.h | 2 +- deps/v8/src/zone/zone-containers.h | 32 ++++++++++++++++++++++++++++++++ deps/v8/src/zone/zone-handle-set.h | 9 +++++++++ deps/v8/src/zone/zone.cc | 2 +- 5 files changed, 48 insertions(+), 3 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 08381b31f1..ee841fb4af 100644 --- a/deps/v8/src/zone/accounting-allocator.cc +++ b/deps/v8/src/zone/accounting-allocator.cc @@ -83,7 +83,11 @@ Segment* AccountingAllocator::GetSegment(size_t bytes) { Segment* AccountingAllocator::AllocateSegment(size_t bytes) { void* memory = malloc(bytes); - if (memory) { + if (memory == nullptr) { + V8::GetCurrentPlatform()->OnCriticalMemoryPressure(); + memory = malloc(bytes); + } + if (memory != nullptr) { base::AtomicWord current = base::Relaxed_AtomicIncrement(¤t_memory_usage_, bytes); base::AtomicWord max = base::Relaxed_Load(&max_memory_usage_); diff --git a/deps/v8/src/zone/zone-chunk-list.h b/deps/v8/src/zone/zone-chunk-list.h index 8c7e5d98d0..a0aaca8b09 100644 --- a/deps/v8/src/zone/zone-chunk-list.h +++ b/deps/v8/src/zone/zone-chunk-list.h @@ -25,7 +25,7 @@ class ReverseZoneChunkListIterator; // collection that // * needs to grow indefinitely, // * will mostly grow at the back, but may sometimes grow in front as well -// (preferrably in batches), +// (preferably in batches), // * needs to have very low overhead, // * offers forward- and backwards-iteration, // * offers relatively fast seeking, diff --git a/deps/v8/src/zone/zone-containers.h b/deps/v8/src/zone/zone-containers.h index f399899464..78d25cc644 100644 --- a/deps/v8/src/zone/zone-containers.h +++ b/deps/v8/src/zone/zone-containers.h @@ -12,8 +12,11 @@ #include #include #include +#include +#include #include +#include "src/base/functional.h" #include "src/zone/zone-allocator.h" namespace v8 { @@ -133,6 +136,35 @@ class ZoneMap Compare(), ZoneAllocator>(zone)) {} }; +// A wrapper subclass for std::unordered_map to make it easy to construct one +// that uses a zone allocator. +template , + typename KeyEqual = std::equal_to> +class ZoneUnorderedMap + : public std::unordered_map>> { + public: + // Constructs an empty map. + explicit ZoneUnorderedMap(Zone* zone) + : std::unordered_map>>( + 100, Hash(), KeyEqual(), + ZoneAllocator>(zone)) {} +}; + +// A wrapper subclass for std::unordered_set to make it easy to construct one +// that uses a zone allocator. +template , + typename KeyEqual = std::equal_to> +class ZoneUnorderedSet + : public std::unordered_set> { + public: + // Constructs an empty map. + explicit ZoneUnorderedSet(Zone* zone) + : std::unordered_set>( + 100, Hash(), KeyEqual(), ZoneAllocator(zone)) {} +}; + // A wrapper subclass for std::multimap to make it easy to construct one that // uses a zone allocator. template > diff --git a/deps/v8/src/zone/zone-handle-set.h b/deps/v8/src/zone/zone-handle-set.h index b3c3688461..e2cc1c6dc3 100644 --- a/deps/v8/src/zone/zone-handle-set.h +++ b/deps/v8/src/zone/zone-handle-set.h @@ -163,6 +163,15 @@ class ZoneHandleSet final { intptr_t data_; }; +template +std::ostream& operator<<(std::ostream& os, ZoneHandleSet set) { + for (size_t i = 0; i < set.size(); ++i) { + if (i > 0) os << ", "; + os << set.at(i); + } + return os; +} + template class ZoneHandleSet::const_iterator { public: diff --git a/deps/v8/src/zone/zone.cc b/deps/v8/src/zone/zone.cc index d2dd9ce068..d9113a8f76 100644 --- a/deps/v8/src/zone/zone.cc +++ b/deps/v8/src/zone/zone.cc @@ -171,7 +171,7 @@ Address Zone::NewExpand(size_t size) { Address result = RoundUp(segment->start(), kAlignmentInBytes); position_ = result + size; // Check for address overflow. - // (Should not happen since the segment is guaranteed to accomodate + // (Should not happen since the segment is guaranteed to accommodate // size bytes + header and alignment padding) DCHECK(reinterpret_cast(position_) >= reinterpret_cast(result)); -- cgit v1.2.3