Lines Matching refs:self

93   Thread* self = Thread::Current();  in ShutDown()  local
95 MutexLock mu(self, *Locks::thread_list_lock_); in ShutDown()
96 contains = Contains(self); in ShutDown()
164 Thread* self = Thread::Current(); in DumpUnattachedThreads() local
172 MutexLock mu(self, *Locks::thread_list_lock_); in DumpUnattachedThreads()
203 Thread* self = Thread::Current(); in Run() local
204 CHECK(self != nullptr); in Run()
208 ScopedObjectAccess soa(self); in Run()
212 MutexLock mu(self, lock_); in Run()
217 barrier_.Pass(self); in Run()
221 void Dump(Thread* self, std::ostream& os) { in Dump() argument
222 MutexLock mu(self, lock_); in Dump()
229 Thread* self = Thread::Current(); in WaitForThreadsToRunThroughCheckpoint() local
230 ScopedThreadStateChange tsc(self, ThreadState::kWaitingForCheckPointsToRun); in WaitForThreadsToRunThroughCheckpoint()
231 bool timed_out = barrier_.Increment(self, threads_running_checkpoint, kDumpWaitTimeout); in WaitForThreadsToRunThroughCheckpoint()
253 Thread* self = Thread::Current(); in Dump() local
255 MutexLock mu(self, *Locks::thread_list_lock_); in Dump()
258 if (self != nullptr) { in Dump()
263 ScopedObjectAccess soa(self); in Dump()
269 checkpoint.Dump(self, os); in Dump()
275 void ThreadList::AssertOtherThreadsAreSuspended(Thread* self) { in AssertOtherThreadsAreSuspended() argument
276 MutexLock mu(self, *Locks::thread_list_lock_); in AssertOtherThreadsAreSuspended()
277 MutexLock mu2(self, *Locks::thread_suspend_count_lock_); in AssertOtherThreadsAreSuspended()
279 if (thread != self) { in AssertOtherThreadsAreSuspended()
309 Thread* self = Thread::Current(); in RunCheckpoint() local
310 Locks::mutator_lock_->AssertNotExclusiveHeld(self); in RunCheckpoint()
311 Locks::thread_list_lock_->AssertNotHeld(self); in RunCheckpoint()
312 Locks::thread_suspend_count_lock_->AssertNotHeld(self); in RunCheckpoint()
319 MutexLock mu(self, *Locks::thread_list_lock_); in RunCheckpoint()
321 self->DisallowPreMonitorMutexes(); in RunCheckpoint()
323 MutexLock mu2(self, *Locks::thread_suspend_count_lock_); in RunCheckpoint()
326 if (thread != self) { in RunCheckpoint()
333 thread->DecrementSuspendCount(self); in RunCheckpoint()
334 Thread::resume_cond_->Broadcast(self); in RunCheckpoint()
344 thread->IncrementSuspendCount(self); in RunCheckpoint()
366 callback->Run(self); in RunCheckpoint()
371 checkpoint_function->Run(self); in RunCheckpoint()
373 bool mutator_lock_held = Locks::mutator_lock_->IsSharedHeld(self); in RunCheckpoint()
385 Thread::EnsureFlipFunctionStarted(self, thread); in RunCheckpoint()
397 MutexLock mu2(self, *Locks::thread_suspend_count_lock_); in RunCheckpoint()
398 thread->DecrementSuspendCount(self); in RunCheckpoint()
413 MutexLock mu2(self, *Locks::thread_suspend_count_lock_); in RunCheckpoint()
414 Thread::resume_cond_->Broadcast(self); in RunCheckpoint()
418 self->AllowPreMonitorMutexes(); in RunCheckpoint()
424 Thread* self = Thread::Current(); in RunEmptyCheckpoint() local
425 Locks::mutator_lock_->AssertNotExclusiveHeld(self); in RunEmptyCheckpoint()
426 Locks::thread_list_lock_->AssertNotHeld(self); in RunEmptyCheckpoint()
427 Locks::thread_suspend_count_lock_->AssertNotHeld(self); in RunEmptyCheckpoint()
431 barrier->Init(self, 0); in RunEmptyCheckpoint()
433 MutexLock mu(self, *Locks::thread_list_lock_); in RunEmptyCheckpoint()
434 MutexLock mu2(self, *Locks::thread_suspend_count_lock_); in RunEmptyCheckpoint()
436 if (thread != self) { in RunEmptyCheckpoint()
459 Runtime::Current()->GetHeap()->GetReferenceProcessor()->BroadcastForSlowPath(self); in RunEmptyCheckpoint()
462 ScopedThreadStateChange tsc(self, ThreadState::kWaitingForCheckPointsToRun); in RunEmptyCheckpoint()
480 bool timed_out = barrier->Increment(self, barrier_count, kEmptyCheckpointPeriodicTimeoutMs); in RunEmptyCheckpoint()
489 ss << "Barrier count " << barrier->GetCount(self) << "\n"; in RunEmptyCheckpoint()
501 ScopedObjectAccess soa(self); in RunEmptyCheckpoint()
502 MutexLock mu1(self, *Locks::thread_list_lock_); in RunEmptyCheckpoint()
529 ALWAYS_INLINE void AcquireMutatorLockSharedUncontended(Thread* self) in AcquireMutatorLockSharedUncontended() argument
531 bool success = Locks::mutator_lock_->SharedTryLock(self, /*check=*/false); in AcquireMutatorLockSharedUncontended()
544 Thread* self = Thread::Current(); in FlipThreadRoots() local
545 Locks::mutator_lock_->AssertNotHeld(self); in FlipThreadRoots()
546 Locks::thread_list_lock_->AssertNotHeld(self); in FlipThreadRoots()
547 Locks::thread_suspend_count_lock_->AssertNotHeld(self); in FlipThreadRoots()
548 CHECK_NE(self->GetState(), ThreadState::kRunnable); in FlipThreadRoots()
550 collector->GetHeap()->ThreadFlipBegin(self); // Sync with JNI critical calls. in FlipThreadRoots()
558 SuspendAllInternal(self); in FlipThreadRoots()
574 Locks::mutator_lock_->ExclusiveLock(self); in FlipThreadRoots()
576 flip_callback->Run(self); in FlipThreadRoots()
579 MutexLock mu(self, *Locks::thread_list_lock_); in FlipThreadRoots()
580 MutexLock mu2(self, *Locks::thread_suspend_count_lock_); in FlipThreadRoots()
588 DCHECK(thread == self || thread->IsSuspended()); in FlipThreadRoots()
592 int thread_index = thread == self ? 0 : i++; in FlipThreadRoots()
612 MutexLock mu(self, *Locks::thread_list_lock_); in FlipThreadRoots()
613 Locks::thread_suspend_count_lock_->Lock(self); in FlipThreadRoots()
614 ResumeAllInternal(self); in FlipThreadRoots()
630 AcquireMutatorLockSharedUncontended(self); in FlipThreadRoots()
632 Locks::thread_suspend_count_lock_->Unlock(self); in FlipThreadRoots()
635 collector->GetHeap()->ThreadFlipEnd(self); in FlipThreadRoots()
640 self, flipping_threads[i], Thread::StateAndFlags(0), &exit_flags[i], &finished); in FlipThreadRoots()
642 MutexLock mu2(self, *Locks::thread_list_lock_); in FlipThreadRoots()
650 flipping_threads[i]->WaitForFlipFunctionTestingExited(self, &exit_flags[i]); in FlipThreadRoots()
651 MutexLock mu2(self, *Locks::thread_list_lock_); in FlipThreadRoots()
658 Locks::mutator_lock_->SharedUnlock(self); in FlipThreadRoots()
770 Thread* self = Thread::Current(); in SuspendAll() local
772 if (self != nullptr) { in SuspendAll()
773 VLOG(threads) << *self << " SuspendAll for " << cause << " starting..."; in SuspendAll()
781 SuspendAllInternal(self); in SuspendAll()
786 if (Locks::mutator_lock_->ExclusiveLockWithTimeout(self, in SuspendAll()
798 Locks::mutator_lock_->ExclusiveLock(self); in SuspendAll()
812 AssertOtherThreadsAreSuspended(self); in SuspendAll()
817 DCHECK(!self->ReadFlag(ThreadFlag::kPendingFlipFunction)); in SuspendAll()
818 DCHECK(!self->ReadFlag(ThreadFlag::kRunningFlipFunction)); in SuspendAll()
822 if (self != nullptr) { in SuspendAll()
823 VLOG(threads) << *self << " SuspendAll complete"; in SuspendAll()
830 void ThreadList::SuspendAllInternal(Thread* self, SuspendReason reason) { in SuspendAllInternal() argument
832 Locks::mutator_lock_->AssertNotExclusiveHeld(self); in SuspendAllInternal()
833 Locks::thread_list_lock_->AssertNotHeld(self); in SuspendAllInternal()
834 Locks::thread_suspend_count_lock_->AssertNotHeld(self); in SuspendAllInternal()
835 if (kDebugLocking && self != nullptr) { in SuspendAllInternal()
836 CHECK_NE(self->GetState(), ThreadState::kRunnable); in SuspendAllInternal()
852 MutexLock mu(self, *Locks::thread_list_lock_); in SuspendAllInternal()
853 MutexLock mu2(self, *Locks::thread_suspend_count_lock_); in SuspendAllInternal()
861 pending_threads.store(list_.size() - (self == nullptr ? 0 : 1), std::memory_order_relaxed); in SuspendAllInternal()
864 if (thread == self) { in SuspendAllInternal()
869 thread->IncrementSuspendCount(self, &pending_threads, nullptr, reason); in SuspendAllInternal()
892 self->AtomicSetFlag(ThreadFlag::kSuspensionImmune, std::memory_order_relaxed); in SuspendAllInternal()
893 DCHECK(self == nullptr || found_myself); in SuspendAllInternal()
900 MutexLock mu2(self, *Locks::thread_suspend_count_lock_); in SuspendAllInternal()
904 Thread::resume_cond_->WaitHoldingLocks(self); in SuspendAllInternal()
922 MutexLock mu(self, *Locks::thread_list_lock_); in SuspendAllInternal()
923 MutexLock mu2(self, *Locks::thread_suspend_count_lock_); in SuspendAllInternal()
926 if (thread != self && !thread->IsSuspended()) { in SuspendAllInternal()
957 Thread* self = Thread::Current(); in ResumeAll() local
960 AssertOtherThreadsAreSuspended(self); in ResumeAll()
962 MutexLock mu(self, *Locks::thread_list_lock_); in ResumeAll()
963 MutexLock mu2(self, *Locks::thread_suspend_count_lock_); in ResumeAll()
965 ResumeAllInternal(self); in ResumeAll()
969 void ThreadList::ResumeAllInternal(Thread* self) { in ResumeAllInternal() argument
970 DCHECK_NE(self->GetState(), ThreadState::kRunnable); in ResumeAllInternal()
971 if (self != nullptr) { in ResumeAllInternal()
972 VLOG(threads) << *self << " ResumeAll starting"; in ResumeAllInternal()
981 Locks::mutator_lock_->ExclusiveUnlock(self); in ResumeAllInternal()
985 if (thread != self) { in ResumeAllInternal()
986 thread->DecrementSuspendCount(self); in ResumeAllInternal()
993 self->AtomicClearFlag(ThreadFlag::kSuspensionImmune, std::memory_order_relaxed); in ResumeAllInternal()
998 if (self != nullptr) { in ResumeAllInternal()
999 VLOG(threads) << *self << " ResumeAll waking others"; in ResumeAllInternal()
1003 Thread::resume_cond_->Broadcast(self); in ResumeAllInternal()
1005 if (self != nullptr) { in ResumeAllInternal()
1006 VLOG(threads) << *self << " ResumeAll complete"; in ResumeAllInternal()
1016 Thread* self = Thread::Current(); in Resume() local
1017 DCHECK_NE(thread, self); in Resume()
1022 MutexLock mu(self, *Locks::thread_list_lock_); in Resume()
1024 MutexLock mu2(self, *Locks::thread_suspend_count_lock_); in Resume()
1037 thread->DecrementSuspendCount(self, /*for_user_code=*/(reason == SuspendReason::kForUserCode)); in Resume()
1038 Thread::resume_cond_->Broadcast(self); in Resume()
1045 bool ThreadList::SuspendThread(Thread* self, in SuspendThread() argument
1064 Locks::mutator_lock_->AssertSharedHeld(self); in SuspendThread()
1065 Locks::thread_list_lock_->AssertHeld(self); in SuspendThread()
1070 CHECK_NE(thread, self) << func_name << "(self)"; in SuspendThread()
1073 MutexLock suspend_count_mu(self, *Locks::thread_suspend_count_lock_); in SuspendThread()
1074 if (LIKELY(self->GetSuspendCount() == 0)) { in SuspendThread()
1077 thread->IncrementSuspendCount(self, nullptr, &wrapped_barrier, reason); in SuspendThread()
1100 Locks::thread_list_lock_->ExclusiveUnlock(self); in SuspendThread()
1102 ScopedThreadSuspension sts(self, ThreadState::kSuspended); in SuspendThread()
1106 Locks::thread_list_lock_->ExclusiveLock(self); in SuspendThread()
1110 Locks::thread_list_lock_->ExclusiveUnlock(self); in SuspendThread()
1111 self->TransitionFromRunnableToSuspended(self_state); in SuspendThread()
1130 MutexLock suspend_count_mu(self, *Locks::thread_suspend_count_lock_); in SuspendThread()
1141 thread->DecrementSuspendCount(self, in SuspendThread()
1143 Thread::resume_cond_->Broadcast(self); in SuspendThread()
1150 MutexLock suspend_count_mu(self, *Locks::thread_suspend_count_lock_); in SuspendThread()
1190 MutexLock suspend_count_mu(self, *Locks::thread_suspend_count_lock_); in SuspendThread()
1197 Thread* const self = Thread::Current(); in SuspendThreadByPeer() local
1198 ThreadState old_self_state = self->GetState(); in SuspendThreadByPeer()
1199 self->TransitionFromSuspendedToRunnable(); in SuspendThreadByPeer()
1200 Locks::thread_list_lock_->ExclusiveLock(self); in SuspendThreadByPeer()
1201 ObjPtr<mirror::Object> thread_ptr = self->DecodeJObject(peer); in SuspendThreadByPeer()
1202 Thread* thread = Thread::FromManagedThread(self, thread_ptr); in SuspendThreadByPeer()
1213 Locks::thread_list_lock_->ExclusiveUnlock(self); in SuspendThreadByPeer()
1214 self->TransitionFromRunnableToSuspended(old_self_state); in SuspendThreadByPeer()
1219 bool success = SuspendThread(self, thread, reason, old_self_state, __func__, 0); in SuspendThreadByPeer()
1220 Locks::thread_list_lock_->AssertNotHeld(self); in SuspendThreadByPeer()
1227 Thread* const self = Thread::Current(); in SuspendThreadByThreadId() local
1228 ThreadState old_self_state = self->GetState(); in SuspendThreadByThreadId()
1231 self->TransitionFromSuspendedToRunnable(); in SuspendThreadByThreadId()
1232 Locks::thread_list_lock_->ExclusiveLock(self); in SuspendThreadByThreadId()
1237 Locks::thread_list_lock_->ExclusiveUnlock(self); in SuspendThreadByThreadId()
1238 self->TransitionFromRunnableToSuspended(old_self_state); in SuspendThreadByThreadId()
1244 bool success = SuspendThread(self, thread, reason, old_self_state, __func__, attempt_of_4); in SuspendThreadByThreadId()
1245 Locks::thread_list_lock_->AssertNotHeld(self); in SuspendThreadByThreadId()
1269 Thread* self = Thread::Current(); in WaitForOtherNonDaemonThreadsToExit() local
1270 Locks::mutator_lock_->AssertNotHeld(self); in WaitForOtherNonDaemonThreadsToExit()
1272 Locks::runtime_shutdown_lock_->Lock(self); in WaitForOtherNonDaemonThreadsToExit()
1281 Locks::runtime_shutdown_lock_->Unlock(self); in WaitForOtherNonDaemonThreadsToExit()
1286 MutexLock mu(self, *Locks::thread_list_lock_); in WaitForOtherNonDaemonThreadsToExit()
1287 Locks::runtime_shutdown_lock_->Unlock(self); in WaitForOtherNonDaemonThreadsToExit()
1294 if (thread != self && !thread->IsDaemon()) { in WaitForOtherNonDaemonThreadsToExit()
1304 Locks::thread_exit_cond_->Wait(self); in WaitForOtherNonDaemonThreadsToExit()
1310 Thread* self = Thread::Current(); in SuspendAllDaemonThreadsForShutdown() local
1314 MutexLock mu(self, *Locks::thread_list_lock_); in SuspendAllDaemonThreadsForShutdown()
1315 MutexLock mu2(self, *Locks::thread_suspend_count_lock_); in SuspendAllDaemonThreadsForShutdown()
1320 if (thread != self) { in SuspendAllDaemonThreadsForShutdown()
1321 thread->IncrementSuspendCount(self); in SuspendAllDaemonThreadsForShutdown()
1351 MutexLock mu(self, *Locks::thread_list_lock_); in SuspendAllDaemonThreadsForShutdown()
1353 if (thread != self && thread->GetState() == ThreadState::kRunnable) { in SuspendAllDaemonThreadsForShutdown()
1382 MutexLock mu(self, *Locks::thread_list_lock_); in SuspendAllDaemonThreadsForShutdown()
1388 DCHECK(thread == self || !all_suspended || thread->GetState() != ThreadState::kRunnable); in SuspendAllDaemonThreadsForShutdown()
1407 void ThreadList::Register(Thread* self) { in Register() argument
1408 DCHECK_EQ(self, Thread::Current()); in Register()
1413 self->ShortDump(oss); // We don't hold the mutator_lock_ yet and so cannot call Dump. in Register()
1414 LOG(INFO) << "ThreadList::Register() " << *self << "\n" << oss.str(); in Register()
1419 MutexLock mu(self, *Locks::thread_list_lock_); in Register()
1420 MutexLock mu2(self, *Locks::thread_suspend_count_lock_); in Register()
1422 self->IncrementSuspendCount(self); in Register()
1426 CHECK(!Contains(self)); in Register()
1427 list_.push_back(self); in Register()
1432 self->SetIsGcMarkingAndUpdateEntrypoints(cc->IsMarking()); in Register()
1434 self->SetReadBarrierEntrypoints(); in Register()
1436 self->SetWeakRefAccessEnabled(cc->IsWeakRefAccessEnabled()); in Register()
1440 void ThreadList::Unregister(Thread* self, bool should_run_callbacks) { in Unregister() argument
1441 DCHECK_EQ(self, Thread::Current()); in Unregister()
1442 CHECK_NE(self->GetState(), ThreadState::kRunnable); in Unregister()
1443 Locks::mutator_lock_->AssertNotHeld(self); in Unregister()
1444 if (self->tls32_.disable_thread_flip_count != 0) { in Unregister()
1445 LOG(FATAL) << "Incomplete PrimitiveArrayCritical section at exit: " << *self << "count = " in Unregister()
1446 << self->tls32_.disable_thread_flip_count; in Unregister()
1449 VLOG(threads) << "ThreadList::Unregister() " << *self; in Unregister()
1452 MutexLock mu(self, *Locks::thread_list_lock_); in Unregister()
1461 self->Destroy(should_run_callbacks); in Unregister()
1463 uint32_t thin_lock_id = self->GetThreadId(); in Unregister()
1469 MutexLock mu(self, *Locks::thread_list_lock_); in Unregister()
1470 if (!Contains(self)) { in Unregister()
1472 self->GetThreadName(thread_name); in Unregister()
1478 MutexLock mu2(self, *Locks::thread_suspend_count_lock_); in Unregister()
1479 Thread::StateAndFlags state_and_flags = self->GetStateAndFlags(std::memory_order_acquire); in Unregister()
1482 list_.remove(self); in Unregister()
1483 self->SignalExitFlags(); in Unregister()
1503 if (UNLIKELY(self->GetMethodTraceBuffer() != nullptr)) { in Unregister()
1504 Trace::ReleaseThreadBuffer(self); in Unregister()
1506 delete self; in Unregister()
1534 void ThreadList::WaitForUnregisterToComplete(Thread* self) { in WaitForUnregisterToComplete() argument
1538 Locks::thread_exit_cond_->Wait(self); in WaitForUnregisterToComplete()
1543 Thread* const self = Thread::Current(); in VisitRootsForSuspendedThreads() local
1548 MutexLock mu(self, *Locks::thread_list_lock_); in VisitRootsForSuspendedThreads()
1549 MutexLock mu2(self, *Locks::thread_suspend_count_lock_); in VisitRootsForSuspendedThreads()
1551 thread->IncrementSuspendCount(self); in VisitRootsForSuspendedThreads()
1552 if (thread == self || thread->IsSuspended()) { in VisitRootsForSuspendedThreads()
1555 thread->DecrementSuspendCount(self); in VisitRootsForSuspendedThreads()
1568 MutexLock mu2(self, *Locks::thread_suspend_count_lock_); in VisitRootsForSuspendedThreads()
1570 thread->DecrementSuspendCount(self); in VisitRootsForSuspendedThreads()
1572 Thread::resume_cond_->Broadcast(self); in VisitRootsForSuspendedThreads()
1597 uint32_t ThreadList::AllocThreadId(Thread* self) { in AllocThreadId() argument
1598 MutexLock mu(self, *Locks::allocated_thread_ids_lock_); in AllocThreadId()
1609 void ThreadList::ReleaseThreadId(Thread* self, uint32_t id) { in ReleaseThreadId() argument
1610 MutexLock mu(self, *Locks::allocated_thread_ids_lock_); in ReleaseThreadId()