| 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/os_thread.h" | 5 #include "vm/os_thread.h" |
| 6 | 6 |
| 7 #include "vm/atomic.h" | 7 #include "vm/atomic.h" |
| 8 #include "vm/lockers.h" | 8 #include "vm/lockers.h" |
| 9 #include "vm/log.h" | 9 #include "vm/log.h" |
| 10 #include "vm/thread_interrupter.h" | 10 #include "vm/thread_interrupter.h" |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 44 OSThread* os_thread = new OSThread(); | 44 OSThread* os_thread = new OSThread(); |
| 45 AddThreadToListLocked(os_thread); | 45 AddThreadToListLocked(os_thread); |
| 46 return os_thread; | 46 return os_thread; |
| 47 } | 47 } |
| 48 | 48 |
| 49 | 49 |
| 50 OSThread::~OSThread() { | 50 OSThread::~OSThread() { |
| 51 RemoveThreadFromList(this); | 51 RemoveThreadFromList(this); |
| 52 delete log_; | 52 delete log_; |
| 53 log_ = NULL; | 53 log_ = NULL; |
| 54 if (Timeline::recorder() != NULL) { | 54 if (FLAG_support_timeline) { |
| 55 Timeline::recorder()->FinishBlock(timeline_block_); | 55 if (Timeline::recorder() != NULL) { |
| 56 Timeline::recorder()->FinishBlock(timeline_block_); |
| 57 } |
| 56 } | 58 } |
| 57 timeline_block_ = NULL; | 59 timeline_block_ = NULL; |
| 58 delete timeline_block_lock_; | 60 delete timeline_block_lock_; |
| 59 free(name_); | 61 free(name_); |
| 60 } | 62 } |
| 61 | 63 |
| 62 | 64 |
| 63 void OSThread::DisableThreadInterrupts() { | 65 void OSThread::DisableThreadInterrupts() { |
| 64 ASSERT(OSThread::Current() == this); | 66 ASSERT(OSThread::Current() == this); |
| 65 AtomicOperations::FetchAndIncrement(&thread_interrupt_disabled_); | 67 AtomicOperations::FetchAndIncrement(&thread_interrupt_disabled_); |
| 66 } | 68 } |
| 67 | 69 |
| 68 | 70 |
| 69 void OSThread::EnableThreadInterrupts() { | 71 void OSThread::EnableThreadInterrupts() { |
| 70 ASSERT(OSThread::Current() == this); | 72 ASSERT(OSThread::Current() == this); |
| 71 uintptr_t old = | 73 uintptr_t old = |
| 72 AtomicOperations::FetchAndDecrement(&thread_interrupt_disabled_); | 74 AtomicOperations::FetchAndDecrement(&thread_interrupt_disabled_); |
| 73 if (old == 1) { | 75 if (FLAG_profiler && (old == 1)) { |
| 74 // We just decremented from 1 to 0. | 76 // We just decremented from 1 to 0. |
| 75 // Make sure the thread interrupter is awake. | 77 // Make sure the thread interrupter is awake. |
| 76 ThreadInterrupter::WakeUp(); | 78 ThreadInterrupter::WakeUp(); |
| 77 } | 79 } |
| 78 if (old == 0) { | 80 if (old == 0) { |
| 79 // We just decremented from 0, this means we've got a mismatched pair | 81 // We just decremented from 0, this means we've got a mismatched pair |
| 80 // of calls to EnableThreadInterrupts and DisableThreadInterrupts. | 82 // of calls to EnableThreadInterrupts and DisableThreadInterrupts. |
| 81 FATAL("Invalid call to OSThread::EnableThreadInterrupts()"); | 83 FATAL("Invalid call to OSThread::EnableThreadInterrupts()"); |
| 82 } | 84 } |
| 83 } | 85 } |
| (...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 268 | 270 |
| 269 OSThread* OSThreadIterator::Next() { | 271 OSThread* OSThreadIterator::Next() { |
| 270 ASSERT(OSThread::thread_list_lock_ != NULL); | 272 ASSERT(OSThread::thread_list_lock_ != NULL); |
| 271 ASSERT(OSThread::thread_list_lock_->IsOwnedByCurrentThread()); | 273 ASSERT(OSThread::thread_list_lock_->IsOwnedByCurrentThread()); |
| 272 OSThread* current = next_; | 274 OSThread* current = next_; |
| 273 next_ = next_->thread_list_next_; | 275 next_ = next_->thread_list_next_; |
| 274 return current; | 276 return current; |
| 275 } | 277 } |
| 276 | 278 |
| 277 } // namespace dart | 279 } // namespace dart |
| OLD | NEW |