Lines Matching refs:thread

114 bool ThreadList::Contains(Thread* thread) {  in Contains()  argument
115 return find(list_.begin(), list_.end(), thread) != list_.end(); in Contains()
125 for (const auto& thread : list_) { in DumpNativeStacks() local
126 os << "DUMPING THREAD " << thread->GetTid() << "\n"; in DumpNativeStacks()
127 DumpNativeStack(os, unwinder, thread->GetTid(), "\t"); in DumpNativeStacks()
170 Thread* thread; in DumpUnattachedThreads() local
173 thread = FindThreadByTid(tid); in DumpUnattachedThreads()
175 if (thread == nullptr) { in DumpUnattachedThreads()
200 void Run(Thread* thread) override { in Run() argument
209 dump_order = thread->Dump(local_os, unwinder_, dump_native_stack_); in Run()
214 std::pair<Thread::DumpOrder, uint32_t> sort_key(dump_order, thread->GetThreadId()); in Run()
278 for (const auto& thread : list_) { in AssertOtherThreadsAreSuspended() local
279 if (thread != self) { in AssertOtherThreadsAreSuspended()
280 CHECK(thread->IsSuspended()) in AssertOtherThreadsAreSuspended()
281 << "\nUnsuspended thread: <<" << *thread << "\n" in AssertOtherThreadsAreSuspended()
325 for (const auto& thread : list_) { in RunCheckpoint() local
326 if (thread != self) { in RunCheckpoint()
329 if (thread->RequestCheckpoint(checkpoint_function)) { in RunCheckpoint()
333 thread->DecrementSuspendCount(self); in RunCheckpoint()
344 thread->IncrementSuspendCount(self); in RunCheckpoint()
347 if (thread->IsSuspended()) { in RunCheckpoint()
357 DCHECK(thread->IsSuspended()); in RunCheckpoint()
358 suspended_count_modified_threads.push_back(thread); in RunCheckpoint()
378 for (auto& thread : suspended_count_modified_threads) { in RunCheckpoint() local
379 if (thread != nullptr) { in RunCheckpoint()
381 DCHECK(thread->IsSuspended()); in RunCheckpoint()
385 Thread::EnsureFlipFunctionStarted(self, thread); in RunCheckpoint()
386 if (thread->GetStateAndFlags(std::memory_order_acquire) in RunCheckpoint()
395 checkpoint_function->Run(thread); in RunCheckpoint()
398 thread->DecrementSuspendCount(self); in RunCheckpoint()
402 thread = nullptr; in RunCheckpoint()
408 [](Thread* thread) { return thread == nullptr; })); in RunCheckpoint() argument
435 for (Thread* thread : list_) { in RunEmptyCheckpoint()
436 if (thread != self) { in RunEmptyCheckpoint()
438 if (thread->RequestEmptyCheckpoint()) { in RunEmptyCheckpoint()
443 runnable_thread_ids.push_back(thread->GetThreadId()); in RunEmptyCheckpoint()
447 if (thread->GetState() != ThreadState::kRunnable) { in RunEmptyCheckpoint()
503 for (Thread* thread : GetList()) { in RunEmptyCheckpoint()
504 uint32_t tid = thread->GetThreadId(); in RunEmptyCheckpoint()
509 thread->ReadFlag(ThreadFlag::kEmptyCheckpointRequest)) { in RunEmptyCheckpoint()
512 thread->Dump(LOG_STREAM(FATAL_WITHOUT_ABORT), in RunEmptyCheckpoint()
585 for (Thread* thread : list_) { in FlipThreadRoots()
588 DCHECK(thread == self || thread->IsSuspended()); in FlipThreadRoots()
589 thread->SetFlipFunction(thread_flip_visitor); in FlipThreadRoots()
592 int thread_index = thread == self ? 0 : i++; in FlipThreadRoots()
593 flipping_threads[thread_index] = thread; in FlipThreadRoots()
594 thread->NotifyOnThreadExit(&exit_flags[thread_index]); in FlipThreadRoots()
863 for (const auto& thread : list_) { in SuspendAllInternal() local
864 if (thread == self) { in SuspendAllInternal()
867 VLOG(threads) << "requesting thread suspend: " << *thread; in SuspendAllInternal()
869 thread->IncrementSuspendCount(self, &pending_threads, nullptr, reason); in SuspendAllInternal()
870 if (thread->IsSuspended()) { in SuspendAllInternal()
875 DCHECK_EQ(thread->tlsPtr_.active_suspendall_barrier, &pending_threads); in SuspendAllInternal()
877 thread->tlsPtr_.active_suspendall_barrier = nullptr; in SuspendAllInternal()
878 if (!thread->HasActiveSuspendBarrier()) { in SuspendAllInternal()
879 thread->AtomicClearFlag(ThreadFlag::kActiveSuspendBarrier); in SuspendAllInternal()
925 for (const auto& thread : list_) { in SuspendAllInternal() local
926 if (thread != self && !thread->IsSuspended()) { in SuspendAllInternal()
927 culprit = thread; in SuspendAllInternal()
928 oss << *thread << ", "; in SuspendAllInternal()
984 for (const auto& thread : list_) { in ResumeAllInternal() local
985 if (thread != self) { in ResumeAllInternal()
986 thread->DecrementSuspendCount(self); in ResumeAllInternal()
1012 bool ThreadList::Resume(Thread* thread, SuspendReason reason) { in Resume() argument
1017 DCHECK_NE(thread, self); in Resume()
1018 VLOG(threads) << "Resume(" << reinterpret_cast<void*>(thread) << ") starting..." << reason; in Resume()
1025 if (UNLIKELY(!thread->IsSuspended())) { in Resume()
1027 << "Resume(" << reinterpret_cast<void*>(thread) << ") thread not suspended"; in Resume()
1030 if (!Contains(thread)) { in Resume()
1034 << "Resume(" << reinterpret_cast<void*>(thread) << ") thread not within thread list"; in Resume()
1037 thread->DecrementSuspendCount(self, /*for_user_code=*/(reason == SuspendReason::kForUserCode)); in Resume()
1041 VLOG(threads) << "Resume(" << reinterpret_cast<void*>(thread) << ") finished waking others"; in Resume()
1046 Thread* thread, in SuspendThread() argument
1053 pid_t tid = thread->GetTid(); in SuspendThread()
1060 thread->NotifyOnThreadExit(&tef); in SuspendThread()
1067 DCHECK(Contains(thread)); in SuspendThread()
1070 CHECK_NE(thread, self) << func_name << "(self)"; in SuspendThread()
1071 VLOG(threads) << func_name << " suspending: " << *thread; in SuspendThread()
1075 suspended_count = thread->suspended_count_; in SuspendThread()
1076 checkpoint_count = thread->checkpoint_count_; in SuspendThread()
1077 thread->IncrementSuspendCount(self, nullptr, &wrapped_barrier, reason); in SuspendThread()
1078 if (thread->IsSuspended()) { in SuspendThread()
1080 thread->RemoveFirstSuspend1Barrier(&wrapped_barrier); in SuspendThread()
1083 if (!thread->HasActiveSuspendBarrier()) { in SuspendThread()
1084 thread->AtomicClearFlag(ThreadFlag::kActiveSuspendBarrier); in SuspendThread()
1088 DCHECK_GT(thread->GetSuspendCount(), 0); in SuspendThread()
1109 thread->UnregisterThreadExitFlag(&tef); in SuspendThread()
1136 thread->RemoveSuspend1Barrier(&wrapped_barrier); in SuspendThread()
1137 if (!thread->HasActiveSuspendBarrier()) { in SuspendThread()
1138 thread->AtomicClearFlag(ThreadFlag::kActiveSuspendBarrier); in SuspendThread()
1141 thread->DecrementSuspendCount(self, in SuspendThread()
1147 thread->GetThreadName(name); in SuspendThread()
1151 first_barrier = thread->tlsPtr_.active_suspend1_barriers; in SuspendThread()
1159 thread->GetTid(), in SuspendThread()
1161 thread->GetStateAndFlags(std::memory_order_relaxed).GetValue(), in SuspendThread()
1162 thread->GetNativePriority(), in SuspendThread()
1166 thread->suspended_count_ - suspended_count, in SuspendThread()
1167 thread->checkpoint_count_ - checkpoint_count, in SuspendThread()
1174 thread->AbortInThis(message); in SuspendThread()
1180 VLOG(threads) << func_name << " suspended: " << *thread; in SuspendThread()
1183 thread->GetThreadName(name); in SuspendThread()
1185 StringPrintf("%s suspended %s for tid=%d", func_name, name.c_str(), thread->GetTid()) in SuspendThread()
1189 CHECK(thread->IsSuspended()); in SuspendThread()
1191 thread->CheckBarrierInactive(&wrapped_barrier); in SuspendThread()
1202 Thread* thread = Thread::FromManagedThread(self, thread_ptr); in SuspendThreadByPeer() local
1203 if (thread == nullptr || !Contains(thread)) { in SuspendThreadByPeer()
1204 if (thread == nullptr) { in SuspendThreadByPeer()
1211 << reinterpret_cast<void*>(thread); in SuspendThreadByPeer()
1217 VLOG(threads) << "SuspendThreadByPeer found thread: " << *thread; in SuspendThreadByPeer()
1219 bool success = SuspendThread(self, thread, reason, old_self_state, __func__, 0); in SuspendThreadByPeer()
1221 return success ? thread : nullptr; in SuspendThreadByPeer()
1233 Thread* thread = FindThreadByThreadId(thread_id); in SuspendThreadByThreadId() local
1234 if (thread == nullptr) { in SuspendThreadByThreadId()
1241 DCHECK(Contains(thread)); in SuspendThreadByThreadId()
1242 VLOG(threads) << "SuspendThreadByThreadId found thread: " << *thread; in SuspendThreadByThreadId()
1244 bool success = SuspendThread(self, thread, reason, old_self_state, __func__, attempt_of_4); in SuspendThreadByThreadId()
1246 return success ? thread : nullptr; in SuspendThreadByThreadId()
1250 for (const auto& thread : list_) { in FindThreadByThreadId() local
1251 if (thread->GetThreadId() == thread_id) { in FindThreadByThreadId()
1252 return thread; in FindThreadByThreadId()
1259 for (const auto& thread : list_) { in FindThreadByTid() local
1260 if (thread->GetTid() == tid) { in FindThreadByTid()
1261 return thread; in FindThreadByTid()
1293 for (const auto& thread : list_) { in WaitForOtherNonDaemonThreadsToExit() local
1294 if (thread != self && !thread->IsDaemon()) { in WaitForOtherNonDaemonThreadsToExit()
1316 for (const auto& thread : list_) { in SuspendAllDaemonThreadsForShutdown() local
1319 CHECK(thread->IsDaemon()) << *thread; in SuspendAllDaemonThreadsForShutdown()
1320 if (thread != self) { in SuspendAllDaemonThreadsForShutdown()
1321 thread->IncrementSuspendCount(self); in SuspendAllDaemonThreadsForShutdown()
1326 thread->GetJniEnv()->SetFunctionsToRuntimeShutdownFunctions(); in SuspendAllDaemonThreadsForShutdown()
1352 for (const auto& thread : list_) { in SuspendAllDaemonThreadsForShutdown() local
1353 if (thread != self && thread->GetState() == ThreadState::kRunnable) { in SuspendAllDaemonThreadsForShutdown()
1355 LOG(WARNING) << "daemon thread not yet suspended: " << *thread; in SuspendAllDaemonThreadsForShutdown()
1387 for (const auto& thread : list_) { in SuspendAllDaemonThreadsForShutdown() local
1388 DCHECK(thread == self || !all_suspended || thread->GetState() != ThreadState::kRunnable); in SuspendAllDaemonThreadsForShutdown()
1390 thread->GetJniEnv()->SetRuntimeDeleted(); in SuspendAllDaemonThreadsForShutdown()
1529 for (const auto& thread : list_) { in ForEach() local
1530 callback(thread, context); in ForEach()
1550 for (Thread* thread : list_) { in VisitRootsForSuspendedThreads()
1551 thread->IncrementSuspendCount(self); in VisitRootsForSuspendedThreads()
1552 if (thread == self || thread->IsSuspended()) { in VisitRootsForSuspendedThreads()
1553 threads_to_visit.push_back(thread); in VisitRootsForSuspendedThreads()
1555 thread->DecrementSuspendCount(self); in VisitRootsForSuspendedThreads()
1562 for (Thread* thread : threads_to_visit) { in VisitRootsForSuspendedThreads()
1563 thread->VisitRoots(visitor, kVisitRootFlagAllRoots); in VisitRootsForSuspendedThreads()
1569 for (Thread* thread : threads_to_visit) { in VisitRootsForSuspendedThreads()
1570 thread->DecrementSuspendCount(self); in VisitRootsForSuspendedThreads()
1578 for (const auto& thread : list_) { in VisitRoots() local
1579 thread->VisitRoots(visitor, flags); in VisitRoots()
1585 for (const auto& thread : list_) { in VisitReflectiveTargets() local
1586 thread->VisitReflectiveTargets(visitor); in VisitReflectiveTargets()
1592 for (const auto& thread : list_) { in SweepInterpreterCaches() local
1593 thread->SweepInterpreterCache(visitor); in SweepInterpreterCaches()