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

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: Make new heap functions private Created 5 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
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"
11 #include "src/base/utils/random-number-generator.h" 11 #include "src/base/utils/random-number-generator.h"
12 #include "src/bootstrapper.h" 12 #include "src/bootstrapper.h"
13 #include "src/codegen.h" 13 #include "src/codegen.h"
14 #include "src/compilation-cache.h" 14 #include "src/compilation-cache.h"
15 #include "src/conversions.h" 15 #include "src/conversions.h"
16 #include "src/cpu-profiler.h" 16 #include "src/cpu-profiler.h"
17 #include "src/debug/debug.h" 17 #include "src/debug/debug.h"
18 #include "src/deoptimizer.h" 18 #include "src/deoptimizer.h"
19 #include "src/global-handles.h" 19 #include "src/global-handles.h"
20 #include "src/heap/array-buffer-tracker.h" 20 #include "src/heap/array-buffer-tracker.h"
21 #include "src/heap/gc-idle-time-handler.h" 21 #include "src/heap/gc-idle-time-handler.h"
22 #include "src/heap/gc-tracer.h" 22 #include "src/heap/gc-tracer.h"
23 #include "src/heap/incremental-marking.h" 23 #include "src/heap/incremental-marking.h"
24 #include "src/heap/mark-compact-inl.h" 24 #include "src/heap/mark-compact-inl.h"
25 #include "src/heap/mark-compact.h" 25 #include "src/heap/mark-compact.h"
26 #include "src/heap/memory-reducer.h" 26 #include "src/heap/memory-reducer.h"
27 #include "src/heap/object-stats.h" 27 #include "src/heap/object-stats.h"
28 #include "src/heap/objects-visiting-inl.h" 28 #include "src/heap/objects-visiting-inl.h"
29 #include "src/heap/objects-visiting.h" 29 #include "src/heap/objects-visiting.h"
30 #include "src/heap/scavenge-job.h"
30 #include "src/heap/scavenger-inl.h" 31 #include "src/heap/scavenger-inl.h"
31 #include "src/heap/store-buffer.h" 32 #include "src/heap/store-buffer.h"
32 #include "src/heap-profiler.h" 33 #include "src/heap-profiler.h"
33 #include "src/interpreter/interpreter.h" 34 #include "src/interpreter/interpreter.h"
34 #include "src/runtime-profiler.h" 35 #include "src/runtime-profiler.h"
35 #include "src/scopeinfo.h" 36 #include "src/scopeinfo.h"
36 #include "src/snapshot/natives.h" 37 #include "src/snapshot/natives.h"
37 #include "src/snapshot/serialize.h" 38 #include "src/snapshot/serialize.h"
38 #include "src/snapshot/snapshot.h" 39 #include "src/snapshot/snapshot.h"
39 #include "src/type-feedback-vector.h" 40 #include "src/type-feedback-vector.h"
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
120 marking_time_(0.0), 121 marking_time_(0.0),
121 sweeping_time_(0.0), 122 sweeping_time_(0.0),
122 last_idle_notification_time_(0.0), 123 last_idle_notification_time_(0.0),
123 last_gc_time_(0.0), 124 last_gc_time_(0.0),
124 scavenge_collector_(nullptr), 125 scavenge_collector_(nullptr),
125 mark_compact_collector_(this), 126 mark_compact_collector_(this),
126 store_buffer_(this), 127 store_buffer_(this),
127 incremental_marking_(this), 128 incremental_marking_(this),
128 memory_reducer_(nullptr), 129 memory_reducer_(nullptr),
129 object_stats_(nullptr), 130 object_stats_(nullptr),
131 scavenge_job_(nullptr),
130 full_codegen_bytes_generated_(0), 132 full_codegen_bytes_generated_(0),
131 crankshaft_codegen_bytes_generated_(0), 133 crankshaft_codegen_bytes_generated_(0),
132 new_space_allocation_counter_(0), 134 new_space_allocation_counter_(0),
133 old_generation_allocation_counter_(0), 135 old_generation_allocation_counter_(0),
134 old_generation_size_at_last_gc_(0), 136 old_generation_size_at_last_gc_(0),
135 gcs_since_last_deopt_(0), 137 gcs_since_last_deopt_(0),
136 allocation_sites_scratchpad_length_(0), 138 allocation_sites_scratchpad_length_(0),
137 ring_buffer_full_(false), 139 ring_buffer_full_(false),
138 ring_buffer_end_(0), 140 ring_buffer_end_(0),
139 promotion_queue_(this), 141 promotion_queue_(this),
(...skipping 632 matching lines...) Expand 10 before | Expand all | Expand 10 after
772 current_gc_callback_flags_); 774 current_gc_callback_flags_);
773 return; 775 return;
774 } 776 }
775 DCHECK(FLAG_overapproximate_weak_closure); 777 DCHECK(FLAG_overapproximate_weak_closure);
776 if (!incremental_marking()->weak_closure_was_overapproximated()) { 778 if (!incremental_marking()->weak_closure_was_overapproximated()) {
777 OverApproximateWeakClosure("GC interrupt"); 779 OverApproximateWeakClosure("GC interrupt");
778 } 780 }
779 } 781 }
780 782
781 783
784 void Heap::ScheduleIdleScavengeIfNeeded(int bytes_allocated) {
785 scavenge_job_->ScheduleIdleTaskIfNeeded(this, bytes_allocated);
786 }
787
788
782 void Heap::OverApproximateWeakClosure(const char* gc_reason) { 789 void Heap::OverApproximateWeakClosure(const char* gc_reason) {
783 if (FLAG_trace_incremental_marking) { 790 if (FLAG_trace_incremental_marking) {
784 PrintF("[IncrementalMarking] Overapproximate weak closure (%s).\n", 791 PrintF("[IncrementalMarking] Overapproximate weak closure (%s).\n",
785 gc_reason); 792 gc_reason);
786 } 793 }
787 794
788 GCTracer::Scope gc_scope(tracer(), 795 GCTracer::Scope gc_scope(tracer(),
789 GCTracer::Scope::MC_INCREMENTAL_WEAKCLOSURE); 796 GCTracer::Scope::MC_INCREMENTAL_WEAKCLOSURE);
790 797
791 { 798 {
(...skipping 3301 matching lines...) Expand 10 before | Expand all | Expand 10 after
4093 4100
4094 4101
4095 GCIdleTimeHandler::HeapState Heap::ComputeHeapState() { 4102 GCIdleTimeHandler::HeapState Heap::ComputeHeapState() {
4096 GCIdleTimeHandler::HeapState heap_state; 4103 GCIdleTimeHandler::HeapState heap_state;
4097 heap_state.contexts_disposed = contexts_disposed_; 4104 heap_state.contexts_disposed = contexts_disposed_;
4098 heap_state.contexts_disposal_rate = 4105 heap_state.contexts_disposal_rate =
4099 tracer()->ContextDisposalRateInMilliseconds(); 4106 tracer()->ContextDisposalRateInMilliseconds();
4100 heap_state.incremental_marking_stopped = incremental_marking()->IsStopped(); 4107 heap_state.incremental_marking_stopped = incremental_marking()->IsStopped();
4101 heap_state.mark_compact_speed_in_bytes_per_ms = 4108 heap_state.mark_compact_speed_in_bytes_per_ms =
4102 static_cast<size_t>(tracer()->MarkCompactSpeedInBytesPerMillisecond()); 4109 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; 4110 return heap_state;
4110 } 4111 }
4111 4112
4112 4113
4113 double Heap::AdvanceIncrementalMarking( 4114 double Heap::AdvanceIncrementalMarking(
4114 intptr_t step_size_in_bytes, double deadline_in_ms, 4115 intptr_t step_size_in_bytes, double deadline_in_ms,
4115 IncrementalMarking::StepActions step_actions) { 4116 IncrementalMarking::StepActions step_actions) {
4116 DCHECK(!incremental_marking()->IsStopped()); 4117 DCHECK(!incremental_marking()->IsStopped());
4117 4118
4118 if (step_size_in_bytes == 0) { 4119 if (step_size_in_bytes == 0) {
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
4155 IncrementalMarkingJob::IdleTask::kDone; 4156 IncrementalMarkingJob::IdleTask::kDone;
4156 } 4157 }
4157 break; 4158 break;
4158 } 4159 }
4159 case DO_FULL_GC: { 4160 case DO_FULL_GC: {
4160 DCHECK(contexts_disposed_ > 0); 4161 DCHECK(contexts_disposed_ > 0);
4161 HistogramTimerScope scope(isolate_->counters()->gc_context()); 4162 HistogramTimerScope scope(isolate_->counters()->gc_context());
4162 CollectAllGarbage(kNoGCFlags, "idle notification: contexts disposed"); 4163 CollectAllGarbage(kNoGCFlags, "idle notification: contexts disposed");
4163 break; 4164 break;
4164 } 4165 }
4165 case DO_SCAVENGE:
4166 CollectGarbage(NEW_SPACE, "idle notification: scavenge");
4167 break;
4168 case DO_NOTHING: 4166 case DO_NOTHING:
4169 break; 4167 break;
4170 } 4168 }
4171 4169
4172 return result; 4170 return result;
4173 } 4171 }
4174 4172
4175 4173
4176 void Heap::IdleNotificationEpilogue(GCIdleTimeAction action, 4174 void Heap::IdleNotificationEpilogue(GCIdleTimeAction action,
4177 GCIdleTimeHandler::HeapState heap_state, 4175 GCIdleTimeHandler::HeapState heap_state,
(...skipping 806 matching lines...) Expand 10 before | Expand all | Expand 10 after
4984 4982
4985 // Update inline allocation limit for old spaces. 4983 // Update inline allocation limit for old spaces.
4986 PagedSpaces spaces(this); 4984 PagedSpaces spaces(this);
4987 for (PagedSpace* space = spaces.next(); space != NULL; 4985 for (PagedSpace* space = spaces.next(); space != NULL;
4988 space = spaces.next()) { 4986 space = spaces.next()) {
4989 space->EmptyAllocationInfo(); 4987 space->EmptyAllocationInfo();
4990 } 4988 }
4991 } 4989 }
4992 4990
4993 4991
4992 void Heap::LowerInlineAllocationLimit(intptr_t step) {
4993 new_space()->LowerInlineAllocationLimit(step);
4994 }
4995
4996
4997 void Heap::ResetInlineAllocationLimit() {
4998 new_space()->LowerInlineAllocationLimit(
4999 ScavengeJob::kBytesAllocatedBeforeNextIdleTask);
5000 }
5001
5002
4994 V8_DECLARE_ONCE(initialize_gc_once); 5003 V8_DECLARE_ONCE(initialize_gc_once);
4995 5004
4996 static void InitializeGCOnce() { 5005 static void InitializeGCOnce() {
4997 Scavenger::Initialize(); 5006 Scavenger::Initialize();
4998 StaticScavengeVisitor::Initialize(); 5007 StaticScavengeVisitor::Initialize();
4999 MarkCompactCollector::Initialize(); 5008 MarkCompactCollector::Initialize();
5000 } 5009 }
5001 5010
5002 5011
5003 bool Heap::SetUp() { 5012 bool Heap::SetUp() {
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
5074 5083
5075 tracer_ = new GCTracer(this); 5084 tracer_ = new GCTracer(this);
5076 5085
5077 scavenge_collector_ = new Scavenger(this); 5086 scavenge_collector_ = new Scavenger(this);
5078 5087
5079 memory_reducer_ = new MemoryReducer(this); 5088 memory_reducer_ = new MemoryReducer(this);
5080 5089
5081 object_stats_ = new ObjectStats(this); 5090 object_stats_ = new ObjectStats(this);
5082 object_stats_->ClearObjectStats(true); 5091 object_stats_->ClearObjectStats(true);
5083 5092
5093 scavenge_job_ = new ScavengeJob();
5094
5084 array_buffer_tracker_ = new ArrayBufferTracker(this); 5095 array_buffer_tracker_ = new ArrayBufferTracker(this);
5085 5096
5086 LOG(isolate_, IntPtrTEvent("heap-capacity", Capacity())); 5097 LOG(isolate_, IntPtrTEvent("heap-capacity", Capacity()));
5087 LOG(isolate_, IntPtrTEvent("heap-available", Available())); 5098 LOG(isolate_, IntPtrTEvent("heap-available", Available()));
5088 5099
5089 store_buffer()->SetUp(); 5100 store_buffer()->SetUp();
5090 5101
5091 mark_compact_collector()->SetUp(); 5102 mark_compact_collector()->SetUp();
5092 5103
5104 ResetInlineAllocationLimit();
5105
5093 return true; 5106 return true;
5094 } 5107 }
5095 5108
5096 5109
5097 bool Heap::CreateHeapObjects() { 5110 bool Heap::CreateHeapObjects() {
5098 // Create initial maps. 5111 // Create initial maps.
5099 if (!CreateInitialMaps()) return false; 5112 if (!CreateInitialMaps()) return false;
5100 CreateApiObjects(); 5113 CreateApiObjects();
5101 5114
5102 // Create initial objects 5115 // Create initial objects
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after
5192 5205
5193 if (memory_reducer_ != nullptr) { 5206 if (memory_reducer_ != nullptr) {
5194 memory_reducer_->TearDown(); 5207 memory_reducer_->TearDown();
5195 delete memory_reducer_; 5208 delete memory_reducer_;
5196 memory_reducer_ = nullptr; 5209 memory_reducer_ = nullptr;
5197 } 5210 }
5198 5211
5199 delete object_stats_; 5212 delete object_stats_;
5200 object_stats_ = nullptr; 5213 object_stats_ = nullptr;
5201 5214
5215 delete scavenge_job_;
5216 scavenge_job_ = nullptr;
5217
5202 WaitUntilUnmappingOfFreeChunksCompleted(); 5218 WaitUntilUnmappingOfFreeChunksCompleted();
5203 5219
5204 delete array_buffer_tracker_; 5220 delete array_buffer_tracker_;
5205 array_buffer_tracker_ = nullptr; 5221 array_buffer_tracker_ = nullptr;
5206 5222
5207 isolate_->global_handles()->TearDown(); 5223 isolate_->global_handles()->TearDown();
5208 5224
5209 external_string_table_.TearDown(); 5225 external_string_table_.TearDown();
5210 5226
5211 mark_compact_collector()->TearDown(); 5227 mark_compact_collector()->TearDown();
(...skipping 893 matching lines...) Expand 10 before | Expand all | Expand 10 after
6105 } 6121 }
6106 6122
6107 6123
6108 // static 6124 // static
6109 int Heap::GetStaticVisitorIdForMap(Map* map) { 6125 int Heap::GetStaticVisitorIdForMap(Map* map) {
6110 return StaticVisitorBase::GetVisitorId(map); 6126 return StaticVisitorBase::GetVisitorId(map);
6111 } 6127 }
6112 6128
6113 } // namespace internal 6129 } // namespace internal
6114 } // namespace v8 6130 } // namespace v8
OLDNEW
« src/heap/heap.h ('K') | « src/heap/heap.h ('k') | src/heap/incremental-marking.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698