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

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

Issue 2191723002: Fix race condition with HasMutatorThread that was being used without a lock. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Address self review comments. Created 4 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 : threads_lock_(new Monitor()), 21 : threads_lock_(new Monitor()),
22 active_list_(NULL), 22 active_list_(NULL),
23 free_list_(NULL), 23 free_list_(NULL),
24 mutator_thread_(NULL) {} 24 mutator_thread_(NULL) {}
25 ~ThreadRegistry(); 25 ~ThreadRegistry();
26 26
27 void VisitObjectPointers(ObjectPointerVisitor* visitor, bool validate_frames); 27 void VisitObjectPointers(ObjectPointerVisitor* visitor, bool validate_frames);
28 void PrepareForGC(); 28 void PrepareForGC();
29 Thread* mutator_thread() const { return mutator_thread_; }
29 30
30 private: 31 private:
31 Thread* active_list() const { return active_list_; } 32 Thread* active_list() const { return active_list_; }
32 Monitor* threads_lock() const { return threads_lock_; } 33 Monitor* threads_lock() const { return threads_lock_; }
33 34
34 Thread* GetFreeThreadLocked(Isolate* isolate, bool is_mutator); 35 Thread* GetFreeThreadLocked(Isolate* isolate, bool is_mutator);
35 void ReturnThreadLocked(bool is_mutator, Thread* thread); 36 void ReturnThreadLocked(bool is_mutator, Thread* thread);
36 void AddToActiveListLocked(Thread* thread); 37 void AddToActiveListLocked(Thread* thread);
37 void RemoveFromActiveListLocked(Thread* thread); 38 void RemoveFromActiveListLocked(Thread* thread);
38 Thread* GetFromFreelistLocked(Isolate* isolate); 39 Thread* GetFromFreelistLocked(Isolate* isolate);
(...skipping 21 matching lines...) Expand all
60 Thread* mutator_thread_; 61 Thread* mutator_thread_;
61 62
62 friend class Isolate; 63 friend class Isolate;
63 friend class SafepointHandler; 64 friend class SafepointHandler;
64 DISALLOW_COPY_AND_ASSIGN(ThreadRegistry); 65 DISALLOW_COPY_AND_ASSIGN(ThreadRegistry);
65 }; 66 };
66 67
67 } // namespace dart 68 } // namespace dart
68 69
69 #endif // VM_THREAD_REGISTRY_H_ 70 #endif // VM_THREAD_REGISTRY_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698