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

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

Issue 1352453004: Perform scavenge in idle tasks. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 5 years, 3 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/heap/heap.h" 5 #include "src/heap/heap.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 761 matching lines...) Expand 10 before | Expand all | Expand 10 after
772 current_gc_callback_flags_); 772 current_gc_callback_flags_);
773 return; 773 return;
774 } 774 }
775 DCHECK(FLAG_overapproximate_weak_closure); 775 DCHECK(FLAG_overapproximate_weak_closure);
776 if (!incremental_marking()->weak_closure_was_overapproximated()) { 776 if (!incremental_marking()->weak_closure_was_overapproximated()) {
777 OverApproximateWeakClosure("GC interrupt"); 777 OverApproximateWeakClosure("GC interrupt");
778 } 778 }
779 } 779 }
780 780
781 781
782 void Heap::ScheduleIdleScavenge(int bytes_allocated) {
783 scavenge_job_.ScheduleIdleTask(this, bytes_allocated);
784 }
785
786
782 void Heap::OverApproximateWeakClosure(const char* gc_reason) { 787 void Heap::OverApproximateWeakClosure(const char* gc_reason) {
783 if (FLAG_trace_incremental_marking) { 788 if (FLAG_trace_incremental_marking) {
784 PrintF("[IncrementalMarking] Overapproximate weak closure (%s).\n", 789 PrintF("[IncrementalMarking] Overapproximate weak closure (%s).\n",
785 gc_reason); 790 gc_reason);
786 } 791 }
787 792
788 GCTracer::Scope gc_scope(tracer(), 793 GCTracer::Scope gc_scope(tracer(),
789 GCTracer::Scope::MC_INCREMENTAL_WEAKCLOSURE); 794 GCTracer::Scope::MC_INCREMENTAL_WEAKCLOSURE);
790 795
791 { 796 {
(...skipping 3301 matching lines...) Expand 10 before | Expand all | Expand 10 after
4093 4098
4094 4099
4095 GCIdleTimeHandler::HeapState Heap::ComputeHeapState() { 4100 GCIdleTimeHandler::HeapState Heap::ComputeHeapState() {
4096 GCIdleTimeHandler::HeapState heap_state; 4101 GCIdleTimeHandler::HeapState heap_state;
4097 heap_state.contexts_disposed = contexts_disposed_; 4102 heap_state.contexts_disposed = contexts_disposed_;
4098 heap_state.contexts_disposal_rate = 4103 heap_state.contexts_disposal_rate =
4099 tracer()->ContextDisposalRateInMilliseconds(); 4104 tracer()->ContextDisposalRateInMilliseconds();
4100 heap_state.incremental_marking_stopped = incremental_marking()->IsStopped(); 4105 heap_state.incremental_marking_stopped = incremental_marking()->IsStopped();
4101 heap_state.mark_compact_speed_in_bytes_per_ms = 4106 heap_state.mark_compact_speed_in_bytes_per_ms =
4102 static_cast<size_t>(tracer()->MarkCompactSpeedInBytesPerMillisecond()); 4107 static_cast<size_t>(tracer()->MarkCompactSpeedInBytesPerMillisecond());
4103 heap_state.scavenge_speed_in_bytes_per_ms =
4104 static_cast<size_t>(tracer()->ScavengeSpeedInBytesPerMillisecond());
4105 heap_state.used_new_space_size = new_space_.Size();
4106 heap_state.new_space_capacity = new_space_.Capacity();
4107 heap_state.new_space_allocation_throughput_in_bytes_per_ms =
4108 tracer()->NewSpaceAllocationThroughputInBytesPerMillisecond();
4109 return heap_state; 4108 return heap_state;
4110 } 4109 }
4111 4110
4112 4111
4113 double Heap::AdvanceIncrementalMarking( 4112 double Heap::AdvanceIncrementalMarking(
4114 intptr_t step_size_in_bytes, double deadline_in_ms, 4113 intptr_t step_size_in_bytes, double deadline_in_ms,
4115 IncrementalMarking::StepActions step_actions) { 4114 IncrementalMarking::StepActions step_actions) {
4116 DCHECK(!incremental_marking()->IsStopped()); 4115 DCHECK(!incremental_marking()->IsStopped());
4117 4116
4118 if (step_size_in_bytes == 0) { 4117 if (step_size_in_bytes == 0) {
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
4155 IncrementalMarkingJob::IdleTask::kDone; 4154 IncrementalMarkingJob::IdleTask::kDone;
4156 } 4155 }
4157 break; 4156 break;
4158 } 4157 }
4159 case DO_FULL_GC: { 4158 case DO_FULL_GC: {
4160 DCHECK(contexts_disposed_ > 0); 4159 DCHECK(contexts_disposed_ > 0);
4161 HistogramTimerScope scope(isolate_->counters()->gc_context()); 4160 HistogramTimerScope scope(isolate_->counters()->gc_context());
4162 CollectAllGarbage(kNoGCFlags, "idle notification: contexts disposed"); 4161 CollectAllGarbage(kNoGCFlags, "idle notification: contexts disposed");
4163 break; 4162 break;
4164 } 4163 }
4165 case DO_SCAVENGE:
4166 CollectGarbage(NEW_SPACE, "idle notification: scavenge");
4167 break;
4168 case DO_NOTHING: 4164 case DO_NOTHING:
4169 break; 4165 break;
4170 } 4166 }
4171 4167
4172 return result; 4168 return result;
4173 } 4169 }
4174 4170
4175 4171
4176 void Heap::IdleNotificationEpilogue(GCIdleTimeAction action, 4172 void Heap::IdleNotificationEpilogue(GCIdleTimeAction action,
4177 GCIdleTimeHandler::HeapState heap_state, 4173 GCIdleTimeHandler::HeapState heap_state,
(...skipping 806 matching lines...) Expand 10 before | Expand all | Expand 10 after
4984 4980
4985 // Update inline allocation limit for old spaces. 4981 // Update inline allocation limit for old spaces.
4986 PagedSpaces spaces(this); 4982 PagedSpaces spaces(this);
4987 for (PagedSpace* space = spaces.next(); space != NULL; 4983 for (PagedSpace* space = spaces.next(); space != NULL;
4988 space = spaces.next()) { 4984 space = spaces.next()) {
4989 space->EmptyAllocationInfo(); 4985 space->EmptyAllocationInfo();
4990 } 4986 }
4991 } 4987 }
4992 4988
4993 4989
4990 void Heap::LowerInlineAllocationLimit(intptr_t step) {
4991 new_space()->LowerInlineAllocationLimit(step);
4992 }
4993
4994
4995 void Heap::ResetInlineAllocationLimit() {
Hannes Payer (out of office) 2015/09/21 09:00:56 For consistency, you have to call this method also
ulan 2015/09/23 09:58:38 Yup, I call it in Heap::SetUp below (line 5100)
Hannes Payer (out of office) 2015/09/23 14:16:39 Acknowledged.
4996 new_space()->LowerInlineAllocationLimit(
4997 ScavengeJob::kBytesAllocatedBeforeNextIdleTask);
4998 }
4999
5000
4994 V8_DECLARE_ONCE(initialize_gc_once); 5001 V8_DECLARE_ONCE(initialize_gc_once);
4995 5002
4996 static void InitializeGCOnce() { 5003 static void InitializeGCOnce() {
4997 Scavenger::Initialize(); 5004 Scavenger::Initialize();
4998 StaticScavengeVisitor::Initialize(); 5005 StaticScavengeVisitor::Initialize();
4999 MarkCompactCollector::Initialize(); 5006 MarkCompactCollector::Initialize();
5000 } 5007 }
5001 5008
5002 5009
5003 bool Heap::SetUp() { 5010 bool Heap::SetUp() {
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
5083 5090
5084 array_buffer_tracker_ = new ArrayBufferTracker(this); 5091 array_buffer_tracker_ = new ArrayBufferTracker(this);
5085 5092
5086 LOG(isolate_, IntPtrTEvent("heap-capacity", Capacity())); 5093 LOG(isolate_, IntPtrTEvent("heap-capacity", Capacity()));
5087 LOG(isolate_, IntPtrTEvent("heap-available", Available())); 5094 LOG(isolate_, IntPtrTEvent("heap-available", Available()));
5088 5095
5089 store_buffer()->SetUp(); 5096 store_buffer()->SetUp();
5090 5097
5091 mark_compact_collector()->SetUp(); 5098 mark_compact_collector()->SetUp();
5092 5099
5100 ResetInlineAllocationLimit();
5101
5093 return true; 5102 return true;
5094 } 5103 }
5095 5104
5096 5105
5097 bool Heap::CreateHeapObjects() { 5106 bool Heap::CreateHeapObjects() {
5098 // Create initial maps. 5107 // Create initial maps.
5099 if (!CreateInitialMaps()) return false; 5108 if (!CreateInitialMaps()) return false;
5100 CreateApiObjects(); 5109 CreateApiObjects();
5101 5110
5102 // Create initial objects 5111 // Create initial objects
(...skipping 1002 matching lines...) Expand 10 before | Expand all | Expand 10 after
6105 } 6114 }
6106 6115
6107 6116
6108 // static 6117 // static
6109 int Heap::GetStaticVisitorIdForMap(Map* map) { 6118 int Heap::GetStaticVisitorIdForMap(Map* map) {
6110 return StaticVisitorBase::GetVisitorId(map); 6119 return StaticVisitorBase::GetVisitorId(map);
6111 } 6120 }
6112 6121
6113 } // namespace internal 6122 } // namespace internal
6114 } // namespace v8 6123 } // namespace v8
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698