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, ...@@ -1488,7 +1488,7 @@ void DeclarationScope::ResetAfterPreparsing(AstValueFactory* ast_value_factory,
has_rest_ = false; has_rest_ = false;
DCHECK_NE(zone_, ast_value_factory->zone()); DCHECK_NE(zone_, ast_value_factory->zone());
zone_->ReleaseMemory(); zone_->Reset();
if (aborted) { if (aborted) {
// Prepare scope for use in the outer zone. // Prepare scope for use in the outer zone.
......
...@@ -73,10 +73,16 @@ void* Zone::AsanNew(size_t size) { ...@@ -73,10 +73,16 @@ void* Zone::AsanNew(size_t size) {
return reinterpret_cast<void*>(result); return reinterpret_cast<void*>(result);
} }
void Zone::ReleaseMemory() { void Zone::Reset() {
if (!segment_head_) return;
allocator_->ZoneDestruction(this); allocator_->ZoneDestruction(this);
Segment* keep = segment_head_;
segment_head_ = segment_head_->next();
keep->set_next(nullptr);
DeleteAll(); DeleteAll();
allocator_->ZoneCreation(this); allocator_->ZoneCreation(this);
keep->ZapContents();
segment_head_ = keep;
} }
void Zone::DeleteAll() { void Zone::DeleteAll() {
......
...@@ -69,9 +69,10 @@ class V8_EXPORT_PRIVATE Zone final { ...@@ -69,9 +69,10 @@ class V8_EXPORT_PRIVATE Zone final {
// Seals the zone to prevent any further allocation. // Seals the zone to prevent any further allocation.
void Seal() { sealed_ = true; } void Seal() { sealed_ = true; }
// Allows the zone to be safely reused. Releases the memory and fires zone // Allows the zone to be safely reused. Releases the memory except for the
// destruction and creation events for the accounting allocator. // last page, and fires zone destruction and creation events for the
void ReleaseMemory(); // accounting allocator.
void Reset();
// Returns true if more memory has been allocated in zones than // Returns true if more memory has been allocated in zones than
// the limit allows. // 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