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

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

Issue 1282423003: Enable iterating over roots from helper threads by moving stack walking. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 5 years, 4 months 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 #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
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
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_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698