summaryrefslogtreecommitdiff
path: root/deps/v8/src/zone
diff options
context:
space:
mode:
authorMichaël Zasso <targos@protonmail.com>2017-10-18 15:03:02 -0700
committerMichaël Zasso <targos@protonmail.com>2017-10-18 17:01:41 -0700
commit3d1b3df9486c0e7708065257f7311902f6b7b366 (patch)
treecb051bdeaead11e06dcd97725783e0f113afb1bf /deps/v8/src/zone
parente2cddbb8ccdb7b3c4a40c8acc630f68703bc77b5 (diff)
downloadandroid-node-v8-3d1b3df9486c0e7708065257f7311902f6b7b366.tar.gz
android-node-v8-3d1b3df9486c0e7708065257f7311902f6b7b366.tar.bz2
android-node-v8-3d1b3df9486c0e7708065257f7311902f6b7b366.zip
deps: update V8 to 6.2.414.32
PR-URL: https://github.com/nodejs/node/pull/15362 Reviewed-By: Myles Borins <myles.borins@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Matteo Collina <matteo.collina@gmail.com> Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Diffstat (limited to 'deps/v8/src/zone')
-rw-r--r--deps/v8/src/zone/accounting-allocator.cc6
-rw-r--r--deps/v8/src/zone/zone-chunk-list.h2
-rw-r--r--deps/v8/src/zone/zone-containers.h32
-rw-r--r--deps/v8/src/zone/zone-handle-set.h9
-rw-r--r--deps/v8/src/zone/zone.cc2
5 files changed, 48 insertions, 3 deletions
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(&current_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 <queue>
#include <set>
#include <stack>
+#include <unordered_map>
+#include <unordered_set>
#include <vector>
+#include "src/base/functional.h"
#include "src/zone/zone-allocator.h"
namespace v8 {
@@ -133,6 +136,35 @@ class ZoneMap
Compare(), ZoneAllocator<std::pair<const K, V>>(zone)) {}
};
+// A wrapper subclass for std::unordered_map to make it easy to construct one
+// that uses a zone allocator.
+template <typename K, typename V, typename Hash = base::hash<K>,
+ typename KeyEqual = std::equal_to<K>>
+class ZoneUnorderedMap
+ : public std::unordered_map<K, V, Hash, KeyEqual,
+ ZoneAllocator<std::pair<const K, V>>> {
+ public:
+ // Constructs an empty map.
+ explicit ZoneUnorderedMap(Zone* zone)
+ : std::unordered_map<K, V, Hash, KeyEqual,
+ ZoneAllocator<std::pair<const K, V>>>(
+ 100, Hash(), KeyEqual(),
+ ZoneAllocator<std::pair<const K, V>>(zone)) {}
+};
+
+// A wrapper subclass for std::unordered_set to make it easy to construct one
+// that uses a zone allocator.
+template <typename K, typename Hash = base::hash<K>,
+ typename KeyEqual = std::equal_to<K>>
+class ZoneUnorderedSet
+ : public std::unordered_set<K, Hash, KeyEqual, ZoneAllocator<K>> {
+ public:
+ // Constructs an empty map.
+ explicit ZoneUnorderedSet(Zone* zone)
+ : std::unordered_set<K, Hash, KeyEqual, ZoneAllocator<K>>(
+ 100, Hash(), KeyEqual(), ZoneAllocator<K>(zone)) {}
+};
+
// A wrapper subclass for std::multimap to make it easy to construct one that
// uses a zone allocator.
template <typename K, typename V, typename Compare = std::less<K>>
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
@@ -164,6 +164,15 @@ class ZoneHandleSet final {
};
template <typename T>
+std::ostream& operator<<(std::ostream& os, ZoneHandleSet<T> set) {
+ for (size_t i = 0; i < set.size(); ++i) {
+ if (i > 0) os << ", ";
+ os << set.at(i);
+ }
+ return os;
+}
+
+template <typename T>
class ZoneHandleSet<T>::const_iterator {
public:
typedef std::forward_iterator_tag iterator_category;
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<uintptr_t>(position_) >=
reinterpret_cast<uintptr_t>(result));