| 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/log.h" | 10 #include "vm/log.h" |
| (...skipping 323 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 334 ASSERT(thread->store_buffer_block_ == NULL); | 334 ASSERT(thread->store_buffer_block_ == NULL); |
| 335 // TODO(koda): Use StoreBufferAcquire once we properly flush before Scavenge. | 335 // TODO(koda): Use StoreBufferAcquire once we properly flush before Scavenge. |
| 336 thread->store_buffer_block_ = | 336 thread->store_buffer_block_ = |
| 337 thread->isolate()->store_buffer()->PopEmptyBlock(); | 337 thread->isolate()->store_buffer()->PopEmptyBlock(); |
| 338 ASSERT(isolate->heap() != NULL); | 338 ASSERT(isolate->heap() != NULL); |
| 339 thread->heap_ = isolate->heap(); | 339 thread->heap_ = isolate->heap(); |
| 340 ASSERT(thread->thread_interrupt_callback_ == NULL); | 340 ASSERT(thread->thread_interrupt_callback_ == NULL); |
| 341 ASSERT(thread->thread_interrupt_data_ == NULL); | 341 ASSERT(thread->thread_interrupt_data_ == NULL); |
| 342 // Do not update isolate->mutator_thread, but perform sanity check: | 342 // Do not update isolate->mutator_thread, but perform sanity check: |
| 343 // this thread should not be both the main mutator and helper. | 343 // this thread should not be both the main mutator and helper. |
| 344 ASSERT(!isolate->MutatorThreadIsCurrentThread()); | 344 ASSERT(!thread->IsMutatorThread()); |
| 345 thread->Schedule(isolate, bypass_safepoint); | 345 thread->Schedule(isolate, bypass_safepoint); |
| 346 } | 346 } |
| 347 | 347 |
| 348 | 348 |
| 349 void Thread::ExitIsolateAsHelper(bool bypass_safepoint) { | 349 void Thread::ExitIsolateAsHelper(bool bypass_safepoint) { |
| 350 Thread* thread = Thread::Current(); | 350 Thread* thread = Thread::Current(); |
| 351 Isolate* isolate = thread->isolate(); | 351 Isolate* isolate = thread->isolate(); |
| 352 ASSERT(isolate != NULL); | 352 ASSERT(isolate != NULL); |
| 353 thread->Unschedule(bypass_safepoint); | 353 thread->Unschedule(bypass_safepoint); |
| 354 // TODO(koda): Move store_buffer_block_ into State. | 354 // TODO(koda): Move store_buffer_block_ into State. |
| 355 thread->StoreBufferRelease(); | 355 thread->StoreBufferRelease(); |
| 356 thread->isolate_ = NULL; | 356 thread->isolate_ = NULL; |
| 357 thread->heap_ = NULL; | 357 thread->heap_ = NULL; |
| 358 ASSERT(!isolate->MutatorThreadIsCurrentThread()); | 358 ASSERT(!thread->IsMutatorThread()); |
| 359 } | 359 } |
| 360 | 360 |
| 361 | 361 |
| 362 // TODO(koda): Make non-static and invoke in SafepointThreads. | 362 // TODO(koda): Make non-static and invoke in SafepointThreads. |
| 363 void Thread::PrepareForGC() { | 363 void Thread::PrepareForGC() { |
| 364 Thread* thread = Thread::Current(); | 364 Thread* thread = Thread::Current(); |
| 365 // Prevent scheduling another GC. | 365 // Prevent scheduling another GC. |
| 366 thread->StoreBufferRelease(StoreBuffer::kIgnoreThreshold); | 366 thread->StoreBufferRelease(StoreBuffer::kIgnoreThreshold); |
| 367 // Make sure to get an *empty* block; the isolate needs all entries | 367 // Make sure to get an *empty* block; the isolate needs all entries |
| 368 // at GC time. | 368 // at GC time. |
| (...skipping 30 matching lines...) Expand all Loading... |
| 399 store_buffer_block_ = NULL; | 399 store_buffer_block_ = NULL; |
| 400 isolate_->store_buffer()->PushBlock(block, policy); | 400 isolate_->store_buffer()->PushBlock(block, policy); |
| 401 } | 401 } |
| 402 | 402 |
| 403 | 403 |
| 404 void Thread::StoreBufferAcquire() { | 404 void Thread::StoreBufferAcquire() { |
| 405 store_buffer_block_ = isolate()->store_buffer()->PopNonFullBlock(); | 405 store_buffer_block_ = isolate()->store_buffer()->PopNonFullBlock(); |
| 406 } | 406 } |
| 407 | 407 |
| 408 | 408 |
| 409 bool Thread::IsMutatorThread() const { |
| 410 return ((isolate_ != NULL) && (isolate_->mutator_thread() == this)); |
| 411 } |
| 412 |
| 413 |
| 409 CHA* Thread::cha() const { | 414 CHA* Thread::cha() const { |
| 410 ASSERT(isolate_ != NULL); | 415 ASSERT(isolate_ != NULL); |
| 411 return cha_; | 416 return cha_; |
| 412 } | 417 } |
| 413 | 418 |
| 414 | 419 |
| 415 void Thread::set_cha(CHA* value) { | 420 void Thread::set_cha(CHA* value) { |
| 416 ASSERT(isolate_ != NULL); | 421 ASSERT(isolate_ != NULL); |
| 417 cha_ = value; | 422 cha_ = value; |
| 418 } | 423 } |
| (...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 543 Thread* ThreadIterator::Next() { | 548 Thread* ThreadIterator::Next() { |
| 544 ASSERT(Thread::thread_list_lock_ != NULL); | 549 ASSERT(Thread::thread_list_lock_ != NULL); |
| 545 ASSERT(Thread::thread_list_lock_->IsOwnedByCurrentThread()); | 550 ASSERT(Thread::thread_list_lock_->IsOwnedByCurrentThread()); |
| 546 Thread* current = next_; | 551 Thread* current = next_; |
| 547 next_ = next_->thread_list_next_; | 552 next_ = next_->thread_list_next_; |
| 548 return current; | 553 return current; |
| 549 } | 554 } |
| 550 | 555 |
| 551 | 556 |
| 552 } // namespace dart | 557 } // namespace dart |
| OLD | NEW |