Lines Matching refs:self

57     Thread* self = Thread::Current();  in ~ThreadList()  local
58 MutexLock mu(self, *Locks::thread_list_lock_); in ~ThreadList()
59 contains = Contains(self); in ~ThreadList()
124 Thread* self = Thread::Current(); in DumpUnattachedThreads() local
132 MutexLock mu(self, *Locks::thread_list_lock_); in DumpUnattachedThreads()
151 void ThreadList::AssertThreadsAreSuspended(Thread* self, Thread* ignore1, Thread* ignore2) { in AssertThreadsAreSuspended() argument
152 MutexLock mu(self, *Locks::thread_list_lock_); in AssertThreadsAreSuspended()
153 MutexLock mu2(self, *Locks::thread_suspend_count_lock_); in AssertThreadsAreSuspended()
182 static void ThreadSuspendSleep(Thread* self, useconds_t* delay_us, useconds_t* total_delay_us) { in ThreadSuspendSleep() argument
199 Thread* self = Thread::Current(); in RunCheckpoint() local
200 Locks::mutator_lock_->AssertNotExclusiveHeld(self); in RunCheckpoint()
201 Locks::thread_list_lock_->AssertNotHeld(self); in RunCheckpoint()
202 Locks::thread_suspend_count_lock_->AssertNotHeld(self); in RunCheckpoint()
204 CHECK_NE(self->GetState(), kRunnable); in RunCheckpoint()
212 MutexLock mu(self, *Locks::thread_list_lock_); in RunCheckpoint()
213 MutexLock mu2(self, *Locks::thread_suspend_count_lock_); in RunCheckpoint()
215 if (thread != self) { in RunCheckpoint()
228 thread->ModifySuspendCount(self, +1, false); in RunCheckpoint()
238 checkpoint_function->Run(self); in RunCheckpoint()
247 ThreadSuspendSleep(self, &delay_us, &total_delay_us); in RunCheckpoint()
258 MutexLock mu2(self, *Locks::thread_suspend_count_lock_); in RunCheckpoint()
259 thread->ModifySuspendCount(self, -1, false); in RunCheckpoint()
266 MutexLock mu2(self, *Locks::thread_suspend_count_lock_); in RunCheckpoint()
267 Thread::resume_cond_->Broadcast(self); in RunCheckpoint()
277 Thread* self = Thread::Current(); in RunCheckpointOnRunnableThreads() local
279 Locks::mutator_lock_->AssertNotExclusiveHeld(self); in RunCheckpointOnRunnableThreads()
280 Locks::thread_list_lock_->AssertNotHeld(self); in RunCheckpointOnRunnableThreads()
281 Locks::thread_suspend_count_lock_->AssertNotHeld(self); in RunCheckpointOnRunnableThreads()
282 CHECK_NE(self->GetState(), kRunnable); in RunCheckpointOnRunnableThreads()
288 MutexLock mu(self, *Locks::thread_list_lock_); in RunCheckpointOnRunnableThreads()
289 MutexLock mu2(self, *Locks::thread_suspend_count_lock_); in RunCheckpointOnRunnableThreads()
291 if (thread != self) { in RunCheckpointOnRunnableThreads()
305 Thread* self = Thread::Current(); in SuspendAll() local
307 if (self != nullptr) { in SuspendAll()
308 VLOG(threads) << *self << " SuspendAll starting..."; in SuspendAll()
315 Locks::mutator_lock_->AssertNotHeld(self); in SuspendAll()
316 Locks::thread_list_lock_->AssertNotHeld(self); in SuspendAll()
317 Locks::thread_suspend_count_lock_->AssertNotHeld(self); in SuspendAll()
318 if (kDebugLocking && self != nullptr) { in SuspendAll()
319 CHECK_NE(self->GetState(), kRunnable); in SuspendAll()
322 MutexLock mu(self, *Locks::thread_list_lock_); in SuspendAll()
323 MutexLock mu2(self, *Locks::thread_suspend_count_lock_); in SuspendAll()
328 if (thread == self) { in SuspendAll()
332 thread->ModifySuspendCount(self, +1, false); in SuspendAll()
339 if (!Locks::mutator_lock_->ExclusiveLockWithTimeout(self, 30 * 1000, 0)) { in SuspendAll()
343 Locks::mutator_lock_->ExclusiveLock(self); in SuspendAll()
353 AssertThreadsAreSuspended(self, self); in SuspendAll()
359 if (self != nullptr) { in SuspendAll()
360 VLOG(threads) << *self << " SuspendAll complete"; in SuspendAll()
367 Thread* self = Thread::Current(); in ResumeAll() local
369 if (self != nullptr) { in ResumeAll()
370 VLOG(threads) << *self << " ResumeAll starting"; in ResumeAll()
380 AssertThreadsAreSuspended(self, self); in ResumeAll()
383 Locks::mutator_lock_->ExclusiveUnlock(self); in ResumeAll()
385 MutexLock mu(self, *Locks::thread_list_lock_); in ResumeAll()
386 MutexLock mu2(self, *Locks::thread_suspend_count_lock_); in ResumeAll()
391 if (thread == self) { in ResumeAll()
394 thread->ModifySuspendCount(self, -1, false); in ResumeAll()
399 if (self != nullptr) { in ResumeAll()
400 VLOG(threads) << *self << " ResumeAll waking others"; in ResumeAll()
404 Thread::resume_cond_->Broadcast(self); in ResumeAll()
408 if (self != nullptr) { in ResumeAll()
409 VLOG(threads) << *self << " ResumeAll complete"; in ResumeAll()
416 Thread* self = Thread::Current(); in Resume() local
417 DCHECK_NE(thread, self); in Resume()
423 MutexLock mu(self, *Locks::thread_list_lock_); in Resume()
425 MutexLock mu2(self, *Locks::thread_suspend_count_lock_); in Resume()
434 thread->ModifySuspendCount(self, -1, for_debugger); in Resume()
439 MutexLock mu(self, *Locks::thread_suspend_count_lock_); in Resume()
440 Thread::resume_cond_->Broadcast(self); in Resume()
446 static void ThreadSuspendByPeerWarning(Thread* self, int level, const char* message, jobject peer) { in ThreadSuspendByPeerWarning() argument
447 JNIEnvExt* env = self->GetJniEnv(); in ThreadSuspendByPeerWarning()
467 Thread* self = Thread::Current(); in SuspendThreadByPeer() local
477 ScopedObjectAccess soa(self); in SuspendThreadByPeer()
478 MutexLock mu(self, *Locks::thread_list_lock_); in SuspendThreadByPeer()
481 ThreadSuspendByPeerWarning(self, WARNING, "No such thread for suspend", peer); in SuspendThreadByPeer()
491 MutexLock mu(self, *Locks::thread_suspend_count_lock_); in SuspendThreadByPeer()
493 thread->ModifySuspendCount(self, +1, debug_suspension); in SuspendThreadByPeer()
504 CHECK_NE(thread, self) << "Attempt to suspend the current thread for the debugger"; in SuspendThreadByPeer()
513 ThreadSuspendByPeerWarning(self, FATAL, "Thread suspension timed out", peer); in SuspendThreadByPeer()
524 ThreadSuspendSleep(self, &delay_us, &total_delay_us); in SuspendThreadByPeer()
539 Thread* self = Thread::Current(); in SuspendThreadByThreadId() local
549 ScopedObjectAccess soa(self); in SuspendThreadByThreadId()
550 MutexLock mu(self, *Locks::thread_list_lock_); in SuspendThreadByThreadId()
568 MutexLock mu(self, *Locks::thread_suspend_count_lock_); in SuspendThreadByThreadId()
570 thread->ModifySuspendCount(self, +1, debug_suspension); in SuspendThreadByThreadId()
581 CHECK_NE(thread, self) << "Attempt to suspend the current thread for the debugger"; in SuspendThreadByThreadId()
601 ThreadSuspendSleep(self, &delay_us, &total_delay_us); in SuspendThreadByThreadId()
606 Thread* self = Thread::Current(); in FindThreadByThreadId() local
607 MutexLock mu(self, *Locks::thread_list_lock_); in FindThreadByThreadId()
610 CHECK(thread == self || thread->IsSuspended()); in FindThreadByThreadId()
618 Thread* self = Thread::Current(); in SuspendAllForDebugger() local
621 VLOG(threads) << *self << " SuspendAllForDebugger starting..."; in SuspendAllForDebugger()
624 MutexLock mu(self, *Locks::thread_list_lock_); in SuspendAllForDebugger()
626 MutexLock mu(self, *Locks::thread_suspend_count_lock_); in SuspendAllForDebugger()
633 if (thread == self || thread == debug_thread) { in SuspendAllForDebugger()
637 thread->ModifySuspendCount(self, +1, true); in SuspendAllForDebugger()
646 if (!Locks::mutator_lock_->ExclusiveLockWithTimeout(self, 30 * 1000, 0)) { in SuspendAllForDebugger()
649 Locks::mutator_lock_->ExclusiveUnlock(self); in SuspendAllForDebugger()
652 Locks::mutator_lock_->ExclusiveLock(self); in SuspendAllForDebugger()
653 Locks::mutator_lock_->ExclusiveUnlock(self); in SuspendAllForDebugger()
655 AssertThreadsAreSuspended(self, self, debug_thread); in SuspendAllForDebugger()
657 VLOG(threads) << *self << " SuspendAllForDebugger complete"; in SuspendAllForDebugger()
661 Thread* self = Thread::Current(); in SuspendSelfForDebugger() local
666 CHECK(self != debug_thread); in SuspendSelfForDebugger()
667 CHECK_NE(self->GetState(), kRunnable); in SuspendSelfForDebugger()
668 Locks::mutator_lock_->AssertNotHeld(self); in SuspendSelfForDebugger()
674 MutexLock mu(self, *Locks::thread_suspend_count_lock_); in SuspendSelfForDebugger()
675 self->ModifySuspendCount(self, +1, true); in SuspendSelfForDebugger()
676 CHECK_GT(self->GetSuspendCount(), 0); in SuspendSelfForDebugger()
679 VLOG(threads) << *self << " self-suspending (debugger)"; in SuspendSelfForDebugger()
682 DebugInvokeReq* pReq = self->GetInvokeReq(); in SuspendSelfForDebugger()
689 MutexLock mu(self, pReq->lock); in SuspendSelfForDebugger()
690 pReq->cond.Signal(self); in SuspendSelfForDebugger()
699 MutexLock mu(self, *Locks::thread_suspend_count_lock_); in SuspendSelfForDebugger()
700 while (self->GetSuspendCount() != 0) { in SuspendSelfForDebugger()
701 Thread::resume_cond_->Wait(self); in SuspendSelfForDebugger()
702 if (self->GetSuspendCount() != 0) { in SuspendSelfForDebugger()
709 VLOG(jdwp) << *self << " still suspended after undo " in SuspendSelfForDebugger()
710 << "(suspend count=" << self->GetSuspendCount() << ", " in SuspendSelfForDebugger()
711 << "debug suspend count=" << self->GetDebugSuspendCount() << ")"; in SuspendSelfForDebugger()
714 CHECK_EQ(self->GetSuspendCount(), 0); in SuspendSelfForDebugger()
717 VLOG(threads) << *self << " self-reviving (debugger)"; in SuspendSelfForDebugger()
721 Thread* self = Thread::Current(); in ResumeAllForDebugger() local
724 VLOG(threads) << *self << " ResumeAllForDebugger starting..."; in ResumeAllForDebugger()
727 Locks::mutator_lock_->AssertNotExclusiveHeld(self); in ResumeAllForDebugger()
730 MutexLock mu(self, *Locks::thread_list_lock_); in ResumeAllForDebugger()
732 MutexLock mu(self, *Locks::thread_suspend_count_lock_); in ResumeAllForDebugger()
749 if (thread == self || thread == debug_thread) { in ResumeAllForDebugger()
757 thread->ModifySuspendCount(self, -1, true); in ResumeAllForDebugger()
763 MutexLock mu(self, *Locks::thread_suspend_count_lock_); in ResumeAllForDebugger()
764 Thread::resume_cond_->Broadcast(self); in ResumeAllForDebugger()
767 VLOG(threads) << *self << " ResumeAllForDebugger complete"; in ResumeAllForDebugger()
771 Thread* self = Thread::Current(); in UndoDebuggerSuspensions() local
773 VLOG(threads) << *self << " UndoDebuggerSuspensions starting"; in UndoDebuggerSuspensions()
776 MutexLock mu(self, *Locks::thread_list_lock_); in UndoDebuggerSuspensions()
777 MutexLock mu2(self, *Locks::thread_suspend_count_lock_); in UndoDebuggerSuspensions()
783 if (thread == self || thread->GetDebugSuspendCount() == 0) { in UndoDebuggerSuspensions()
786 thread->ModifySuspendCount(self, -thread->GetDebugSuspendCount(), true); in UndoDebuggerSuspensions()
791 MutexLock mu(self, *Locks::thread_suspend_count_lock_); in UndoDebuggerSuspensions()
792 Thread::resume_cond_->Broadcast(self); in UndoDebuggerSuspensions()
795 VLOG(threads) << "UndoDebuggerSuspensions(" << *self << ") complete"; in UndoDebuggerSuspensions()
799 Thread* self = Thread::Current(); in WaitForOtherNonDaemonThreadsToExit() local
800 Locks::mutator_lock_->AssertNotHeld(self); in WaitForOtherNonDaemonThreadsToExit()
805 MutexLock mu(self, *Locks::runtime_shutdown_lock_); in WaitForOtherNonDaemonThreadsToExit()
810 MutexLock mu(self, *Locks::thread_list_lock_); in WaitForOtherNonDaemonThreadsToExit()
812 if (thread != self && !thread->IsDaemon()) { in WaitForOtherNonDaemonThreadsToExit()
819 thread_exit_cond_.Wait(self); in WaitForOtherNonDaemonThreadsToExit()
825 Thread* self = Thread::Current(); in SuspendAllDaemonThreads() local
826 MutexLock mu(self, *Locks::thread_list_lock_); in SuspendAllDaemonThreads()
828 MutexLock mu2(self, *Locks::thread_suspend_count_lock_); in SuspendAllDaemonThreads()
833 if (thread != self) { in SuspendAllDaemonThreads()
834 thread->ModifySuspendCount(self, +1, false); in SuspendAllDaemonThreads()
844 if (thread != self && thread->GetState() == kRunnable) { in SuspendAllDaemonThreads()
858 void ThreadList::Register(Thread* self) { in Register() argument
859 DCHECK_EQ(self, Thread::Current()); in Register()
863 self->ShortDump(oss); // We don't hold the mutator_lock_ yet and so cannot call Dump. in Register()
864 LOG(INFO) << "ThreadList::Register() " << *self << "\n" << oss.str(); in Register()
869 MutexLock mu(self, *Locks::thread_list_lock_); in Register()
870 MutexLock mu2(self, *Locks::thread_suspend_count_lock_); in Register()
875 self->ModifySuspendCount(self, +1, true); in Register()
878 self->ModifySuspendCount(self, +1, false); in Register()
880 CHECK(!Contains(self)); in Register()
881 list_.push_back(self); in Register()
884 void ThreadList::Unregister(Thread* self) { in Unregister() argument
885 DCHECK_EQ(self, Thread::Current()); in Unregister()
887 VLOG(threads) << "ThreadList::Unregister() " << *self; in Unregister()
891 self->Destroy(); in Unregister()
894 Trace::StoreExitingThreadInfo(self); in Unregister()
896 uint32_t thin_lock_id = self->GetThreadId(); in Unregister()
897 while (self != nullptr) { in Unregister()
901 Locks::thread_list_lock_->ExclusiveLock(self); in Unregister()
902 if (!Contains(self)) { in Unregister()
906 self = nullptr; in Unregister()
910 if (!self->IsSuspended()) { in Unregister()
911 list_.remove(self); in Unregister()
912 delete self; in Unregister()
913 self = nullptr; in Unregister()
916 Locks::thread_list_lock_->ExclusiveUnlock(self); in Unregister()
945 uint32_t ThreadList::AllocThreadId(Thread* self) { in AllocThreadId() argument
946 MutexLock mu(self, *Locks::allocated_thread_ids_lock_); in AllocThreadId()
957 void ThreadList::ReleaseThreadId(Thread* self, uint32_t id) { in ReleaseThreadId() argument
958 MutexLock mu(self, *Locks::allocated_thread_ids_lock_); in ReleaseThreadId()