OLD | NEW |
1 // Copyright 2015 the V8 project authors. All rights reserved. | 1 // Copyright 2015 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/memory-reducer.h" | 5 #include "src/heap/memory-reducer.h" |
6 | 6 |
7 #include "src/flags.h" | 7 #include "src/flags.h" |
8 #include "src/heap/heap.h" | 8 #include "src/heap/heap.h" |
9 #include "src/utils.h" | 9 #include "src/utils.h" |
10 #include "src/v8.h" | 10 #include "src/v8.h" |
11 | 11 |
12 namespace v8 { | 12 namespace v8 { |
13 namespace internal { | 13 namespace internal { |
14 | 14 |
15 const int MemoryReducer::kLongDelayMs = 5000; | 15 const int MemoryReducer::kLongDelayMs = 5000; |
16 const int MemoryReducer::kShortDelayMs = 500; | 16 const int MemoryReducer::kShortDelayMs = 500; |
17 const int MemoryReducer::kWatchdogDelayMs = 100000; | 17 const int MemoryReducer::kWatchdogDelayMs = 100000; |
18 const int MemoryReducer::kMaxNumberOfGCs = 3; | 18 const int MemoryReducer::kMaxNumberOfGCs = 3; |
19 | 19 |
20 MemoryReducer::TimerTask::TimerTask(MemoryReducer* memory_reducer) | 20 MemoryReducer::TimerTask::TimerTask(MemoryReducer* memory_reducer) |
21 : CancelableTask(memory_reducer->heap()->isolate()), | 21 : CancelableTask(memory_reducer->heap()->isolate()), |
22 memory_reducer_(memory_reducer) {} | 22 memory_reducer_(memory_reducer) {} |
23 | 23 |
24 | 24 |
25 void MemoryReducer::TimerTask::RunInternal() { | 25 void MemoryReducer::TimerTask::RunInternal() { |
26 Heap* heap = memory_reducer_->heap(); | 26 Heap* heap = memory_reducer_->heap(); |
27 Event event; | 27 Event event; |
| 28 double time_ms = heap->MonotonicallyIncreasingTimeInMs(); |
| 29 heap->tracer()->SampleAllocation(time_ms, heap->NewSpaceAllocationCounter(), |
| 30 heap->OldGenerationAllocationCounter()); |
28 event.type = kTimer; | 31 event.type = kTimer; |
29 event.time_ms = heap->MonotonicallyIncreasingTimeInMs(); | 32 event.time_ms = time_ms; |
30 event.low_allocation_rate = heap->HasLowAllocationRate(); | 33 event.low_allocation_rate = heap->HasLowAllocationRate(); |
31 event.can_start_incremental_gc = | 34 event.can_start_incremental_gc = |
32 heap->incremental_marking()->IsStopped() && | 35 heap->incremental_marking()->IsStopped() && |
33 heap->incremental_marking()->CanBeActivated(); | 36 heap->incremental_marking()->CanBeActivated(); |
34 memory_reducer_->NotifyTimer(event); | 37 memory_reducer_->NotifyTimer(event); |
35 } | 38 } |
36 | 39 |
37 | 40 |
38 void MemoryReducer::NotifyTimer(const Event& event) { | 41 void MemoryReducer::NotifyTimer(const Event& event) { |
39 DCHECK_EQ(kTimer, event.type); | 42 DCHECK_EQ(kTimer, event.type); |
(...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
193 auto timer_task = new MemoryReducer::TimerTask(this); | 196 auto timer_task = new MemoryReducer::TimerTask(this); |
194 V8::GetCurrentPlatform()->CallDelayedOnForegroundThread( | 197 V8::GetCurrentPlatform()->CallDelayedOnForegroundThread( |
195 isolate, timer_task, (delay_ms + kSlackMs) / 1000.0); | 198 isolate, timer_task, (delay_ms + kSlackMs) / 1000.0); |
196 } | 199 } |
197 | 200 |
198 | 201 |
199 void MemoryReducer::TearDown() { state_ = State(kDone, 0, 0, 0.0); } | 202 void MemoryReducer::TearDown() { state_ = State(kDone, 0, 0, 0.0); } |
200 | 203 |
201 } // internal | 204 } // internal |
202 } // v8 | 205 } // v8 |
OLD | NEW |