| OLD | NEW |
| 1 // Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file |
| 2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
| 3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
| 4 | 4 |
| 5 #include "vm/dart_api_state.h" | 5 #include "vm/dart_api_state.h" |
| 6 | 6 |
| 7 #include "platform/assert.h" | 7 #include "platform/assert.h" |
| 8 #include "platform/utils.h" | 8 #include "platform/utils.h" |
| 9 #include "vm/heap.h" | 9 #include "vm/heap.h" |
| 10 #include "vm/isolate.h" | 10 #include "vm/isolate.h" |
| 11 #include "vm/lockers.h" | 11 #include "vm/lockers.h" |
| 12 #include "vm/thread.h" | 12 #include "vm/thread.h" |
| 13 #include "vm/timeline.h" | 13 #include "vm/timeline.h" |
| 14 | 14 |
| 15 namespace dart { | 15 namespace dart { |
| 16 | 16 |
| 17 BackgroundFinalizer::BackgroundFinalizer(Isolate* isolate, | 17 BackgroundFinalizer::BackgroundFinalizer(Isolate* isolate, |
| 18 FinalizationQueue* queue) : | 18 FinalizationQueue* queue) : |
| 19 isolate_(isolate), | 19 isolate_(isolate), |
| 20 queue_(queue) { | 20 queue_(queue) { |
| 21 ASSERT(FLAG_background_finalization); |
| 21 MonitorLocker ml(isolate->heap()->finalization_tasks_lock()); | 22 MonitorLocker ml(isolate->heap()->finalization_tasks_lock()); |
| 22 isolate->heap()->set_finalization_tasks( | 23 isolate->heap()->set_finalization_tasks( |
| 23 isolate->heap()->finalization_tasks() + 1); | 24 isolate->heap()->finalization_tasks() + 1); |
| 24 ml.Notify(); | 25 ml.Notify(); |
| 25 } | 26 } |
| 26 | 27 |
| 27 | 28 |
| 28 void BackgroundFinalizer::Run() { | 29 void BackgroundFinalizer::Run() { |
| 29 bool result = Thread::EnterIsolateAsHelper(isolate_, | 30 bool result = Thread::EnterIsolateAsHelper(isolate_, |
| 30 Thread::kFinalizerTask); | 31 Thread::kFinalizerTask); |
| (...skipping 15 matching lines...) Expand all Loading... |
| 46 | 47 |
| 47 { | 48 { |
| 48 Heap* heap = isolate_->heap(); | 49 Heap* heap = isolate_->heap(); |
| 49 MonitorLocker ml(heap->finalization_tasks_lock()); | 50 MonitorLocker ml(heap->finalization_tasks_lock()); |
| 50 heap->set_finalization_tasks(heap->finalization_tasks() - 1); | 51 heap->set_finalization_tasks(heap->finalization_tasks() - 1); |
| 51 ml.Notify(); | 52 ml.Notify(); |
| 52 } | 53 } |
| 53 } | 54 } |
| 54 | 55 |
| 55 } // namespace dart | 56 } // namespace dart |
| OLD | NEW |