summaryrefslogtreecommitdiff
path: root/deps/v8/src/zone
diff options
context:
space:
mode:
authorMichaël Zasso <targos@protonmail.com>2018-12-04 08:20:37 +0100
committerMichaël Zasso <targos@protonmail.com>2018-12-06 15:23:33 +0100
commit9b4bf7de6c9a7c25f116c7a502384c20b5cfaea3 (patch)
tree2b0c843168dafb939d8df8a15b2aa72b76dee51d /deps/v8/src/zone
parentb8fbe69db1292307adb2c2b2e0d5ef48c4ab2faf (diff)
downloadnode-new-9b4bf7de6c9a7c25f116c7a502384c20b5cfaea3.tar.gz
deps: update V8 to 7.1.302.28
PR-URL: https://github.com/nodejs/node/pull/23423 Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Gus Caplan <me@gus.host> Reviewed-By: Myles Borins <myles.borins@gmail.com>
Diffstat (limited to 'deps/v8/src/zone')
-rw-r--r--deps/v8/src/zone/zone-allocator.h4
-rw-r--r--deps/v8/src/zone/zone-chunk-list.h4
-rw-r--r--deps/v8/src/zone/zone-containers.h4
-rw-r--r--deps/v8/src/zone/zone.cc7
-rw-r--r--deps/v8/src/zone/zone.h17
5 files changed, 26 insertions, 10 deletions
diff --git a/deps/v8/src/zone/zone-allocator.h b/deps/v8/src/zone/zone-allocator.h
index 3914241e04..b3ce2473b6 100644
--- a/deps/v8/src/zone/zone-allocator.h
+++ b/deps/v8/src/zone/zone-allocator.h
@@ -42,7 +42,7 @@ class ZoneAllocator {
T* address(T& x) const { return &x; }
const T* address(const T& x) const { return &x; }
- T* allocate(size_t n, const void* hint = 0) {
+ T* allocate(size_t n, const void* hint = nullptr) {
return static_cast<T*>(zone_->NewArray<T>(static_cast<int>(n)));
}
void deallocate(T* p, size_t) { /* noop for Zones */
@@ -103,7 +103,7 @@ class RecyclingZoneAllocator : public ZoneAllocator<T> {
template <typename U>
friend class RecyclingZoneAllocator;
- T* allocate(size_t n, const void* hint = 0) {
+ T* allocate(size_t n, const void* hint = nullptr) {
// Only check top block in free list, since this will be equal to or larger
// than the other blocks in the free list.
if (free_list_ && free_list_->size >= n) {
diff --git a/deps/v8/src/zone/zone-chunk-list.h b/deps/v8/src/zone/zone-chunk-list.h
index 9c0c073a81..049e8f52a9 100644
--- a/deps/v8/src/zone/zone-chunk-list.h
+++ b/deps/v8/src/zone/zone-chunk-list.h
@@ -155,8 +155,8 @@ class ZoneChunkListIterator
using ChunkList = maybe_const<ZoneChunkList<T>>;
public:
- maybe_const<T>& operator*() { return current_->items()[position_]; }
- maybe_const<T>* operator->() { return &current_->items()[position_]; }
+ maybe_const<T>& operator*() const { return current_->items()[position_]; }
+ maybe_const<T>* operator->() const { return &current_->items()[position_]; }
bool operator==(const ZoneChunkListIterator& other) const {
return other.current_ == current_ && other.position_ == position_;
}
diff --git a/deps/v8/src/zone/zone-containers.h b/deps/v8/src/zone/zone-containers.h
index 1988826779..86c4bd0702 100644
--- a/deps/v8/src/zone/zone-containers.h
+++ b/deps/v8/src/zone/zone-containers.h
@@ -161,10 +161,10 @@ class ZoneUnorderedMap
ZoneAllocator<std::pair<const K, V>>> {
public:
// Constructs an empty map.
- explicit ZoneUnorderedMap(Zone* zone)
+ explicit ZoneUnorderedMap(Zone* zone, size_t bucket_count = 100)
: std::unordered_map<K, V, Hash, KeyEqual,
ZoneAllocator<std::pair<const K, V>>>(
- 100, Hash(), KeyEqual(),
+ bucket_count, Hash(), KeyEqual(),
ZoneAllocator<std::pair<const K, V>>(zone)) {}
};
diff --git a/deps/v8/src/zone/zone.cc b/deps/v8/src/zone/zone.cc
index 295d7815cb..a851f6797a 100644
--- a/deps/v8/src/zone/zone.cc
+++ b/deps/v8/src/zone/zone.cc
@@ -43,7 +43,6 @@ Zone::Zone(AccountingAllocator* allocator, const char* name,
Zone::~Zone() {
allocator_->ZoneDestruction(this);
-
DeleteAll();
DCHECK_EQ(segment_bytes_allocated_, 0);
@@ -77,6 +76,12 @@ void* Zone::New(size_t size) {
return reinterpret_cast<void*>(result);
}
+void Zone::ReleaseMemory() {
+ allocator_->ZoneDestruction(this);
+ DeleteAll();
+ allocator_->ZoneCreation(this);
+}
+
void Zone::DeleteAll() {
// Traverse the chained list of segments and return them all to the allocator.
for (Segment* current = segment_head_; current;) {
diff --git a/deps/v8/src/zone/zone.h b/deps/v8/src/zone/zone.h
index 6f863f27fd..5fcc25b350 100644
--- a/deps/v8/src/zone/zone.h
+++ b/deps/v8/src/zone/zone.h
@@ -9,8 +9,10 @@
#include "src/base/hashmap.h"
#include "src/base/logging.h"
+#include "src/base/threaded-list.h"
#include "src/globals.h"
#include "src/splay-tree.h"
+#include "src/utils.h"
#include "src/zone/accounting-allocator.h"
#ifndef ZONE_NAME
@@ -56,6 +58,10 @@ class V8_EXPORT_PRIVATE Zone final {
// Seals the zone to prevent any further allocation.
void Seal() { sealed_ = true; }
+ // Allows the zone to be safely reused. Releases the memory and fires zone
+ // destruction and creation events for the accounting allocator.
+ void ReleaseMemory();
+
// Returns true if more memory has been allocated in zones than
// the limit allows.
bool excess_allocation() const {
@@ -69,6 +75,9 @@ class V8_EXPORT_PRIVATE Zone final {
AccountingAllocator* allocator() const { return allocator_; }
private:
+ // Deletes all objects and free all memory allocated in the Zone.
+ void DeleteAll();
+
// All pointers returned from New() are 8-byte aligned.
static const size_t kAlignmentInBytes = 8;
@@ -81,9 +90,6 @@ class V8_EXPORT_PRIVATE Zone final {
// Report zone excess when allocation exceeds this limit.
static const size_t kExcessLimit = 256 * MB;
- // Deletes all objects and free all memory allocated in the Zone.
- void DeleteAll();
-
// The number of bytes allocated in this zone so far.
size_t allocation_size_;
@@ -295,6 +301,11 @@ class ZoneList final {
template <typename T>
using ZonePtrList = ZoneList<T*>;
+// ZoneThreadedList is a special variant of the ThreadedList that can be put
+// into a Zone.
+template <typename T, typename TLTraits = base::ThreadedListTraits<T>>
+using ZoneThreadedList = base::ThreadedListBase<T, ZoneObject, TLTraits>;
+
// A zone splay tree. The config type parameter encapsulates the
// different configurations of a concrete splay tree (see splay-tree.h).
// The tree itself and all its elements are allocated in the Zone.