Commit 8c359f64 authored by Toon Verwaest's avatar Toon Verwaest Committed by Commit Bot

[zone] Keep one page when we Zone::Reset for reuse

Change-Id: I50c6124d3da5b35d4156c066f38d10d2dc966567
Reviewed-on: https://chromium-review.googlesource.com/c/1349246Reviewed-by: 's avatarIgor Sheludko <ishell@chromium.org>
Commit-Queue: Toon Verwaest <verwaest@chromium.org>
Cr-Commit-Position: refs/heads/master@{#57793}
parent e167ad82
......@@ -1488,7 +1488,7 @@ void DeclarationScope::ResetAfterPreparsing(AstValueFactory* ast_value_factory,
has_rest_ = false;
DCHECK_NE(zone_, ast_value_factory->zone());
zone_->ReleaseMemory();
zone_->Reset();
if (aborted) {
// Prepare scope for use in the outer zone.
......
......@@ -73,10 +73,16 @@ void* Zone::AsanNew(size_t size) {
return reinterpret_cast<void*>(result);
}
void Zone::ReleaseMemory() {
void Zone::Reset() {
if (!segment_head_) return;
allocator_->ZoneDestruction(this);
Segment* keep = segment_head_;
segment_head_ = segment_head_->next();
keep->set_next(nullptr);
DeleteAll();
allocator_->ZoneCreation(this);
keep->ZapContents();
segment_head_ = keep;
}
void Zone::DeleteAll() {
......
......@@ -69,9 +69,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();
// Allows the zone to be safely reused. Releases the memory except for the
// last page, and fires zone destruction and creation events for the
// accounting allocator.
void Reset();
// Returns true if more memory has been allocated in zones than
// the limit allows.
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment