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 #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/lockers.h" | 8 #include "vm/lockers.h" |
9 | 9 |
10 namespace dart { | 10 namespace dart { |
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
80 OSThread* os_thread = OSThread::Current(); | 80 OSThread* os_thread = OSThread::Current(); |
81 ASSERT(os_thread != NULL); | 81 ASSERT(os_thread != NULL); |
82 ASSERT(isolate->heap() != NULL); | 82 ASSERT(isolate->heap() != NULL); |
83 if (is_mutator) { | 83 if (is_mutator) { |
84 if (mutator_thread_ == NULL) { | 84 if (mutator_thread_ == NULL) { |
85 mutator_thread_ = GetThreadFromFreelist(isolate); | 85 mutator_thread_ = GetThreadFromFreelist(isolate); |
86 } | 86 } |
87 thread = mutator_thread_; | 87 thread = mutator_thread_; |
88 } else { | 88 } else { |
89 thread = GetThreadFromFreelist(isolate); | 89 thread = GetThreadFromFreelist(isolate); |
| 90 ASSERT(thread->api_top_scope() == NULL); |
90 } | 91 } |
91 thread->isolate_ = isolate; | 92 thread->isolate_ = isolate; |
92 thread->heap_ = isolate->heap(); | 93 thread->heap_ = isolate->heap(); |
93 thread->set_os_thread(os_thread); | 94 thread->set_os_thread(os_thread); |
94 os_thread->set_thread(thread); | 95 os_thread->set_thread(thread); |
95 Thread::SetCurrent(thread); | 96 Thread::SetCurrent(thread); |
96 os_thread->EnableThreadInterrupts(); | 97 os_thread->EnableThreadInterrupts(); |
97 return thread; | 98 return thread; |
98 } | 99 } |
99 | 100 |
100 | 101 |
101 void ThreadRegistry::Unschedule(Thread* thread, | 102 void ThreadRegistry::Unschedule(Thread* thread, |
102 bool is_mutator, | 103 bool is_mutator, |
103 bool bypass_safepoint) { | 104 bool bypass_safepoint) { |
104 MonitorLocker ml(monitor_); | 105 MonitorLocker ml(monitor_); |
105 OSThread* os_thread = thread->os_thread(); | 106 OSThread* os_thread = thread->os_thread(); |
106 ASSERT(os_thread != NULL); | 107 ASSERT(os_thread != NULL); |
107 os_thread->DisableThreadInterrupts(); | 108 os_thread->DisableThreadInterrupts(); |
108 thread->isolate_ = NULL; | 109 thread->isolate_ = NULL; |
109 thread->heap_ = NULL; | 110 thread->heap_ = NULL; |
110 thread->set_os_thread(NULL); | 111 thread->set_os_thread(NULL); |
111 os_thread->set_thread(NULL); | 112 os_thread->set_thread(NULL); |
112 OSThread::SetCurrent(os_thread); | 113 OSThread::SetCurrent(os_thread); |
113 if (!is_mutator) { | 114 if (!is_mutator) { |
| 115 ASSERT(thread->api_top_scope() == NULL); |
114 ReturnThreadToFreelist(thread); | 116 ReturnThreadToFreelist(thread); |
115 } | 117 } |
116 if (!bypass_safepoint && in_rendezvous_) { | 118 if (!bypass_safepoint && in_rendezvous_) { |
117 // Don't wait for this thread. | 119 // Don't wait for this thread. |
118 ASSERT(remaining_ > 0); | 120 ASSERT(remaining_ > 0); |
119 if (--remaining_ == 0) { | 121 if (--remaining_ == 0) { |
120 ml.NotifyAll(); | 122 ml.NotifyAll(); |
121 } | 123 } |
122 } | 124 } |
123 } | 125 } |
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
218 intptr_t count = 0; | 220 intptr_t count = 0; |
219 Thread* current = active_list_; | 221 Thread* current = active_list_; |
220 while (current != NULL) { | 222 while (current != NULL) { |
221 ++count; | 223 ++count; |
222 current = current->next_; | 224 current = current->next_; |
223 } | 225 } |
224 return count; | 226 return count; |
225 } | 227 } |
226 | 228 |
227 } // namespace dart | 229 } // namespace dart |
OLD | NEW |