| 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/json_stream.h" | 8 #include "vm/json_stream.h" |
| 9 #include "vm/lockers.h" | 9 #include "vm/lockers.h" |
| 10 | 10 |
| (...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 163 // Get thread structure from free list or create a new one. | 163 // Get thread structure from free list or create a new one. |
| 164 if (free_list_ == NULL) { | 164 if (free_list_ == NULL) { |
| 165 thread = new Thread(isolate); | 165 thread = new Thread(isolate); |
| 166 } else { | 166 } else { |
| 167 thread = free_list_; | 167 thread = free_list_; |
| 168 free_list_ = thread->next_; | 168 free_list_ = thread->next_; |
| 169 } | 169 } |
| 170 return thread; | 170 return thread; |
| 171 } | 171 } |
| 172 | 172 |
| 173 | |
| 174 void ThreadRegistry::ReturnToFreelistLocked(Thread* thread) { | 173 void ThreadRegistry::ReturnToFreelistLocked(Thread* thread) { |
| 175 ASSERT(thread != NULL); | 174 ASSERT(thread != NULL); |
| 176 ASSERT(thread->os_thread_ == NULL); | 175 ASSERT(thread->os_thread_ == NULL); |
| 177 ASSERT(thread->isolate_ == NULL); | 176 ASSERT(thread->isolate_ == NULL); |
| 178 ASSERT(thread->heap_ == NULL); | 177 ASSERT(thread->heap_ == NULL); |
| 179 ASSERT(threads_lock()->IsOwnedByCurrentThread()); | 178 ASSERT(threads_lock()->IsOwnedByCurrentThread()); |
| 180 // Add thread to the free list. | 179 // Add thread to the free list. |
| 181 thread->next_ = free_list_; | 180 thread->next_ = free_list_; |
| 182 free_list_ = thread; | 181 free_list_ = thread; |
| 183 } | 182 } |
| 184 | 183 |
| 185 | |
| 186 uint ThreadRegistry::ThreadHighWatermarksTotalLocked() const { | |
| 187 ASSERT(threads_lock()->IsOwnedByCurrentThread()); | |
| 188 uint memory_high_watermarks_total = 0; | |
| 189 Thread* current = active_list_; | |
| 190 while (current != NULL) { | |
| 191 memory_high_watermarks_total += current->memory_high_watermark(); | |
| 192 current = current->next_; | |
| 193 } | |
| 194 return memory_high_watermarks_total; | |
| 195 } | |
| 196 | |
| 197 } // namespace dart | 184 } // namespace dart |
| OLD | NEW |