Chromium Code Reviews| 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 #ifndef VM_THREAD_REGISTRY_H_ | 5 #ifndef VM_THREAD_REGISTRY_H_ | 
| 6 #define VM_THREAD_REGISTRY_H_ | 6 #define VM_THREAD_REGISTRY_H_ | 
| 7 | 7 | 
| 8 #include "vm/globals.h" | 8 #include "vm/globals.h" | 
| 9 #include "vm/growable_array.h" | 9 #include "vm/growable_array.h" | 
| 10 #include "vm/isolate.h" | 10 #include "vm/isolate.h" | 
| 11 #include "vm/lockers.h" | 11 #include "vm/lockers.h" | 
| 12 #include "vm/stack_frame.h" | |
| 12 #include "vm/thread.h" | 13 #include "vm/thread.h" | 
| 13 | 14 | 
| 14 namespace dart { | 15 namespace dart { | 
| 15 | 16 | 
| 16 // Unordered collection of threads relating to a particular isolate. | 17 // Unordered collection of threads relating to a particular isolate. | 
| 17 class ThreadRegistry { | 18 class ThreadRegistry { | 
| 18 public: | 19 public: | 
| 19 ThreadRegistry() | 20 ThreadRegistry() | 
| 20 : monitor_(new Monitor()), | 21 : monitor_(new Monitor()), | 
| 21 entries_(), | 22 entries_(), | 
| (...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 111 entry.thread, | 112 entry.thread, | 
| 112 entry.thread->isolate()); | 113 entry.thread->isolate()); | 
| 113 } | 114 } | 
| 114 } | 115 } | 
| 115 } | 116 } | 
| 116 | 117 | 
| 117 void VisitObjectPointers(ObjectPointerVisitor* visitor) { | 118 void VisitObjectPointers(ObjectPointerVisitor* visitor) { | 
| 118 MonitorLocker ml(monitor_); | 119 MonitorLocker ml(monitor_); | 
| 119 for (int i = 0; i < entries_.length(); ++i) { | 120 for (int i = 0; i < entries_.length(); ++i) { | 
| 120 const Entry& entry = entries_[i]; | 121 const Entry& entry = entries_[i]; | 
| 121 Zone* zone = entry.scheduled ? entry.thread->zone() : entry.state.zone; | 122 const Thread::State& state = | 
| 122 if (zone != NULL) { | 123 entry.scheduled ? entry.thread->state_ : entry.state; | 
| 123 zone->VisitObjectPointers(visitor); | 124 if (state.zone != NULL) { | 
| 125 state.zone->VisitObjectPointers(visitor); | |
| 126 } | |
| 127 // Iterate over all the stack frames and visit objects on the stack. | |
| 128 uword efi = state.top_exit_frame_info; | |
| 129 if (efi == 0) continue; | |
| 130 StackFrameIterator frames_iterator(efi, false); | |
| 
 
Ivan Posva
2015/08/11 17:41:31
Please do not use explicit constants and use the a
 
 | |
| 131 StackFrame* frame = frames_iterator.NextFrame(); | |
| 132 while (frame != NULL) { | |
| 133 frame->VisitObjectPointers(visitor); | |
| 134 frame = frames_iterator.NextFrame(); | |
| 124 } | 135 } | 
| 125 } | 136 } | 
| 126 } | 137 } | 
| 127 | 138 | 
| 128 private: | 139 private: | 
| 129 struct Entry { | 140 struct Entry { | 
| 130 Thread* thread; | 141 Thread* thread; | 
| 131 bool scheduled; | 142 bool scheduled; | 
| 132 Thread::State state; | 143 Thread::State state; | 
| 133 }; | 144 }; | 
| (...skipping 25 matching lines...) Expand all Loading... | |
| 159 intptr_t remaining_; // Number of threads yet to reach their safepoint. | 170 intptr_t remaining_; // Number of threads yet to reach their safepoint. | 
| 160 int64_t round_; // Counter, to prevent missing updates to remaining_ | 171 int64_t round_; // Counter, to prevent missing updates to remaining_ | 
| 161 // (see comments in CheckSafepointLocked). | 172 // (see comments in CheckSafepointLocked). | 
| 162 | 173 | 
| 163 DISALLOW_COPY_AND_ASSIGN(ThreadRegistry); | 174 DISALLOW_COPY_AND_ASSIGN(ThreadRegistry); | 
| 164 }; | 175 }; | 
| 165 | 176 | 
| 166 } // namespace dart | 177 } // namespace dart | 
| 167 | 178 | 
| 168 #endif // VM_THREAD_REGISTRY_H_ | 179 #endif // VM_THREAD_REGISTRY_H_ | 
| OLD | NEW |