| 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" |
| (...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 170 // Leave some room for precision error in task scheduler. | 170 // Leave some room for precision error in task scheduler. |
| 171 const double kSlackMs = 100; | 171 const double kSlackMs = 100; |
| 172 v8::Isolate* isolate = reinterpret_cast<v8::Isolate*>(heap()->isolate()); | 172 v8::Isolate* isolate = reinterpret_cast<v8::Isolate*>(heap()->isolate()); |
| 173 DCHECK(nullptr == pending_task_); | 173 DCHECK(nullptr == pending_task_); |
| 174 pending_task_ = new MemoryReducer::TimerTask(this); | 174 pending_task_ = new MemoryReducer::TimerTask(this); |
| 175 V8::GetCurrentPlatform()->CallDelayedOnForegroundThread( | 175 V8::GetCurrentPlatform()->CallDelayedOnForegroundThread( |
| 176 isolate, pending_task_, (delay_ms + kSlackMs) / 1000.0); | 176 isolate, pending_task_, (delay_ms + kSlackMs) / 1000.0); |
| 177 } | 177 } |
| 178 | 178 |
| 179 | 179 |
| 180 void MemoryReducer::ClearTask(v8::Task* task) { |
| 181 if (pending_task_ == task) { |
| 182 pending_task_ = nullptr; |
| 183 } |
| 184 } |
| 185 |
| 186 |
| 180 void MemoryReducer::TearDown() { | 187 void MemoryReducer::TearDown() { |
| 181 if (pending_task_ != nullptr) { | 188 if (pending_task_ != nullptr) { |
| 182 pending_task_->NotifyHeapTearDown(); | 189 pending_task_->NotifyHeapTearDown(); |
| 183 pending_task_ = nullptr; | 190 pending_task_ = nullptr; |
| 184 } | 191 } |
| 185 state_ = State(kDone, 0, 0); | 192 state_ = State(kDone, 0, 0); |
| 186 } | 193 } |
| 187 | 194 |
| 188 } // internal | 195 } // internal |
| 189 } // v8 | 196 } // v8 |
| OLD | NEW |