| 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 4192 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4203 if (FLAG_trace_idle_notification_verbose) { | 4203 if (FLAG_trace_idle_notification_verbose) { |
| 4204 PrintF("["); | 4204 PrintF("["); |
| 4205 heap_state.Print(); | 4205 heap_state.Print(); |
| 4206 PrintF("]"); | 4206 PrintF("]"); |
| 4207 } | 4207 } |
| 4208 PrintF("\n"); | 4208 PrintF("\n"); |
| 4209 } | 4209 } |
| 4210 } | 4210 } |
| 4211 | 4211 |
| 4212 | 4212 |
| 4213 void Heap::CheckBackgroundIdleNotification(double idle_time_in_ms, | |
| 4214 double now_ms) { | |
| 4215 // TODO(ulan): Remove this function once Chrome uses new API | |
| 4216 // for foreground/background notification. | |
| 4217 if (idle_time_in_ms >= GCIdleTimeHandler::kMinBackgroundIdleTime) { | |
| 4218 optimize_for_memory_usage_ = true; | |
| 4219 } else { | |
| 4220 optimize_for_memory_usage_ = false; | |
| 4221 } | |
| 4222 } | |
| 4223 | |
| 4224 | |
| 4225 double Heap::MonotonicallyIncreasingTimeInMs() { | 4213 double Heap::MonotonicallyIncreasingTimeInMs() { |
| 4226 return V8::GetCurrentPlatform()->MonotonicallyIncreasingTime() * | 4214 return V8::GetCurrentPlatform()->MonotonicallyIncreasingTime() * |
| 4227 static_cast<double>(base::Time::kMillisecondsPerSecond); | 4215 static_cast<double>(base::Time::kMillisecondsPerSecond); |
| 4228 } | 4216 } |
| 4229 | 4217 |
| 4230 | 4218 |
| 4231 bool Heap::IdleNotification(int idle_time_in_ms) { | 4219 bool Heap::IdleNotification(int idle_time_in_ms) { |
| 4232 return IdleNotification( | 4220 return IdleNotification( |
| 4233 V8::GetCurrentPlatform()->MonotonicallyIncreasingTime() + | 4221 V8::GetCurrentPlatform()->MonotonicallyIncreasingTime() + |
| 4234 (static_cast<double>(idle_time_in_ms) / | 4222 (static_cast<double>(idle_time_in_ms) / |
| 4235 static_cast<double>(base::Time::kMillisecondsPerSecond))); | 4223 static_cast<double>(base::Time::kMillisecondsPerSecond))); |
| 4236 } | 4224 } |
| 4237 | 4225 |
| 4238 | 4226 |
| 4239 bool Heap::IdleNotification(double deadline_in_seconds) { | 4227 bool Heap::IdleNotification(double deadline_in_seconds) { |
| 4240 CHECK(HasBeenSetUp()); | 4228 CHECK(HasBeenSetUp()); |
| 4241 double deadline_in_ms = | 4229 double deadline_in_ms = |
| 4242 deadline_in_seconds * | 4230 deadline_in_seconds * |
| 4243 static_cast<double>(base::Time::kMillisecondsPerSecond); | 4231 static_cast<double>(base::Time::kMillisecondsPerSecond); |
| 4244 HistogramTimerScope idle_notification_scope( | 4232 HistogramTimerScope idle_notification_scope( |
| 4245 isolate_->counters()->gc_idle_notification()); | 4233 isolate_->counters()->gc_idle_notification()); |
| 4246 double start_ms = MonotonicallyIncreasingTimeInMs(); | 4234 double start_ms = MonotonicallyIncreasingTimeInMs(); |
| 4247 double idle_time_in_ms = deadline_in_ms - start_ms; | 4235 double idle_time_in_ms = deadline_in_ms - start_ms; |
| 4248 | 4236 |
| 4249 CheckBackgroundIdleNotification(idle_time_in_ms, start_ms); | |
| 4250 | |
| 4251 tracer()->SampleAllocation(start_ms, NewSpaceAllocationCounter(), | 4237 tracer()->SampleAllocation(start_ms, NewSpaceAllocationCounter(), |
| 4252 OldGenerationAllocationCounter()); | 4238 OldGenerationAllocationCounter()); |
| 4253 | 4239 |
| 4254 GCIdleTimeHeapState heap_state = ComputeHeapState(); | 4240 GCIdleTimeHeapState heap_state = ComputeHeapState(); |
| 4255 | 4241 |
| 4256 GCIdleTimeAction action = | 4242 GCIdleTimeAction action = |
| 4257 gc_idle_time_handler_->Compute(idle_time_in_ms, heap_state); | 4243 gc_idle_time_handler_->Compute(idle_time_in_ms, heap_state); |
| 4258 | 4244 |
| 4259 bool result = PerformIdleTimeAction(action, heap_state, deadline_in_ms); | 4245 bool result = PerformIdleTimeAction(action, heap_state, deadline_in_ms); |
| 4260 | 4246 |
| (...skipping 1925 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6186 } | 6172 } |
| 6187 | 6173 |
| 6188 | 6174 |
| 6189 // static | 6175 // static |
| 6190 int Heap::GetStaticVisitorIdForMap(Map* map) { | 6176 int Heap::GetStaticVisitorIdForMap(Map* map) { |
| 6191 return StaticVisitorBase::GetVisitorId(map); | 6177 return StaticVisitorBase::GetVisitorId(map); |
| 6192 } | 6178 } |
| 6193 | 6179 |
| 6194 } // namespace internal | 6180 } // namespace internal |
| 6195 } // namespace v8 | 6181 } // namespace v8 |
| OLD | NEW |