Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(48)

Side by Side Diff: src/heap/heap.cc

Issue 1072363002: Make full GC reduce memory footprint an explicit event in the idle notification handler. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 5 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2012 the V8 project authors. All rights reserved. 1 // Copyright 2012 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "src/v8.h" 5 #include "src/v8.h"
6 6
7 #include "src/accessors.h" 7 #include "src/accessors.h"
8 #include "src/api.h" 8 #include "src/api.h"
9 #include "src/base/bits.h" 9 #include "src/base/bits.h"
10 #include "src/base/once.h" 10 #include "src/base/once.h"
(...skipping 4515 matching lines...) Expand 10 before | Expand all | Expand 10 after
4526 if (!IsHeapIterable()) { 4526 if (!IsHeapIterable()) {
4527 CollectAllGarbage(kMakeHeapIterableMask, "Heap::MakeHeapIterable"); 4527 CollectAllGarbage(kMakeHeapIterableMask, "Heap::MakeHeapIterable");
4528 } 4528 }
4529 if (mark_compact_collector()->sweeping_in_progress()) { 4529 if (mark_compact_collector()->sweeping_in_progress()) {
4530 mark_compact_collector()->EnsureSweepingCompleted(); 4530 mark_compact_collector()->EnsureSweepingCompleted();
4531 } 4531 }
4532 DCHECK(IsHeapIterable()); 4532 DCHECK(IsHeapIterable());
4533 } 4533 }
4534 4534
4535 4535
4536 void Heap::IdleMarkCompact(const char* message) { 4536 void Heap::IdleMarkCompact(bool reduce_memory, const char* message) {
4537 bool uncommit = false; 4537 bool uncommit = false;
4538 if (gc_count_at_last_idle_gc_ == gc_count_) { 4538 if (gc_count_at_last_idle_gc_ == gc_count_) {
4539 // No GC since the last full GC, the mutator is probably not active. 4539 // No GC since the last full GC, the mutator is probably not active.
4540 isolate_->compilation_cache()->Clear(); 4540 isolate_->compilation_cache()->Clear();
4541 uncommit = true; 4541 uncommit = true;
4542 } 4542 }
4543 CollectAllGarbage(kReduceMemoryFootprintMask, message); 4543 int flags = reduce_memory ? kReduceMemoryFootprintMask : kNoGCFlags;
4544 CollectAllGarbage(flags, message);
4544 gc_idle_time_handler_.NotifyIdleMarkCompact(); 4545 gc_idle_time_handler_.NotifyIdleMarkCompact();
4545 gc_count_at_last_idle_gc_ = gc_count_; 4546 gc_count_at_last_idle_gc_ = gc_count_;
4546 if (uncommit) { 4547 if (uncommit) {
4547 new_space_.Shrink(); 4548 new_space_.Shrink();
4548 UncommitFromSpace(); 4549 UncommitFromSpace();
4549 } 4550 }
4550 } 4551 }
4551 4552
4552 4553
4553 bool Heap::TryFinalizeIdleIncrementalMarking( 4554 bool Heap::TryFinalizeIdleIncrementalMarking(
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after
4665 } 4666 }
4666 break; 4667 break;
4667 } 4668 }
4668 case DO_FULL_GC: { 4669 case DO_FULL_GC: {
4669 if (contexts_disposed_) { 4670 if (contexts_disposed_) {
4670 HistogramTimerScope scope(isolate_->counters()->gc_context()); 4671 HistogramTimerScope scope(isolate_->counters()->gc_context());
4671 CollectAllGarbage(kNoGCFlags, "idle notification: contexts disposed"); 4672 CollectAllGarbage(kNoGCFlags, "idle notification: contexts disposed");
4672 gc_idle_time_handler_.NotifyIdleMarkCompact(); 4673 gc_idle_time_handler_.NotifyIdleMarkCompact();
4673 gc_count_at_last_idle_gc_ = gc_count_; 4674 gc_count_at_last_idle_gc_ = gc_count_;
4674 } else { 4675 } else {
4675 IdleMarkCompact("idle notification: finalize idle round"); 4676 IdleMarkCompact(false, "idle notification: finalize idle round");
4676 } 4677 }
4677 break; 4678 break;
4678 } 4679 }
4680 case DO_FULL_GC_COMPACT: {
4681 IdleMarkCompact(true, "idle notification: reduce memory footprint");
4682 break;
4683 }
4679 case DO_SCAVENGE: 4684 case DO_SCAVENGE:
4680 CollectGarbage(NEW_SPACE, "idle notification: scavenge"); 4685 CollectGarbage(NEW_SPACE, "idle notification: scavenge");
4681 break; 4686 break;
4682 case DO_FINALIZE_SWEEPING: 4687 case DO_FINALIZE_SWEEPING:
4683 mark_compact_collector()->EnsureSweepingCompleted(); 4688 mark_compact_collector()->EnsureSweepingCompleted();
4684 break; 4689 break;
4685 case DO_NOTHING: 4690 case DO_NOTHING:
4686 break; 4691 break;
4687 } 4692 }
4688 4693
(...skipping 1676 matching lines...) Expand 10 before | Expand all | Expand 10 after
6365 static_cast<int>(object_sizes_last_time_[index])); 6370 static_cast<int>(object_sizes_last_time_[index]));
6366 CODE_AGE_LIST_COMPLETE(ADJUST_LAST_TIME_OBJECT_COUNT) 6371 CODE_AGE_LIST_COMPLETE(ADJUST_LAST_TIME_OBJECT_COUNT)
6367 #undef ADJUST_LAST_TIME_OBJECT_COUNT 6372 #undef ADJUST_LAST_TIME_OBJECT_COUNT
6368 6373
6369 MemCopy(object_counts_last_time_, object_counts_, sizeof(object_counts_)); 6374 MemCopy(object_counts_last_time_, object_counts_, sizeof(object_counts_));
6370 MemCopy(object_sizes_last_time_, object_sizes_, sizeof(object_sizes_)); 6375 MemCopy(object_sizes_last_time_, object_sizes_, sizeof(object_sizes_));
6371 ClearObjectStats(); 6376 ClearObjectStats();
6372 } 6377 }
6373 } 6378 }
6374 } // namespace v8::internal 6379 } // namespace v8::internal
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698