Chromium Code Reviews| 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/dart_api_state.h" | 7 #include "vm/dart_api_state.h" |
| 8 #include "vm/growable_array.h" | 8 #include "vm/growable_array.h" |
| 9 #include "vm/isolate.h" | 9 #include "vm/isolate.h" |
| 10 #include "vm/lockers.h" | 10 #include "vm/lockers.h" |
| (...skipping 218 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 229 ASSERT(!thread->IsMutatorThread()); | 229 ASSERT(!thread->IsMutatorThread()); |
| 230 thread->StoreBufferRelease(); | 230 thread->StoreBufferRelease(); |
| 231 Isolate* isolate = thread->isolate(); | 231 Isolate* isolate = thread->isolate(); |
| 232 ASSERT(isolate != NULL); | 232 ASSERT(isolate != NULL); |
| 233 const bool kIsNotMutatorThread = false; | 233 const bool kIsNotMutatorThread = false; |
| 234 ThreadRegistry* tr = isolate->thread_registry(); | 234 ThreadRegistry* tr = isolate->thread_registry(); |
| 235 tr->Unschedule(thread, kIsNotMutatorThread, bypass_safepoint); | 235 tr->Unschedule(thread, kIsNotMutatorThread, bypass_safepoint); |
| 236 } | 236 } |
| 237 | 237 |
| 238 | 238 |
| 239 // TODO(koda): Make non-static and invoke in SafepointThreads. | |
| 240 void Thread::PrepareForGC() { | 239 void Thread::PrepareForGC() { |
|
siva
2015/12/18 01:05:02
ASSERT(isolate()->thread_registry()->AtSafepoint()
Ivan Posva
2015/12/18 03:59:50
Done.
| |
| 241 Thread* thread = Thread::Current(); | 240 // Prevent scheduling another GC by ignoring the threshold. |
| 242 // Prevent scheduling another GC. | 241 StoreBufferRelease(StoreBuffer::kIgnoreThreshold); |
| 243 thread->StoreBufferRelease(StoreBuffer::kIgnoreThreshold); | |
| 244 // Make sure to get an *empty* block; the isolate needs all entries | 242 // Make sure to get an *empty* block; the isolate needs all entries |
| 245 // at GC time. | 243 // at GC time. |
| 246 // TODO(koda): Replace with an epilogue (PrepareAfterGC) that acquires. | 244 // TODO(koda): Replace with an epilogue (PrepareAfterGC) that acquires. |
| 247 thread->store_buffer_block_ = | 245 store_buffer_block_ = isolate()->store_buffer()->PopEmptyBlock(); |
| 248 thread->isolate()->store_buffer()->PopEmptyBlock(); | |
| 249 } | 246 } |
| 250 | 247 |
| 251 | 248 |
| 252 void Thread::StoreBufferBlockProcess(StoreBuffer::ThresholdPolicy policy) { | 249 void Thread::StoreBufferBlockProcess(StoreBuffer::ThresholdPolicy policy) { |
| 253 StoreBufferRelease(policy); | 250 StoreBufferRelease(policy); |
| 254 StoreBufferAcquire(); | 251 StoreBufferAcquire(); |
| 255 } | 252 } |
| 256 | 253 |
| 257 | 254 |
| 258 void Thread::StoreBufferAddObject(RawObject* obj) { | 255 void Thread::StoreBufferAddObject(RawObject* obj) { |
| 259 store_buffer_block_->Push(obj); | 256 store_buffer_block_->Push(obj); |
| 260 if (store_buffer_block_->IsFull()) { | 257 if (store_buffer_block_->IsFull()) { |
| 261 StoreBufferBlockProcess(StoreBuffer::kCheckThreshold); | 258 StoreBufferBlockProcess(StoreBuffer::kCheckThreshold); |
| 262 } | 259 } |
| 263 } | 260 } |
| 264 | 261 |
| 265 | 262 |
| 266 void Thread::StoreBufferAddObjectGC(RawObject* obj) { | 263 void Thread::StoreBufferAddObjectGC(RawObject* obj) { |
| 267 store_buffer_block_->Push(obj); | 264 store_buffer_block_->Push(obj); |
| 268 if (store_buffer_block_->IsFull()) { | 265 if (store_buffer_block_->IsFull()) { |
| 269 StoreBufferBlockProcess(StoreBuffer::kIgnoreThreshold); | 266 StoreBufferBlockProcess(StoreBuffer::kIgnoreThreshold); |
| 270 } | 267 } |
| 271 } | 268 } |
| 272 | 269 |
| 273 | 270 |
| 274 void Thread::StoreBufferRelease(StoreBuffer::ThresholdPolicy policy) { | 271 void Thread::StoreBufferRelease(StoreBuffer::ThresholdPolicy policy) { |
| 275 StoreBufferBlock* block = store_buffer_block_; | 272 StoreBufferBlock* block = store_buffer_block_; |
| 276 store_buffer_block_ = NULL; | 273 store_buffer_block_ = NULL; |
| 277 isolate_->store_buffer()->PushBlock(block, policy); | 274 isolate()->store_buffer()->PushBlock(block, policy); |
| 278 } | 275 } |
| 279 | 276 |
| 280 | 277 |
| 281 void Thread::StoreBufferAcquire() { | 278 void Thread::StoreBufferAcquire() { |
| 282 store_buffer_block_ = isolate()->store_buffer()->PopNonFullBlock(); | 279 store_buffer_block_ = isolate()->store_buffer()->PopNonFullBlock(); |
| 283 } | 280 } |
| 284 | 281 |
| 285 | 282 |
| 286 bool Thread::IsMutatorThread() const { | 283 bool Thread::IsMutatorThread() const { |
| 287 return ((isolate_ != NULL) && (isolate_->mutator_thread() == this)); | 284 return ((isolate_ != NULL) && (isolate_->mutator_thread() == this)); |
| (...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 449 | 446 |
| 450 DisableThreadInterruptsScope::~DisableThreadInterruptsScope() { | 447 DisableThreadInterruptsScope::~DisableThreadInterruptsScope() { |
| 451 if (thread() != NULL) { | 448 if (thread() != NULL) { |
| 452 OSThread* os_thread = thread()->os_thread(); | 449 OSThread* os_thread = thread()->os_thread(); |
| 453 ASSERT(os_thread != NULL); | 450 ASSERT(os_thread != NULL); |
| 454 os_thread->EnableThreadInterrupts(); | 451 os_thread->EnableThreadInterrupts(); |
| 455 } | 452 } |
| 456 } | 453 } |
| 457 | 454 |
| 458 } // namespace dart | 455 } // namespace dart |
| OLD | NEW |