summaryrefslogtreecommitdiff
path: root/chromium/v8/src/zone/zone.cc
diff options
context:
space:
mode:
authorAllan Sandfeld Jensen <allan.jensen@qt.io>2020-10-12 14:27:29 +0200
committerAllan Sandfeld Jensen <allan.jensen@qt.io>2020-10-13 09:35:20 +0000
commitc30a6232df03e1efbd9f3b226777b07e087a1122 (patch)
treee992f45784689f373bcc38d1b79a239ebe17ee23 /chromium/v8/src/zone/zone.cc
parent7b5b123ac58f58ffde0f4f6e488bcd09aa4decd3 (diff)
downloadqtwebengine-chromium-85-based.tar.gz
BASELINE: Update Chromium to 85.0.4183.14085-based
Change-Id: Iaa42f4680837c57725b1344f108c0196741f6057 Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
Diffstat (limited to 'chromium/v8/src/zone/zone.cc')
-rw-r--r--chromium/v8/src/zone/zone.cc50
1 files changed, 27 insertions, 23 deletions
diff --git a/chromium/v8/src/zone/zone.cc b/chromium/v8/src/zone/zone.cc
index 81fc9c7d8b3..34882d966ca 100644
--- a/chromium/v8/src/zone/zone.cc
+++ b/chromium/v8/src/zone/zone.cc
@@ -36,11 +36,10 @@ Zone::Zone(AccountingAllocator* allocator, const char* name)
segment_head_(nullptr),
name_(name),
sealed_(false) {
- allocator_->ZoneCreation(this);
+ allocator_->TraceZoneCreation(this);
}
Zone::~Zone() {
- allocator_->ZoneDestruction(this);
DeleteAll();
DCHECK_EQ(segment_bytes_allocated_, 0);
@@ -74,14 +73,23 @@ void* Zone::AsanNew(size_t size) {
}
void Zone::ReleaseMemory() {
- allocator_->ZoneDestruction(this);
DeleteAll();
- allocator_->ZoneCreation(this);
+ allocator_->TraceZoneCreation(this);
}
void Zone::DeleteAll() {
+ Segment* current = segment_head_;
+ if (current) {
+ // Commit the allocation_size_ of segment_head_ and disconnect the segments
+ // list from the zone in order to ensure that tracing accounting allocator
+ // will observe value including memory from the head segment.
+ allocation_size_ = allocation_size();
+ segment_head_ = nullptr;
+ }
+ allocator_->TraceZoneDestruction(this);
+
// Traverse the chained list of segments and return them all to the allocator.
- for (Segment* current = segment_head_; current;) {
+ while (current) {
Segment* next = current->next();
size_t size = current->total_size();
@@ -96,30 +104,14 @@ void Zone::DeleteAll() {
position_ = limit_ = 0;
allocation_size_ = 0;
- segment_head_ = nullptr;
-}
-
-// Creates a new segment, sets its size, and pushes it to the front
-// of the segment chain. Returns the new segment.
-Segment* Zone::NewSegment(size_t requested_size) {
- Segment* result = allocator_->AllocateSegment(requested_size);
- if (!result) return nullptr;
- DCHECK_GE(result->total_size(), requested_size);
- segment_bytes_allocated_ += result->total_size();
- result->set_zone(this);
- result->set_next(segment_head_);
- segment_head_ = result;
- return result;
}
Address Zone::NewExpand(size_t size) {
// Make sure the requested size is already properly aligned and that
// there isn't enough room in the Zone to satisfy the request.
DCHECK_EQ(size, RoundDown(size, kAlignmentInBytes));
- DCHECK(limit_ - position_ < size);
+ DCHECK_LT(limit_ - position_, size);
- // Commit the allocation_size_ of segment_head_ if any.
- allocation_size_ = allocation_size();
// Compute the new segment size. We use a 'high water mark'
// strategy, where we increase the segment size every time we expand
// except that we employ a maximum segment size when we delete. This
@@ -148,12 +140,24 @@ Address Zone::NewExpand(size_t size) {
V8::FatalProcessOutOfMemory(nullptr, "Zone");
return kNullAddress;
}
- Segment* segment = NewSegment(new_size);
+
+ Segment* segment = allocator_->AllocateSegment(new_size);
if (segment == nullptr) {
V8::FatalProcessOutOfMemory(nullptr, "Zone");
return kNullAddress;
}
+ DCHECK_GE(segment->total_size(), new_size);
+ segment_bytes_allocated_ += segment->total_size();
+ segment->set_zone(this);
+ segment->set_next(segment_head_);
+ // Commit the allocation_size_ of segment_head_ if any, in order to ensure
+ // that tracing accounting allocator will observe value including memory
+ // from the previous head segment.
+ allocation_size_ = allocation_size();
+ segment_head_ = segment;
+ allocator_->TraceAllocateSegment(segment);
+
// Recompute 'top' and 'limit' based on the new segment.
Address result = RoundUp(segment->start(), kAlignmentInBytes);
position_ = result + size;