| 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 237 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 248 thread->StoreBufferRelease(); | 248 thread->StoreBufferRelease(); |
| 249 thread->isolate_ = NULL; | 249 thread->isolate_ = NULL; |
| 250 thread->heap_ = NULL; | 250 thread->heap_ = NULL; |
| 251 ASSERT(!isolate->MutatorThreadIsCurrentThread()); | 251 ASSERT(!isolate->MutatorThreadIsCurrentThread()); |
| 252 } | 252 } |
| 253 | 253 |
| 254 | 254 |
| 255 // TODO(koda): Make non-static and invoke in SafepointThreads. | 255 // TODO(koda): Make non-static and invoke in SafepointThreads. |
| 256 void Thread::PrepareForGC() { | 256 void Thread::PrepareForGC() { |
| 257 Thread* thread = Thread::Current(); | 257 Thread* thread = Thread::Current(); |
| 258 const bool kDoNotCheckThreshold = false; // Prevent scheduling another GC. | 258 // Prevent scheduling another GC. |
| 259 thread->StoreBufferRelease(kDoNotCheckThreshold); | 259 thread->StoreBufferRelease(StoreBuffer::kIgnoreThreshold); |
| 260 // Make sure to get an *empty* block; the isolate needs all entries | 260 // Make sure to get an *empty* block; the isolate needs all entries |
| 261 // at GC time. | 261 // at GC time. |
| 262 // TODO(koda): Replace with an epilogue (PrepareAfterGC) that acquires. | 262 // TODO(koda): Replace with an epilogue (PrepareAfterGC) that acquires. |
| 263 thread->store_buffer_block_ = | 263 thread->store_buffer_block_ = |
| 264 thread->isolate()->store_buffer()->PopEmptyBlock(); | 264 thread->isolate()->store_buffer()->PopEmptyBlock(); |
| 265 } | 265 } |
| 266 | 266 |
| 267 | 267 |
| 268 void Thread::StoreBufferBlockProcess(bool check_threshold) { | 268 void Thread::StoreBufferBlockProcess(StoreBuffer::ThresholdPolicy policy) { |
| 269 StoreBufferRelease(check_threshold); | 269 StoreBufferRelease(policy); |
| 270 StoreBufferAcquire(); | 270 StoreBufferAcquire(); |
| 271 } | 271 } |
| 272 | 272 |
| 273 | 273 |
| 274 void Thread::StoreBufferAddObject(RawObject* obj) { | 274 void Thread::StoreBufferAddObject(RawObject* obj) { |
| 275 store_buffer_block_->Push(obj); | 275 store_buffer_block_->Push(obj); |
| 276 if (store_buffer_block_->IsFull()) { | 276 if (store_buffer_block_->IsFull()) { |
| 277 StoreBufferBlockProcess(true); | 277 StoreBufferBlockProcess(StoreBuffer::kCheckThreshold); |
| 278 } | 278 } |
| 279 } | 279 } |
| 280 | 280 |
| 281 | 281 |
| 282 void Thread::StoreBufferAddObjectGC(RawObject* obj) { | 282 void Thread::StoreBufferAddObjectGC(RawObject* obj) { |
| 283 store_buffer_block_->Push(obj); | 283 store_buffer_block_->Push(obj); |
| 284 if (store_buffer_block_->IsFull()) { | 284 if (store_buffer_block_->IsFull()) { |
| 285 StoreBufferBlockProcess(false); | 285 StoreBufferBlockProcess(StoreBuffer::kIgnoreThreshold); |
| 286 } | 286 } |
| 287 } | 287 } |
| 288 | 288 |
| 289 | 289 |
| 290 void Thread::StoreBufferRelease(bool check_threshold) { | 290 void Thread::StoreBufferRelease(StoreBuffer::ThresholdPolicy policy) { |
| 291 StoreBufferBlock* block = store_buffer_block_; | 291 StoreBufferBlock* block = store_buffer_block_; |
| 292 store_buffer_block_ = NULL; | 292 store_buffer_block_ = NULL; |
| 293 isolate_->store_buffer()->PushBlock(block, check_threshold); | 293 isolate_->store_buffer()->PushBlock(block, policy); |
| 294 } | 294 } |
| 295 | 295 |
| 296 | 296 |
| 297 void Thread::StoreBufferAcquire() { | 297 void Thread::StoreBufferAcquire() { |
| 298 store_buffer_block_ = isolate()->store_buffer()->PopNonFullBlock(); | 298 store_buffer_block_ = isolate()->store_buffer()->PopNonFullBlock(); |
| 299 } | 299 } |
| 300 | 300 |
| 301 | 301 |
| 302 CHA* Thread::cha() const { | 302 CHA* Thread::cha() const { |
| 303 ASSERT(isolate_ != NULL); | 303 ASSERT(isolate_ != NULL); |
| (...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 383 return Thread::name##_entry_point_offset(); \ | 383 return Thread::name##_entry_point_offset(); \ |
| 384 } | 384 } |
| 385 LEAF_RUNTIME_ENTRY_LIST(COMPUTE_OFFSET) | 385 LEAF_RUNTIME_ENTRY_LIST(COMPUTE_OFFSET) |
| 386 #undef COMPUTE_OFFSET | 386 #undef COMPUTE_OFFSET |
| 387 | 387 |
| 388 UNREACHABLE(); | 388 UNREACHABLE(); |
| 389 return -1; | 389 return -1; |
| 390 } | 390 } |
| 391 | 391 |
| 392 } // namespace dart | 392 } // namespace dart |
| OLD | NEW |