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

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

Issue 629903003: Check if there is still time before finalizing an incremental collection. (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') | src/heap/incremental-marking.h » ('j') | 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 4249 matching lines...) Expand 10 before | Expand all | Expand 10 after
4260 if (!IsHeapIterable()) { 4260 if (!IsHeapIterable()) {
4261 CollectAllGarbage(kMakeHeapIterableMask, "Heap::MakeHeapIterable"); 4261 CollectAllGarbage(kMakeHeapIterableMask, "Heap::MakeHeapIterable");
4262 } 4262 }
4263 if (mark_compact_collector()->sweeping_in_progress()) { 4263 if (mark_compact_collector()->sweeping_in_progress()) {
4264 mark_compact_collector()->EnsureSweepingCompleted(); 4264 mark_compact_collector()->EnsureSweepingCompleted();
4265 } 4265 }
4266 DCHECK(IsHeapIterable()); 4266 DCHECK(IsHeapIterable());
4267 } 4267 }
4268 4268
4269 4269
4270 void Heap::AdvanceIdleIncrementalMarking(intptr_t step_size) { 4270 void Heap::TryFinalizeIdleIncrementalMarking(
4271 incremental_marking()->Step(step_size, 4271 size_t idle_time_in_ms, size_t size_of_objects,
4272 IncrementalMarking::NO_GC_VIA_STACK_GUARD, true); 4272 size_t mark_compact_speed_in_bytes_per_ms) {
4273 4273 if (incremental_marking()->IsComplete() ||
4274 if (incremental_marking()->IsComplete()) { 4274 (mark_compact_collector()->IsMarkingDequeEmpty() &&
4275 gc_idle_time_handler_.ShouldDoMarkCompact(
4276 idle_time_in_ms, size_of_objects,
4277 mark_compact_speed_in_bytes_per_ms))) {
4275 bool uncommit = false; 4278 bool uncommit = false;
4276 if (gc_count_at_last_idle_gc_ == gc_count_) { 4279 if (gc_count_at_last_idle_gc_ == gc_count_) {
4277 // No GC since the last full GC, the mutator is probably not active. 4280 // No GC since the last full GC, the mutator is probably not active.
4278 isolate_->compilation_cache()->Clear(); 4281 isolate_->compilation_cache()->Clear();
4279 uncommit = true; 4282 uncommit = true;
4280 } 4283 }
4281 CollectAllGarbage(kReduceMemoryFootprintMask, 4284 CollectAllGarbage(kReduceMemoryFootprintMask,
4282 "idle notification: finalize incremental"); 4285 "idle notification: finalize incremental");
4283 gc_idle_time_handler_.NotifyIdleMarkCompact(); 4286 gc_idle_time_handler_.NotifyIdleMarkCompact();
4284 gc_count_at_last_idle_gc_ = gc_count_; 4287 gc_count_at_last_idle_gc_ = gc_count_;
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
4324 heap_state.used_new_space_size = new_space_.Size(); 4327 heap_state.used_new_space_size = new_space_.Size();
4325 heap_state.new_space_capacity = new_space_.Capacity(); 4328 heap_state.new_space_capacity = new_space_.Capacity();
4326 heap_state.new_space_allocation_throughput_in_bytes_per_ms = 4329 heap_state.new_space_allocation_throughput_in_bytes_per_ms =
4327 static_cast<size_t>( 4330 static_cast<size_t>(
4328 tracer()->NewSpaceAllocationThroughputInBytesPerMillisecond()); 4331 tracer()->NewSpaceAllocationThroughputInBytesPerMillisecond());
4329 4332
4330 GCIdleTimeAction action = 4333 GCIdleTimeAction action =
4331 gc_idle_time_handler_.Compute(idle_time_in_ms, heap_state); 4334 gc_idle_time_handler_.Compute(idle_time_in_ms, heap_state);
4332 4335
4333 bool result = false; 4336 bool result = false;
4337 int actual_time_in_ms = 0;
4334 switch (action.type) { 4338 switch (action.type) {
4335 case DONE: 4339 case DONE:
4336 result = true; 4340 result = true;
4337 break; 4341 break;
4338 case DO_INCREMENTAL_MARKING: 4342 case DO_INCREMENTAL_MARKING: {
4339 if (incremental_marking()->IsStopped()) { 4343 if (incremental_marking()->IsStopped()) {
4340 incremental_marking()->Start(); 4344 incremental_marking()->Start();
4341 } 4345 }
4342 AdvanceIdleIncrementalMarking(action.parameter); 4346 incremental_marking()->Step(action.parameter,
4347 IncrementalMarking::NO_GC_VIA_STACK_GUARD,
4348 IncrementalMarking::FORCE_MARKING,
4349 IncrementalMarking::DO_NOT_FORCE_COMPLETION);
4350 actual_time_in_ms = static_cast<int>(timer.Elapsed().InMilliseconds());
4351 int remaining_idle_time_in_ms = idle_time_in_ms - actual_time_in_ms;
4352 if (remaining_idle_time_in_ms > 0) {
4353 TryFinalizeIdleIncrementalMarking(
4354 remaining_idle_time_in_ms, heap_state.size_of_objects,
4355 heap_state.mark_compact_speed_in_bytes_per_ms);
4356 }
4343 break; 4357 break;
4358 }
4344 case DO_FULL_GC: { 4359 case DO_FULL_GC: {
4345 HistogramTimerScope scope(isolate_->counters()->gc_context()); 4360 HistogramTimerScope scope(isolate_->counters()->gc_context());
4346 const char* message = contexts_disposed_ 4361 const char* message = contexts_disposed_
4347 ? "idle notification: contexts disposed" 4362 ? "idle notification: contexts disposed"
4348 : "idle notification: finalize idle round"; 4363 : "idle notification: finalize idle round";
4349 CollectAllGarbage(kReduceMemoryFootprintMask, message); 4364 CollectAllGarbage(kReduceMemoryFootprintMask, message);
4350 gc_idle_time_handler_.NotifyIdleMarkCompact(); 4365 gc_idle_time_handler_.NotifyIdleMarkCompact();
4351 break; 4366 break;
4352 } 4367 }
4353 case DO_SCAVENGE: 4368 case DO_SCAVENGE:
4354 CollectGarbage(NEW_SPACE, "idle notification: scavenge"); 4369 CollectGarbage(NEW_SPACE, "idle notification: scavenge");
4355 break; 4370 break;
4356 case DO_FINALIZE_SWEEPING: 4371 case DO_FINALIZE_SWEEPING:
4357 mark_compact_collector()->EnsureSweepingCompleted(); 4372 mark_compact_collector()->EnsureSweepingCompleted();
4358 break; 4373 break;
4359 case DO_NOTHING: 4374 case DO_NOTHING:
4360 break; 4375 break;
4361 } 4376 }
4362 4377
4363 int actual_time_ms = static_cast<int>(timer.Elapsed().InMilliseconds()); 4378 actual_time_in_ms = static_cast<int>(timer.Elapsed().InMilliseconds());
4364 if (actual_time_ms <= idle_time_in_ms) { 4379 if (actual_time_in_ms <= idle_time_in_ms) {
4365 if (action.type != DONE && action.type != DO_NOTHING) { 4380 if (action.type != DONE && action.type != DO_NOTHING) {
4366 isolate()->counters()->gc_idle_time_limit_undershot()->AddSample( 4381 isolate()->counters()->gc_idle_time_limit_undershot()->AddSample(
4367 idle_time_in_ms - actual_time_ms); 4382 idle_time_in_ms - actual_time_in_ms);
4368 } 4383 }
4369 } else { 4384 } else {
4370 isolate()->counters()->gc_idle_time_limit_overshot()->AddSample( 4385 isolate()->counters()->gc_idle_time_limit_overshot()->AddSample(
4371 actual_time_ms - idle_time_in_ms); 4386 actual_time_in_ms - idle_time_in_ms);
4372 } 4387 }
4373 4388
4374 if (FLAG_trace_idle_notification) { 4389 if (FLAG_trace_idle_notification) {
4375 PrintF("Idle notification: requested idle time %d ms, actual time %d ms [", 4390 PrintF("Idle notification: requested idle time %d ms, actual time %d ms [",
4376 idle_time_in_ms, actual_time_ms); 4391 idle_time_in_ms, actual_time_in_ms);
4377 action.Print(); 4392 action.Print();
4378 PrintF("]\n"); 4393 PrintF("]\n");
4379 } 4394 }
4380 4395
4381 contexts_disposed_ = 0; 4396 contexts_disposed_ = 0;
4382 return result; 4397 return result;
4383 } 4398 }
4384 4399
4385 4400
4386 #ifdef DEBUG 4401 #ifdef DEBUG
(...skipping 1766 matching lines...) Expand 10 before | Expand all | Expand 10 after
6153 static_cast<int>(object_sizes_last_time_[index])); 6168 static_cast<int>(object_sizes_last_time_[index]));
6154 CODE_AGE_LIST_COMPLETE(ADJUST_LAST_TIME_OBJECT_COUNT) 6169 CODE_AGE_LIST_COMPLETE(ADJUST_LAST_TIME_OBJECT_COUNT)
6155 #undef ADJUST_LAST_TIME_OBJECT_COUNT 6170 #undef ADJUST_LAST_TIME_OBJECT_COUNT
6156 6171
6157 MemCopy(object_counts_last_time_, object_counts_, sizeof(object_counts_)); 6172 MemCopy(object_counts_last_time_, object_counts_, sizeof(object_counts_));
6158 MemCopy(object_sizes_last_time_, object_sizes_, sizeof(object_sizes_)); 6173 MemCopy(object_sizes_last_time_, object_sizes_, sizeof(object_sizes_));
6159 ClearObjectStats(); 6174 ClearObjectStats();
6160 } 6175 }
6161 } 6176 }
6162 } // namespace v8::internal 6177 } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/heap/heap.h ('k') | src/heap/incremental-marking.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698