| 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 128 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 139 // Get thread structure from free list or create a new one. | 139 // Get thread structure from free list or create a new one. |
| 140 if (free_list_ == NULL) { | 140 if (free_list_ == NULL) { |
| 141 thread = new Thread(isolate); | 141 thread = new Thread(isolate); |
| 142 } else { | 142 } else { |
| 143 thread = free_list_; | 143 thread = free_list_; |
| 144 free_list_ = thread->next_; | 144 free_list_ = thread->next_; |
| 145 } | 145 } |
| 146 return thread; | 146 return thread; |
| 147 } | 147 } |
| 148 | 148 |
| 149 |
| 149 void ThreadRegistry::ReturnToFreelistLocked(Thread* thread) { | 150 void ThreadRegistry::ReturnToFreelistLocked(Thread* thread) { |
| 150 ASSERT(thread != NULL); | 151 ASSERT(thread != NULL); |
| 151 ASSERT(thread->os_thread_ == NULL); | 152 ASSERT(thread->os_thread_ == NULL); |
| 152 ASSERT(thread->isolate_ == NULL); | 153 ASSERT(thread->isolate_ == NULL); |
| 153 ASSERT(thread->heap_ == NULL); | 154 ASSERT(thread->heap_ == NULL); |
| 154 ASSERT(threads_lock()->IsOwnedByCurrentThread()); | 155 ASSERT(threads_lock()->IsOwnedByCurrentThread()); |
| 155 // Add thread to the free list. | 156 // Add thread to the free list. |
| 156 thread->next_ = free_list_; | 157 thread->next_ = free_list_; |
| 157 free_list_ = thread; | 158 free_list_ = thread; |
| 158 } | 159 } |
| 159 | 160 |
| 161 |
| 162 uintptr_t ThreadRegistry::ThreadHighWatermarksTotalLocked() const { |
| 163 ASSERT(threads_lock()->IsOwnedByCurrentThread()); |
| 164 uintptr_t memory_high_watermarks_total = 0; |
| 165 Thread* current = active_list_; |
| 166 while (current != NULL) { |
| 167 memory_high_watermarks_total += current->memory_high_watermark(); |
| 168 current = current->next_; |
| 169 } |
| 170 return memory_high_watermarks_total; |
| 171 } |
| 172 |
| 160 } // namespace dart | 173 } // namespace dart |
| OLD | NEW |