Shrink active semi-space and uncommit other semi-space only in idle memory mode.
authorhpayer <hpayer@chromium.org>
Fri, 15 May 2015 16:08:47 +0000 (09:08 -0700)
committerCommit bot <commit-bot@chromium.org>
Fri, 15 May 2015 16:08:34 +0000 (16:08 +0000)
BUG=chromium:483147
LOG=n

Review URL: https://codereview.chromium.org/1140693003

Cr-Commit-Position: refs/heads/master@{#28429}

src/heap/heap.cc
src/heap/heap.h

index ed7d70c89546a15e485c902a71b6459f929df2c4..1b8a6b74937b880aeb740cfaf8ea3af447a912c1 100644 (file)
@@ -4574,18 +4574,8 @@ void Heap::MakeHeapIterable() {
   DCHECK(IsHeapIterable());
 }
 
-
-void Heap::ReduceNewSpaceSize(bool is_long_idle_notification) {
-  if (is_long_idle_notification) {
-    new_space_.Shrink();
-    UncommitFromSpace();
-  }
-}
-
-
 bool Heap::TryFinalizeIdleIncrementalMarking(
-    bool is_long_idle_notification, double idle_time_in_ms,
-    size_t size_of_objects,
+    double idle_time_in_ms, size_t size_of_objects,
     size_t final_incremental_mark_compact_speed_in_bytes_per_ms) {
   if (FLAG_overapproximate_weak_closure &&
       (incremental_marking()->IsReadyToOverApproximateWeakClosure() ||
@@ -4603,7 +4593,6 @@ bool Heap::TryFinalizeIdleIncrementalMarking(
                   final_incremental_mark_compact_speed_in_bytes_per_ms))) {
     CollectAllGarbage(kNoGCFlags, "idle notification: finalize incremental");
     gc_idle_time_handler_.NotifyIdleMarkCompact();
-    ReduceNewSpaceSize(is_long_idle_notification);
     return true;
   }
   return false;
@@ -4710,8 +4699,7 @@ bool Heap::IdleNotification(double deadline_in_seconds) {
                !mark_compact_collector_.marking_deque()->IsEmpty());
       if (remaining_idle_time_in_ms > 0.0) {
         action.additional_work = TryFinalizeIdleIncrementalMarking(
-            is_long_idle_notification, remaining_idle_time_in_ms,
-            heap_state.size_of_objects,
+            remaining_idle_time_in_ms, heap_state.size_of_objects,
             heap_state.final_incremental_mark_compact_speed_in_bytes_per_ms);
       }
       break;
@@ -4728,13 +4716,11 @@ bool Heap::IdleNotification(double deadline_in_seconds) {
                           "idle notification: finalize idle round");
       }
       gc_count_at_last_idle_gc_ = gc_count_;
-      ReduceNewSpaceSize(is_long_idle_notification);
       gc_idle_time_handler_.NotifyIdleMarkCompact();
       break;
     }
     case DO_SCAVENGE:
       CollectGarbage(NEW_SPACE, "idle notification: scavenge");
-      ReduceNewSpaceSize(is_long_idle_notification);
       break;
     case DO_FINALIZE_SWEEPING:
       mark_compact_collector()->EnsureSweepingCompleted();
@@ -4743,6 +4729,11 @@ bool Heap::IdleNotification(double deadline_in_seconds) {
       break;
   }
 
+  if (action.reduce_memory) {
+    new_space_.Shrink();
+    UncommitFromSpace();
+  }
+
   double current_time = MonotonicallyIncreasingTimeInMs();
   last_idle_notification_time_ = current_time;
   double deadline_difference = deadline_in_ms - current_time;
index e640d1ee65d7d98a75a35c76bcbb2b0dcb3b373c..8c1b459e0866a682ac5f9af160bcf0c20426ab3a 100644 (file)
@@ -2101,11 +2101,9 @@ class Heap {
 
   void SelectScavengingVisitorsTable();
 
-  void ReduceNewSpaceSize(bool is_long_idle_notification);
-
   bool TryFinalizeIdleIncrementalMarking(
-      bool is_long_idle_notification, double idle_time_in_ms,
-      size_t size_of_objects, size_t mark_compact_speed_in_bytes_per_ms);
+      double idle_time_in_ms, size_t size_of_objects,
+      size_t mark_compact_speed_in_bytes_per_ms);
 
   void ClearObjectStats(bool clear_last_time_stats = false);