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

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

Issue 1294023009: Switch to a VM wide timeline recorder (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/stack_frame.h"
13 #include "vm/thread.h" 13 #include "vm/thread.h"
14 14
15 namespace dart { 15 namespace dart {
16 16
17 // Unordered collection of threads relating to a particular isolate. 17 // Unordered collection of threads relating to a particular isolate.
18 class ThreadRegistry { 18 class ThreadRegistry {
19 public: 19 public:
20 ThreadRegistry() 20 ThreadRegistry()
21 : monitor_(new Monitor()), 21 : monitor_(new Monitor()),
22 entries_(), 22 entries_(),
23 in_rendezvous_(false), 23 in_rendezvous_(false),
24 remaining_(0), 24 remaining_(0),
25 round_(0) {} 25 round_(0) {}
26 26
27 ~ThreadRegistry();
28
27 // Bring all threads in this isolate to a safepoint. The caller is 29 // Bring all threads in this isolate to a safepoint. The caller is
28 // expected to be implicitly at a safepoint. The threads will wait 30 // expected to be implicitly at a safepoint. The threads will wait
29 // until ResumeAllThreads is called. First participates in any 31 // until ResumeAllThreads is called. First participates in any
30 // already pending rendezvous requested by another thread. Any 32 // already pending rendezvous requested by another thread. Any
31 // thread that tries to enter this isolate during rendezvous will 33 // thread that tries to enter this isolate during rendezvous will
32 // wait in RestoreStateTo. Nesting is not supported: the caller must 34 // wait in RestoreStateTo. Nesting is not supported: the caller must
33 // call ResumeAllThreads before making further calls to 35 // call ResumeAllThreads before making further calls to
34 // SafepointThreads. 36 // SafepointThreads.
35 void SafepointThreads(); 37 void SafepointThreads();
36 38
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after
131 StackFrame* frame = frames_iterator.NextFrame(); 133 StackFrame* frame = frames_iterator.NextFrame();
132 while (frame != NULL) { 134 while (frame != NULL) {
133 frame->VisitObjectPointers(visitor); 135 frame->VisitObjectPointers(visitor);
134 frame = frames_iterator.NextFrame(); 136 frame = frames_iterator.NextFrame();
135 } 137 }
136 } 138 }
137 } 139 }
138 140
139 private: 141 private:
140 struct Entry { 142 struct Entry {
143 // NOTE: |thread| is deleted automatically when the thread exits.
144 // In other words, it is not safe to dereference |thread| unless you are on
145 // the thread itself.
141 Thread* thread; 146 Thread* thread;
142 bool scheduled; 147 bool scheduled;
143 Thread::State state; 148 Thread::State state;
144 }; 149 };
145 150
146 // Returns Entry corresponding to thread in registry or NULL. 151 // Returns Entry corresponding to thread in registry or NULL.
147 // Note: Lock should be taken before this function is called. 152 // Note: Lock should be taken before this function is called.
148 // TODO(koda): Add method Monitor::IsOwnedByCurrentThread. 153 // TODO(koda): Add method Monitor::IsOwnedByCurrentThread.
149 Entry* FindEntry(Thread* thread) { 154 Entry* FindEntry(Thread* thread) {
150 for (int i = 0; i < entries_.length(); ++i) { 155 for (int i = 0; i < entries_.length(); ++i) {
(...skipping 19 matching lines...) Expand all
170 intptr_t remaining_; // Number of threads yet to reach their safepoint. 175 intptr_t remaining_; // Number of threads yet to reach their safepoint.
171 int64_t round_; // Counter, to prevent missing updates to remaining_ 176 int64_t round_; // Counter, to prevent missing updates to remaining_
172 // (see comments in CheckSafepointLocked). 177 // (see comments in CheckSafepointLocked).
173 178
174 DISALLOW_COPY_AND_ASSIGN(ThreadRegistry); 179 DISALLOW_COPY_AND_ASSIGN(ThreadRegistry);
175 }; 180 };
176 181
177 } // namespace dart 182 } // namespace dart
178 183
179 #endif // VM_THREAD_REGISTRY_H_ 184 #endif // VM_THREAD_REGISTRY_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698