| OLD | NEW |
| 1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2015, 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/thread_registry.h" | 5 #include "vm/thread_registry.h" |
| 6 | 6 |
| 7 #include "vm/isolate.h" | 7 #include "vm/isolate.h" |
| 8 #include "vm/lockers.h" | 8 #include "vm/lockers.h" |
| 9 | 9 |
| 10 namespace dart { | 10 namespace dart { |
| 11 | 11 |
| 12 ThreadRegistry::~ThreadRegistry() { |
| 13 { |
| 14 // Each thread that is scheduled in this isolate may have a cached timeline |
| 15 // block. Mark these timeline blocks as finished. |
| 16 MonitorLocker ml(monitor_); |
| 17 TimelineEventRecorder* recorder = Timeline::recorder(); |
| 18 if (recorder != NULL) { |
| 19 MutexLocker recorder_lock(&recorder->lock_); |
| 20 for (intptr_t i = 0; i < entries_.length(); i++) { |
| 21 // NOTE: It is only safe to access |entry.state| here. |
| 22 const Entry& entry = entries_.At(i); |
| 23 if (entry.state.timeline_block != NULL) { |
| 24 entry.state.timeline_block->Finish(); |
| 25 } |
| 26 } |
| 27 } |
| 28 } |
| 29 |
| 30 // Delete monitor. |
| 31 delete monitor_; |
| 32 } |
| 33 |
| 34 |
| 12 void ThreadRegistry::SafepointThreads() { | 35 void ThreadRegistry::SafepointThreads() { |
| 13 MonitorLocker ml(monitor_); | 36 MonitorLocker ml(monitor_); |
| 14 // First wait for any older rounds that are still in progress. | 37 // First wait for any older rounds that are still in progress. |
| 15 while (in_rendezvous_) { | 38 while (in_rendezvous_) { |
| 16 // Assert we are not the organizer trying to nest calls to SafepointThreads. | 39 // Assert we are not the organizer trying to nest calls to SafepointThreads. |
| 17 ASSERT(remaining_ > 0); | 40 ASSERT(remaining_ > 0); |
| 18 CheckSafepointLocked(); | 41 CheckSafepointLocked(); |
| 19 } | 42 } |
| 20 // Start a new round. | 43 // Start a new round. |
| 21 in_rendezvous_ = true; | 44 in_rendezvous_ = true; |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 75 for (int i = 0; i < entries_.length(); ++i) { | 98 for (int i = 0; i < entries_.length(); ++i) { |
| 76 const Entry& entry = entries_[i]; | 99 const Entry& entry = entries_[i]; |
| 77 if (entry.scheduled) { | 100 if (entry.scheduled) { |
| 78 ++count; | 101 ++count; |
| 79 } | 102 } |
| 80 } | 103 } |
| 81 return count; | 104 return count; |
| 82 } | 105 } |
| 83 | 106 |
| 84 } // namespace dart | 107 } // namespace dart |
| OLD | NEW |