Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(57)

Side by Side Diff: runtime/vm/thread_registry.cc

Issue 2554983002: Created methods to surface zone memory information for each isolate and thread in JSON. (Closed)
Patch Set: Fixed ifndefs, various whitespace issues, and removed extra optional parameters Created 4 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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/lockers.h" 9 #include "vm/lockers.h"
9 10
10 namespace dart { 11 namespace dart {
11 12
12 ThreadRegistry::~ThreadRegistry() { 13 ThreadRegistry::~ThreadRegistry() {
13 // Go over the free thread list and delete the thread objects. 14 // Go over the free thread list and delete the thread objects.
14 { 15 {
15 MonitorLocker ml(threads_lock()); 16 MonitorLocker ml(threads_lock());
16 // At this point the active list should be empty. 17 // At this point the active list should be empty.
17 ASSERT(active_list_ == NULL); 18 ASSERT(active_list_ == NULL);
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
84 void ThreadRegistry::PrepareForGC() { 85 void ThreadRegistry::PrepareForGC() {
85 MonitorLocker ml(threads_lock()); 86 MonitorLocker ml(threads_lock());
86 Thread* thread = active_list_; 87 Thread* thread = active_list_;
87 while (thread != NULL) { 88 while (thread != NULL) {
88 thread->PrepareForGC(); 89 thread->PrepareForGC();
89 thread = thread->next_; 90 thread = thread->next_;
90 } 91 }
91 } 92 }
92 93
93 94
95 #ifndef PRODUCT
96 void ThreadRegistry::PrintJSON(JSONStream* stream) const {
97 MonitorLocker ml(threads_lock());
98 JSONArray threads(stream);
99 PrintJSONHelper(&threads, active_list_);
100 PrintJSONHelper(&threads, free_list_);
Cutch 2016/12/08 22:25:54 We shouldn't include the free list. These are Thre
bkonyi 2016/12/08 22:42:01 I'll go ahead and remove this then.
101 }
102
103
104 void ThreadRegistry::PrintJSONHelper(JSONArray* array, Thread* thread) const {
105 while (thread != NULL) {
106 array->AddValue(thread);
107 thread = thread->next_;
108 }
109 }
110 #endif
111
112
94 void ThreadRegistry::AddToActiveListLocked(Thread* thread) { 113 void ThreadRegistry::AddToActiveListLocked(Thread* thread) {
95 ASSERT(thread != NULL); 114 ASSERT(thread != NULL);
96 ASSERT(threads_lock()->IsOwnedByCurrentThread()); 115 ASSERT(threads_lock()->IsOwnedByCurrentThread());
97 thread->next_ = active_list_; 116 thread->next_ = active_list_;
98 active_list_ = thread; 117 active_list_ = thread;
99 } 118 }
100 119
101 120
102 void ThreadRegistry::RemoveFromActiveListLocked(Thread* thread) { 121 void ThreadRegistry::RemoveFromActiveListLocked(Thread* thread) {
103 ASSERT(thread != NULL); 122 ASSERT(thread != NULL);
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
137 ASSERT(thread->os_thread_ == NULL); 156 ASSERT(thread->os_thread_ == NULL);
138 ASSERT(thread->isolate_ == NULL); 157 ASSERT(thread->isolate_ == NULL);
139 ASSERT(thread->heap_ == NULL); 158 ASSERT(thread->heap_ == NULL);
140 ASSERT(threads_lock()->IsOwnedByCurrentThread()); 159 ASSERT(threads_lock()->IsOwnedByCurrentThread());
141 // Add thread to the free list. 160 // Add thread to the free list.
142 thread->next_ = free_list_; 161 thread->next_ = free_list_;
143 free_list_ = thread; 162 free_list_ = thread;
144 } 163 }
145 164
146 } // namespace dart 165 } // namespace dart
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698