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.h" | 5 #include "vm/thread.h" |
6 | 6 |
7 #include "vm/growable_array.h" | 7 #include "vm/growable_array.h" |
8 #include "vm/isolate.h" | 8 #include "vm/isolate.h" |
9 #include "vm/lockers.h" | 9 #include "vm/lockers.h" |
10 #include "vm/object.h" | 10 #include "vm/object.h" |
(...skipping 182 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
193 Thread* thread = Thread::Current(); | 193 Thread* thread = Thread::Current(); |
194 ASSERT(thread != NULL); | 194 ASSERT(thread != NULL); |
195 ASSERT(thread->isolate() == NULL); | 195 ASSERT(thread->isolate() == NULL); |
196 thread->isolate_ = isolate; | 196 thread->isolate_ = isolate; |
197 ASSERT(thread->store_buffer_block_ == NULL); | 197 ASSERT(thread->store_buffer_block_ == NULL); |
198 // TODO(koda): Use StoreBufferAcquire once we properly flush before Scavenge. | 198 // TODO(koda): Use StoreBufferAcquire once we properly flush before Scavenge. |
199 thread->store_buffer_block_ = | 199 thread->store_buffer_block_ = |
200 thread->isolate()->store_buffer()->PopEmptyBlock(); | 200 thread->isolate()->store_buffer()->PopEmptyBlock(); |
201 ASSERT(isolate->heap() != NULL); | 201 ASSERT(isolate->heap() != NULL); |
202 thread->heap_ = isolate->heap(); | 202 thread->heap_ = isolate->heap(); |
203 ASSERT(thread->thread_state() == NULL); | 203 ASSERT(thread->thread_interrupt_callback_ == NULL); |
| 204 ASSERT(thread->thread_interrupt_data_ == NULL); |
204 // Do not update isolate->mutator_thread, but perform sanity check: | 205 // Do not update isolate->mutator_thread, but perform sanity check: |
205 // this thread should not be both the main mutator and helper. | 206 // this thread should not be both the main mutator and helper. |
206 ASSERT(!isolate->MutatorThreadIsCurrentThread()); | 207 ASSERT(!isolate->MutatorThreadIsCurrentThread()); |
207 thread->Schedule(isolate); | 208 thread->Schedule(isolate); |
208 } | 209 } |
209 | 210 |
210 | 211 |
211 void Thread::ExitIsolateAsHelper() { | 212 void Thread::ExitIsolateAsHelper() { |
212 Thread* thread = Thread::Current(); | 213 Thread* thread = Thread::Current(); |
213 Isolate* isolate = thread->isolate(); | 214 Isolate* isolate = thread->isolate(); |
214 ASSERT(isolate != NULL); | 215 ASSERT(isolate != NULL); |
215 thread->Unschedule(); | 216 thread->Unschedule(); |
216 // TODO(koda): Move store_buffer_block_ into State. | 217 // TODO(koda): Move store_buffer_block_ into State. |
217 thread->StoreBufferRelease(); | 218 thread->StoreBufferRelease(); |
218 thread->set_thread_state(NULL); | |
219 thread->isolate_ = NULL; | 219 thread->isolate_ = NULL; |
220 thread->heap_ = NULL; | 220 thread->heap_ = NULL; |
221 ASSERT(!isolate->MutatorThreadIsCurrentThread()); | 221 ASSERT(!isolate->MutatorThreadIsCurrentThread()); |
222 } | 222 } |
223 | 223 |
224 | 224 |
225 // TODO(koda): Make non-static and invoke in SafepointThreads. | 225 // TODO(koda): Make non-static and invoke in SafepointThreads. |
226 void Thread::PrepareForGC() { | 226 void Thread::PrepareForGC() { |
227 Thread* thread = Thread::Current(); | 227 Thread* thread = Thread::Current(); |
228 const bool kDoNotCheckThreshold = false; // Prevent scheduling another GC. | 228 const bool kDoNotCheckThreshold = false; // Prevent scheduling another GC. |
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
320 #define COMPUTE_OFFSET(type_name, member_name, expr, default_init_value) \ | 320 #define COMPUTE_OFFSET(type_name, member_name, expr, default_init_value) \ |
321 ASSERT((expr)->IsVMHeapObject()); \ | 321 ASSERT((expr)->IsVMHeapObject()); \ |
322 if (object.raw() == expr) return Thread::member_name##offset(); | 322 if (object.raw() == expr) return Thread::member_name##offset(); |
323 CACHED_VM_OBJECTS_LIST(COMPUTE_OFFSET) | 323 CACHED_VM_OBJECTS_LIST(COMPUTE_OFFSET) |
324 #undef COMPUTE_OFFSET | 324 #undef COMPUTE_OFFSET |
325 UNREACHABLE(); | 325 UNREACHABLE(); |
326 return -1; | 326 return -1; |
327 } | 327 } |
328 | 328 |
329 } // namespace dart | 329 } // namespace dart |
OLD | NEW |