OLD | NEW |
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 4189 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4200 if (FLAG_trace_idle_notification_verbose) { | 4200 if (FLAG_trace_idle_notification_verbose) { |
4201 PrintF("["); | 4201 PrintF("["); |
4202 heap_state.Print(); | 4202 heap_state.Print(); |
4203 PrintF("]"); | 4203 PrintF("]"); |
4204 } | 4204 } |
4205 PrintF("\n"); | 4205 PrintF("\n"); |
4206 } | 4206 } |
4207 } | 4207 } |
4208 | 4208 |
4209 | 4209 |
4210 void Heap::CheckAndNotifyBackgroundIdleNotification(double idle_time_in_ms, | 4210 void Heap::CheckBackgroundIdleNotification(double idle_time_in_ms, |
4211 double now_ms) { | 4211 double now_ms) { |
| 4212 // TODO(ulan): Remove this function once Chrome uses new API |
| 4213 // for foreground/background notification. |
4212 if (idle_time_in_ms >= GCIdleTimeHandler::kMinBackgroundIdleTime) { | 4214 if (idle_time_in_ms >= GCIdleTimeHandler::kMinBackgroundIdleTime) { |
4213 MemoryReducer::Event event; | |
4214 event.type = MemoryReducer::kBackgroundIdleNotification; | |
4215 event.time_ms = now_ms; | |
4216 event.can_start_incremental_gc = incremental_marking()->IsStopped() && | |
4217 incremental_marking()->CanBeActivated(); | |
4218 memory_reducer_->NotifyBackgroundIdleNotification(event); | |
4219 optimize_for_memory_usage_ = true; | 4215 optimize_for_memory_usage_ = true; |
4220 } else { | 4216 } else { |
4221 optimize_for_memory_usage_ = false; | 4217 optimize_for_memory_usage_ = false; |
4222 } | 4218 } |
4223 } | 4219 } |
4224 | 4220 |
4225 | 4221 |
4226 double Heap::MonotonicallyIncreasingTimeInMs() { | 4222 double Heap::MonotonicallyIncreasingTimeInMs() { |
4227 return V8::GetCurrentPlatform()->MonotonicallyIncreasingTime() * | 4223 return V8::GetCurrentPlatform()->MonotonicallyIncreasingTime() * |
4228 static_cast<double>(base::Time::kMillisecondsPerSecond); | 4224 static_cast<double>(base::Time::kMillisecondsPerSecond); |
(...skipping 11 matching lines...) Expand all Loading... |
4240 bool Heap::IdleNotification(double deadline_in_seconds) { | 4236 bool Heap::IdleNotification(double deadline_in_seconds) { |
4241 CHECK(HasBeenSetUp()); | 4237 CHECK(HasBeenSetUp()); |
4242 double deadline_in_ms = | 4238 double deadline_in_ms = |
4243 deadline_in_seconds * | 4239 deadline_in_seconds * |
4244 static_cast<double>(base::Time::kMillisecondsPerSecond); | 4240 static_cast<double>(base::Time::kMillisecondsPerSecond); |
4245 HistogramTimerScope idle_notification_scope( | 4241 HistogramTimerScope idle_notification_scope( |
4246 isolate_->counters()->gc_idle_notification()); | 4242 isolate_->counters()->gc_idle_notification()); |
4247 double start_ms = MonotonicallyIncreasingTimeInMs(); | 4243 double start_ms = MonotonicallyIncreasingTimeInMs(); |
4248 double idle_time_in_ms = deadline_in_ms - start_ms; | 4244 double idle_time_in_ms = deadline_in_ms - start_ms; |
4249 | 4245 |
4250 CheckAndNotifyBackgroundIdleNotification(idle_time_in_ms, start_ms); | 4246 CheckBackgroundIdleNotification(idle_time_in_ms, start_ms); |
4251 | 4247 |
4252 tracer()->SampleAllocation(start_ms, NewSpaceAllocationCounter(), | 4248 tracer()->SampleAllocation(start_ms, NewSpaceAllocationCounter(), |
4253 OldGenerationAllocationCounter()); | 4249 OldGenerationAllocationCounter()); |
4254 | 4250 |
4255 GCIdleTimeHeapState heap_state = ComputeHeapState(); | 4251 GCIdleTimeHeapState heap_state = ComputeHeapState(); |
4256 | 4252 |
4257 GCIdleTimeAction action = | 4253 GCIdleTimeAction action = |
4258 gc_idle_time_handler_->Compute(idle_time_in_ms, heap_state); | 4254 gc_idle_time_handler_->Compute(idle_time_in_ms, heap_state); |
4259 | 4255 |
4260 bool result = PerformIdleTimeAction(action, heap_state, deadline_in_ms); | 4256 bool result = PerformIdleTimeAction(action, heap_state, deadline_in_ms); |
(...skipping 1860 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6121 } | 6117 } |
6122 | 6118 |
6123 | 6119 |
6124 // static | 6120 // static |
6125 int Heap::GetStaticVisitorIdForMap(Map* map) { | 6121 int Heap::GetStaticVisitorIdForMap(Map* map) { |
6126 return StaticVisitorBase::GetVisitorId(map); | 6122 return StaticVisitorBase::GetVisitorId(map); |
6127 } | 6123 } |
6128 | 6124 |
6129 } // namespace internal | 6125 } // namespace internal |
6130 } // namespace v8 | 6126 } // namespace v8 |
OLD | NEW |