diff options
Diffstat (limited to 'deps/v8/src/zone')
-rw-r--r-- | deps/v8/src/zone/accounting-allocator.cc | 8 | ||||
-rw-r--r-- | deps/v8/src/zone/zone-containers.h | 5 | ||||
-rw-r--r-- | deps/v8/src/zone/zone.cc | 9 | ||||
-rw-r--r-- | deps/v8/src/zone/zone.h | 7 |
4 files changed, 21 insertions, 8 deletions
diff --git a/deps/v8/src/zone/accounting-allocator.cc b/deps/v8/src/zone/accounting-allocator.cc index ee841fb4af..8ef141b4c1 100644 --- a/deps/v8/src/zone/accounting-allocator.cc +++ b/deps/v8/src/zone/accounting-allocator.cc @@ -10,6 +10,8 @@ #include <malloc.h> // NOLINT #endif +#include "src/allocation.h" + namespace v8 { namespace internal { @@ -82,11 +84,7 @@ Segment* AccountingAllocator::GetSegment(size_t bytes) { } Segment* AccountingAllocator::AllocateSegment(size_t bytes) { - void* memory = malloc(bytes); - if (memory == nullptr) { - V8::GetCurrentPlatform()->OnCriticalMemoryPressure(); - memory = malloc(bytes); - } + void* memory = AllocWithRetry(bytes); if (memory != nullptr) { base::AtomicWord current = base::Relaxed_AtomicIncrement(¤t_memory_usage_, bytes); diff --git a/deps/v8/src/zone/zone-containers.h b/deps/v8/src/zone/zone-containers.h index 78d25cc644..5e9fd0440a 100644 --- a/deps/v8/src/zone/zone-containers.h +++ b/deps/v8/src/zone/zone-containers.h @@ -41,6 +41,11 @@ class ZoneVector : public std::vector<T, ZoneAllocator<T>> { ZoneVector(size_t size, T def, Zone* zone) : std::vector<T, ZoneAllocator<T>>(size, def, ZoneAllocator<T>(zone)) {} + // Constructs a new vector and fills it with the contents of the given + // initializer list. + ZoneVector(std::initializer_list<T> list, Zone* zone) + : std::vector<T, ZoneAllocator<T>>(list, ZoneAllocator<T>(zone)) {} + // Constructs a new vector and fills it with the contents of the range // [first, last). template <class InputIt> diff --git a/deps/v8/src/zone/zone.cc b/deps/v8/src/zone/zone.cc index de8146de05..470f4c4177 100644 --- a/deps/v8/src/zone/zone.cc +++ b/deps/v8/src/zone/zone.cc @@ -42,7 +42,8 @@ const size_t kASanRedzoneBytes = 0; } // namespace -Zone::Zone(AccountingAllocator* allocator, const char* name) +Zone::Zone(AccountingAllocator* allocator, const char* name, + SegmentSize segment_size) : allocation_size_(0), segment_bytes_allocated_(0), position_(0), @@ -50,7 +51,8 @@ Zone::Zone(AccountingAllocator* allocator, const char* name) allocator_(allocator), segment_head_(nullptr), name_(name), - sealed_(false) { + sealed_(false), + segment_size_(segment_size) { allocator_->ZoneCreation(this); } @@ -148,6 +150,9 @@ Address Zone::NewExpand(size_t size) { V8::FatalProcessOutOfMemory("Zone"); return nullptr; } + if (segment_size_ == SegmentSize::kLarge) { + new_size = kMaximumSegmentSize; + } if (new_size < kMinimumSegmentSize) { new_size = kMinimumSegmentSize; } else if (new_size > kMaximumSegmentSize) { diff --git a/deps/v8/src/zone/zone.h b/deps/v8/src/zone/zone.h index c8c1fe3515..e15e3d116e 100644 --- a/deps/v8/src/zone/zone.h +++ b/deps/v8/src/zone/zone.h @@ -34,9 +34,13 @@ namespace internal { // // Note: The implementation is inherently not thread safe. Do not use // from multi-threaded code. + +enum class SegmentSize { kLarge, kDefault }; + class V8_EXPORT_PRIVATE Zone final { public: - Zone(AccountingAllocator* allocator, const char* name); + Zone(AccountingAllocator* allocator, const char* name, + SegmentSize segment_size = SegmentSize::kDefault); ~Zone(); // Allocate 'size' bytes of memory in the Zone; expands the Zone by @@ -109,6 +113,7 @@ class V8_EXPORT_PRIVATE Zone final { Segment* segment_head_; const char* name_; bool sealed_; + SegmentSize segment_size_; }; // ZoneObject is an abstraction that helps define classes of objects |