From 6039cda6168773c168b65adba52ddef33d77bf3e Mon Sep 17 00:00:00 2001 From: Hannes Payer Date: Fri, 27 Nov 2020 12:35:52 +0100 Subject: [PATCH] [heap] Remove NewSpace shrinking logic in CollectAllAvailableGarbage. NewSpace shrinking is already performed in Heap::GarbageCollectionEpilogueInSafepoint. Bug: chromium:1054771 Change-Id: Ia274dd5619fd1d7397a06f0b642f07d68de45ea1 Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2563267 Commit-Queue: Hannes Payer Reviewed-by: Ulan Degenbaev Cr-Commit-Position: refs/heads/master@{#71451} --- src/heap/heap.cc | 4 ---- src/heap/new-spaces.cc | 2 +- 2 files changed, 1 insertion(+), 5 deletions(-) diff --git a/src/heap/heap.cc b/src/heap/heap.cc index eb46888c4a..efc0471308 100644 --- a/src/heap/heap.cc +++ b/src/heap/heap.cc @@ -1406,10 +1406,6 @@ void Heap::CollectAllAvailableGarbage(GarbageCollectionReason gc_reason) { } set_current_gc_flags(kNoGCFlags); - new_space_->Shrink(); - new_lo_space_->SetCapacity(new_space_->Capacity() * - kNewLargeObjectSpaceToSemiSpaceRatio); - UncommitFromSpace(); EagerlyFreeExternalMemory(); if (FLAG_trace_duplicate_threshold_kb) { diff --git a/src/heap/new-spaces.cc b/src/heap/new-spaces.cc index 52548e4071..4046336568 100644 --- a/src/heap/new-spaces.cc +++ b/src/heap/new-spaces.cc @@ -457,7 +457,7 @@ void NewSpace::Shrink() { if (rounded_new_capacity < TotalCapacity() && to_space_.ShrinkTo(rounded_new_capacity)) { // Only shrink from-space if we managed to shrink to-space. - from_space_.Reset(); + if (from_space_.is_committed()) from_space_.Reset(); if (!from_space_.ShrinkTo(rounded_new_capacity)) { // If we managed to shrink to-space but couldn't shrink from // space, attempt to grow to-space again.