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

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

Issue 662543008: Shrink new space in idle notification. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 6 years, 2 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 | Annotate | Revision Log
« no previous file with comments | « src/heap/heap.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 1552 matching lines...) Expand 10 before | Expand all | Expand 10 after
1563 new_space_.LowerInlineAllocationLimit( 1563 new_space_.LowerInlineAllocationLimit(
1564 new_space_.inline_allocation_limit_step()); 1564 new_space_.inline_allocation_limit_step());
1565 1565
1566 // Update how much has survived scavenge. 1566 // Update how much has survived scavenge.
1567 IncrementYoungSurvivorsCounter(static_cast<int>( 1567 IncrementYoungSurvivorsCounter(static_cast<int>(
1568 (PromotedSpaceSizeOfObjects() - survived_watermark) + new_space_.Size())); 1568 (PromotedSpaceSizeOfObjects() - survived_watermark) + new_space_.Size()));
1569 1569
1570 LOG(isolate_, ResourceEvent("scavenge", "end")); 1570 LOG(isolate_, ResourceEvent("scavenge", "end"));
1571 1571
1572 gc_state_ = NOT_IN_GC; 1572 gc_state_ = NOT_IN_GC;
1573
1574 gc_idle_time_handler_.NotifyScavenge();
1573 } 1575 }
1574 1576
1575 1577
1576 String* Heap::UpdateNewSpaceReferenceInExternalStringTableEntry(Heap* heap, 1578 String* Heap::UpdateNewSpaceReferenceInExternalStringTableEntry(Heap* heap,
1577 Object** p) { 1579 Object** p) {
1578 MapWord first_word = HeapObject::cast(*p)->map_word(); 1580 MapWord first_word = HeapObject::cast(*p)->map_word();
1579 1581
1580 if (!first_word.IsForwardingAddress()) { 1582 if (!first_word.IsForwardingAddress()) {
1581 // Unreachable external string can be finalized. 1583 // Unreachable external string can be finalized.
1582 heap->FinalizeExternalString(String::cast(*p)); 1584 heap->FinalizeExternalString(String::cast(*p));
(...skipping 2711 matching lines...) Expand 10 before | Expand all | Expand 10 after
4294 if (!IsHeapIterable()) { 4296 if (!IsHeapIterable()) {
4295 CollectAllGarbage(kMakeHeapIterableMask, "Heap::MakeHeapIterable"); 4297 CollectAllGarbage(kMakeHeapIterableMask, "Heap::MakeHeapIterable");
4296 } 4298 }
4297 if (mark_compact_collector()->sweeping_in_progress()) { 4299 if (mark_compact_collector()->sweeping_in_progress()) {
4298 mark_compact_collector()->EnsureSweepingCompleted(); 4300 mark_compact_collector()->EnsureSweepingCompleted();
4299 } 4301 }
4300 DCHECK(IsHeapIterable()); 4302 DCHECK(IsHeapIterable());
4301 } 4303 }
4302 4304
4303 4305
4306 void Heap::IdleMarkCompact(const char* message) {
4307 bool uncommit = false;
4308 if (gc_count_at_last_idle_gc_ == gc_count_) {
4309 // No GC since the last full GC, the mutator is probably not active.
4310 isolate_->compilation_cache()->Clear();
4311 uncommit = true;
4312 }
4313 CollectAllGarbage(kReduceMemoryFootprintMask, message);
4314 gc_idle_time_handler_.NotifyIdleMarkCompact();
4315 gc_count_at_last_idle_gc_ = gc_count_;
4316 if (uncommit) {
4317 new_space_.Shrink();
4318 UncommitFromSpace();
4319 }
4320 }
4321
4322
4304 void Heap::TryFinalizeIdleIncrementalMarking( 4323 void Heap::TryFinalizeIdleIncrementalMarking(
4305 size_t idle_time_in_ms, size_t size_of_objects, 4324 size_t idle_time_in_ms, size_t size_of_objects,
4306 size_t mark_compact_speed_in_bytes_per_ms) { 4325 size_t mark_compact_speed_in_bytes_per_ms) {
4307 if (incremental_marking()->IsComplete() || 4326 if (incremental_marking()->IsComplete() ||
4308 (mark_compact_collector()->IsMarkingDequeEmpty() && 4327 (mark_compact_collector()->IsMarkingDequeEmpty() &&
4309 gc_idle_time_handler_.ShouldDoMarkCompact( 4328 gc_idle_time_handler_.ShouldDoMarkCompact(
4310 idle_time_in_ms, size_of_objects, 4329 idle_time_in_ms, size_of_objects,
4311 mark_compact_speed_in_bytes_per_ms))) { 4330 mark_compact_speed_in_bytes_per_ms))) {
4312 bool uncommit = false; 4331 IdleMarkCompact("idle notification: finalize incremental");
4313 if (gc_count_at_last_idle_gc_ == gc_count_) {
4314 // No GC since the last full GC, the mutator is probably not active.
4315 isolate_->compilation_cache()->Clear();
4316 uncommit = true;
4317 }
4318 CollectAllGarbage(kReduceMemoryFootprintMask,
4319 "idle notification: finalize incremental");
4320 gc_idle_time_handler_.NotifyIdleMarkCompact();
4321 gc_count_at_last_idle_gc_ = gc_count_;
4322 if (uncommit) {
4323 new_space_.Shrink();
4324 UncommitFromSpace();
4325 }
4326 } 4332 }
4327 } 4333 }
4328 4334
4329 4335
4330 bool Heap::WorthActivatingIncrementalMarking() { 4336 bool Heap::WorthActivatingIncrementalMarking() {
4331 return incremental_marking()->IsStopped() && 4337 return incremental_marking()->IsStopped() &&
4332 incremental_marking()->WorthActivating() && NextGCIsLikelyToBeFull(); 4338 incremental_marking()->WorthActivating() && NextGCIsLikelyToBeFull();
4333 } 4339 }
4334 4340
4335 4341
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
4385 int remaining_idle_time_in_ms = idle_time_in_ms - actual_time_in_ms; 4391 int remaining_idle_time_in_ms = idle_time_in_ms - actual_time_in_ms;
4386 if (remaining_idle_time_in_ms > 0) { 4392 if (remaining_idle_time_in_ms > 0) {
4387 TryFinalizeIdleIncrementalMarking( 4393 TryFinalizeIdleIncrementalMarking(
4388 remaining_idle_time_in_ms, heap_state.size_of_objects, 4394 remaining_idle_time_in_ms, heap_state.size_of_objects,
4389 heap_state.mark_compact_speed_in_bytes_per_ms); 4395 heap_state.mark_compact_speed_in_bytes_per_ms);
4390 } 4396 }
4391 break; 4397 break;
4392 } 4398 }
4393 case DO_FULL_GC: { 4399 case DO_FULL_GC: {
4394 HistogramTimerScope scope(isolate_->counters()->gc_context()); 4400 HistogramTimerScope scope(isolate_->counters()->gc_context());
4395 const char* message = contexts_disposed_ 4401 if (contexts_disposed_) {
4396 ? "idle notification: contexts disposed" 4402 CollectAllGarbage(kReduceMemoryFootprintMask,
ulan 2014/10/23 15:09:09 First version didn't have this branch and uncondit
4397 : "idle notification: finalize idle round"; 4403 "idle notification: contexts disposed");
4398 CollectAllGarbage(kReduceMemoryFootprintMask, message); 4404 gc_idle_time_handler_.NotifyIdleMarkCompact();
4399 gc_idle_time_handler_.NotifyIdleMarkCompact(); 4405 gc_count_at_last_idle_gc_ = gc_count_;
4406 } else {
4407 IdleMarkCompact("idle notification: finalize idle round");
4408 }
4400 break; 4409 break;
4401 } 4410 }
4402 case DO_SCAVENGE: 4411 case DO_SCAVENGE:
4403 CollectGarbage(NEW_SPACE, "idle notification: scavenge"); 4412 CollectGarbage(NEW_SPACE, "idle notification: scavenge");
4404 break; 4413 break;
4405 case DO_FINALIZE_SWEEPING: 4414 case DO_FINALIZE_SWEEPING:
4406 mark_compact_collector()->EnsureSweepingCompleted(); 4415 mark_compact_collector()->EnsureSweepingCompleted();
4407 break; 4416 break;
4408 case DO_NOTHING: 4417 case DO_NOTHING:
4409 break; 4418 break;
(...skipping 1820 matching lines...) Expand 10 before | Expand all | Expand 10 after
6230 static_cast<int>(object_sizes_last_time_[index])); 6239 static_cast<int>(object_sizes_last_time_[index]));
6231 CODE_AGE_LIST_COMPLETE(ADJUST_LAST_TIME_OBJECT_COUNT) 6240 CODE_AGE_LIST_COMPLETE(ADJUST_LAST_TIME_OBJECT_COUNT)
6232 #undef ADJUST_LAST_TIME_OBJECT_COUNT 6241 #undef ADJUST_LAST_TIME_OBJECT_COUNT
6233 6242
6234 MemCopy(object_counts_last_time_, object_counts_, sizeof(object_counts_)); 6243 MemCopy(object_counts_last_time_, object_counts_, sizeof(object_counts_));
6235 MemCopy(object_sizes_last_time_, object_sizes_, sizeof(object_sizes_)); 6244 MemCopy(object_sizes_last_time_, object_sizes_, sizeof(object_sizes_));
6236 ClearObjectStats(); 6245 ClearObjectStats();
6237 } 6246 }
6238 } 6247 }
6239 } // namespace v8::internal 6248 } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/heap/heap.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698