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 | |
150 void ThreadRegistry::ReturnToFreelistLocked(Thread* thread) { | 149 void ThreadRegistry::ReturnToFreelistLocked(Thread* thread) { |
151 ASSERT(thread != NULL); | 150 ASSERT(thread != NULL); |
152 ASSERT(thread->os_thread_ == NULL); | 151 ASSERT(thread->os_thread_ == NULL); |
153 ASSERT(thread->isolate_ == NULL); | 152 ASSERT(thread->isolate_ == NULL); |
154 ASSERT(thread->heap_ == NULL); | 153 ASSERT(thread->heap_ == NULL); |
155 ASSERT(threads_lock()->IsOwnedByCurrentThread()); | 154 ASSERT(threads_lock()->IsOwnedByCurrentThread()); |
156 // Add thread to the free list. | 155 // Add thread to the free list. |
157 thread->next_ = free_list_; | 156 thread->next_ = free_list_; |
158 free_list_ = thread; | 157 free_list_ = thread; |
159 } | 158 } |
160 | 159 |
161 | |
162 intptr_t ThreadRegistry::ThreadHighWatermarksTotalLocked() const { | |
163 ASSERT(threads_lock()->IsOwnedByCurrentThread()); | |
164 intptr_t max_memory_usage_total = 0; | |
165 Thread* current = active_list_; | |
166 while (current != NULL) { | |
167 max_memory_usage_total += current->GetThreadHighWatermark(); | |
168 current = current->next_; | |
169 } | |
170 return max_memory_usage_total; | |
171 } | |
172 | |
173 } // namespace dart | 160 } // namespace dart |
OLD | NEW |