Lines Matching refs:self

87   Thread* self = Thread::Current();  in ~ThreadList()  local
89 MutexLock mu(self, *Locks::thread_list_lock_); in ~ThreadList()
90 contains = Contains(self); in ~ThreadList()
167 Thread* self = Thread::Current(); in DumpUnattachedThreads() local
175 MutexLock mu(self, *Locks::thread_list_lock_); in DumpUnattachedThreads()
202 Thread* self = Thread::Current(); in Run() local
203 CHECK(self != nullptr); in Run()
206 ScopedObjectAccess soa(self); in Run()
212 MutexLock mu(self, *Locks::logging_lock_); in Run()
215 barrier_.Pass(self); in Run()
219 Thread* self = Thread::Current(); in WaitForThreadsToRunThroughCheckpoint() local
220 ScopedThreadStateChange tsc(self, kWaitingForCheckPointsToRun); in WaitForThreadsToRunThroughCheckpoint()
221 bool timed_out = barrier_.Increment(self, threads_running_checkpoint, kDumpWaitTimeout); in WaitForThreadsToRunThroughCheckpoint()
241 Thread* self = Thread::Current(); in Dump() local
243 MutexLock mu(self, *Locks::thread_list_lock_); in Dump()
246 if (self != nullptr) { in Dump()
251 ScopedObjectAccess soa(self); in Dump()
262 void ThreadList::AssertThreadsAreSuspended(Thread* self, Thread* ignore1, Thread* ignore2) { in AssertThreadsAreSuspended() argument
263 MutexLock mu(self, *Locks::thread_list_lock_); in AssertThreadsAreSuspended()
264 MutexLock mu2(self, *Locks::thread_suspend_count_lock_); in AssertThreadsAreSuspended()
300 Thread* self = Thread::Current(); in RunCheckpoint() local
301 Locks::mutator_lock_->AssertNotExclusiveHeld(self); in RunCheckpoint()
302 Locks::thread_list_lock_->AssertNotHeld(self); in RunCheckpoint()
303 Locks::thread_suspend_count_lock_->AssertNotHeld(self); in RunCheckpoint()
310 MutexLock mu(self, *Locks::thread_list_lock_); in RunCheckpoint()
311 MutexLock mu2(self, *Locks::thread_suspend_count_lock_); in RunCheckpoint()
314 if (thread != self) { in RunCheckpoint()
326 bool updated = thread->ModifySuspendCount(self, +1, nullptr, false); in RunCheckpoint()
336 callback->Run(self); in RunCheckpoint()
341 checkpoint_function->Run(self); in RunCheckpoint()
368 MutexLock mu2(self, *Locks::thread_suspend_count_lock_); in RunCheckpoint()
369 bool updated = thread->ModifySuspendCount(self, -1, nullptr, false); in RunCheckpoint()
377 MutexLock mu2(self, *Locks::thread_suspend_count_lock_); in RunCheckpoint()
378 Thread::resume_cond_->Broadcast(self); in RunCheckpoint()
385 Thread* self = Thread::Current(); in RunEmptyCheckpoint() local
386 Locks::mutator_lock_->AssertNotExclusiveHeld(self); in RunEmptyCheckpoint()
387 Locks::thread_list_lock_->AssertNotHeld(self); in RunEmptyCheckpoint()
388 Locks::thread_suspend_count_lock_->AssertNotHeld(self); in RunEmptyCheckpoint()
392 barrier->Init(self, 0); in RunEmptyCheckpoint()
394 MutexLock mu(self, *Locks::thread_list_lock_); in RunEmptyCheckpoint()
395 MutexLock mu2(self, *Locks::thread_suspend_count_lock_); in RunEmptyCheckpoint()
397 if (thread != self) { in RunEmptyCheckpoint()
420 Runtime::Current()->GetHeap()->GetReferenceProcessor()->BroadcastForSlowPath(self); in RunEmptyCheckpoint()
423 ScopedThreadStateChange tsc(self, kWaitingForCheckPointsToRun); in RunEmptyCheckpoint()
441 bool timed_out = barrier->Increment(self, barrier_count, kEmptyCheckpointPeriodicTimeoutMs); in RunEmptyCheckpoint()
450 ss << "Barrier count " << barrier->GetCount(self) << "\n"; in RunEmptyCheckpoint()
462 ScopedObjectAccess soa(self); in RunEmptyCheckpoint()
463 MutexLock mu1(self, *Locks::thread_list_lock_); in RunEmptyCheckpoint()
493 Thread* self = Thread::Current(); in RunCheckpointOnRunnableThreads() local
494 Locks::mutator_lock_->AssertNotExclusiveHeld(self); in RunCheckpointOnRunnableThreads()
495 Locks::thread_list_lock_->AssertNotHeld(self); in RunCheckpointOnRunnableThreads()
496 Locks::thread_suspend_count_lock_->AssertNotHeld(self); in RunCheckpointOnRunnableThreads()
497 CHECK_NE(self->GetState(), kRunnable); in RunCheckpointOnRunnableThreads()
502 MutexLock mu(self, *Locks::thread_list_lock_); in RunCheckpointOnRunnableThreads()
503 MutexLock mu2(self, *Locks::thread_suspend_count_lock_); in RunCheckpointOnRunnableThreads()
505 if (thread != self) { in RunCheckpointOnRunnableThreads()
526 Thread* self = Thread::Current(); in FlipThreadRoots() local
527 Locks::mutator_lock_->AssertNotHeld(self); in FlipThreadRoots()
528 Locks::thread_list_lock_->AssertNotHeld(self); in FlipThreadRoots()
529 Locks::thread_suspend_count_lock_->AssertNotHeld(self); in FlipThreadRoots()
530 CHECK_NE(self->GetState(), kRunnable); in FlipThreadRoots()
532 collector->GetHeap()->ThreadFlipBegin(self); // Sync with JNI critical calls. in FlipThreadRoots()
537 SuspendAllInternal(self, self, nullptr); in FlipThreadRoots()
540 Locks::mutator_lock_->ExclusiveLock(self); in FlipThreadRoots()
542 flip_callback->Run(self); in FlipThreadRoots()
543 Locks::mutator_lock_->ExclusiveUnlock(self); in FlipThreadRoots()
551 MutexLock mu(self, *Locks::thread_list_lock_); in FlipThreadRoots()
552 MutexLock mu2(self, *Locks::thread_suspend_count_lock_); in FlipThreadRoots()
559 if (thread == self) { in FlipThreadRoots()
570 bool updated = thread->ModifySuspendCount(self, -1, nullptr, false); in FlipThreadRoots()
577 Thread::resume_cond_->Broadcast(self); in FlipThreadRoots()
580 collector->GetHeap()->ThreadFlipEnd(self); in FlipThreadRoots()
585 ReaderMutexLock mu(self, *Locks::mutator_lock_); in FlipThreadRoots()
593 Closure* flip_func = self->GetFlipFunction(); in FlipThreadRoots()
595 flip_func->Run(self); in FlipThreadRoots()
602 MutexLock mu2(self, *Locks::thread_suspend_count_lock_); in FlipThreadRoots()
604 bool updated = thread->ModifySuspendCount(self, -1, nullptr, false); in FlipThreadRoots()
607 Thread::resume_cond_->Broadcast(self); in FlipThreadRoots()
614 Thread* self = Thread::Current(); in SuspendAll() local
616 if (self != nullptr) { in SuspendAll()
617 VLOG(threads) << *self << " SuspendAll for " << cause << " starting..."; in SuspendAll()
625 SuspendAllInternal(self, self); in SuspendAll()
630 if (Locks::mutator_lock_->ExclusiveLockWithTimeout(self, in SuspendAll()
642 Locks::mutator_lock_->ExclusiveLock(self); in SuspendAll()
656 AssertThreadsAreSuspended(self, self); in SuspendAll()
661 if (self != nullptr) { in SuspendAll()
662 VLOG(threads) << *self << " SuspendAll complete"; in SuspendAll()
672 void ThreadList::SuspendAllInternal(Thread* self, in SuspendAllInternal() argument
676 Locks::mutator_lock_->AssertNotExclusiveHeld(self); in SuspendAllInternal()
677 Locks::thread_list_lock_->AssertNotHeld(self); in SuspendAllInternal()
678 Locks::thread_suspend_count_lock_->AssertNotHeld(self); in SuspendAllInternal()
679 if (kDebugLocking && self != nullptr) { in SuspendAllInternal()
680 CHECK_NE(self->GetState(), kRunnable); in SuspendAllInternal()
701 MutexLock mu(self, *Locks::thread_list_lock_); in SuspendAllInternal()
702 MutexLock mu2(self, *Locks::thread_suspend_count_lock_); in SuspendAllInternal()
715 bool updated = thread->ModifySuspendCount(self, +1, &pending_threads, debug_suspend); in SuspendAllInternal()
764 Thread* self = Thread::Current(); in ResumeAll() local
766 if (self != nullptr) { in ResumeAll()
767 VLOG(threads) << *self << " ResumeAll starting"; in ResumeAll()
778 AssertThreadsAreSuspended(self, self); in ResumeAll()
783 Locks::mutator_lock_->ExclusiveUnlock(self); in ResumeAll()
785 MutexLock mu(self, *Locks::thread_list_lock_); in ResumeAll()
786 MutexLock mu2(self, *Locks::thread_suspend_count_lock_); in ResumeAll()
791 if (thread == self) { in ResumeAll()
794 bool updated = thread->ModifySuspendCount(self, -1, nullptr, false); in ResumeAll()
800 if (self != nullptr) { in ResumeAll()
801 VLOG(threads) << *self << " ResumeAll waking others"; in ResumeAll()
805 Thread::resume_cond_->Broadcast(self); in ResumeAll()
808 if (self != nullptr) { in ResumeAll()
809 VLOG(threads) << *self << " ResumeAll complete"; in ResumeAll()
819 Thread* self = Thread::Current(); in Resume() local
820 DCHECK_NE(thread, self); in Resume()
826 MutexLock mu(self, *Locks::thread_list_lock_); in Resume()
828 MutexLock mu2(self, *Locks::thread_suspend_count_lock_); in Resume()
837 bool updated = thread->ModifySuspendCount(self, -1, nullptr, for_debugger); in Resume()
843 MutexLock mu(self, *Locks::thread_suspend_count_lock_); in Resume()
844 Thread::resume_cond_->Broadcast(self); in Resume()
850 static void ThreadSuspendByPeerWarning(Thread* self, in ThreadSuspendByPeerWarning() argument
854 JNIEnvExt* env = self->GetJniEnv(); in ThreadSuspendByPeerWarning()
874 Thread* const self = Thread::Current(); in SuspendThreadByPeer() local
885 ScopedObjectAccess soa(self); in SuspendThreadByPeer()
886 MutexLock thread_list_mu(self, *Locks::thread_list_lock_); in SuspendThreadByPeer()
890 MutexLock suspend_count_mu(self, *Locks::thread_suspend_count_lock_); in SuspendThreadByPeer()
900 ThreadSuspendByPeerWarning(self, in SuspendThreadByPeer()
914 MutexLock suspend_count_mu(self, *Locks::thread_suspend_count_lock_); in SuspendThreadByPeer()
916 if (self->GetSuspendCount() > 0) { in SuspendThreadByPeer()
924 bool updated = suspended_thread->ModifySuspendCount(self, +1, nullptr, debug_suspension); in SuspendThreadByPeer()
935 CHECK_NE(thread, self) << "Attempt to suspend the current thread for the debugger"; in SuspendThreadByPeer()
951 ThreadSuspendByPeerWarning(self, in SuspendThreadByPeer()
995 Thread* const self = Thread::Current(); in SuspendThreadByThreadId() local
1005 ScopedObjectAccess soa(self); in SuspendThreadByThreadId()
1006 MutexLock thread_list_mu(self, *Locks::thread_list_lock_); in SuspendThreadByThreadId()
1026 MutexLock suspend_count_mu(self, *Locks::thread_suspend_count_lock_); in SuspendThreadByThreadId()
1028 if (self->GetSuspendCount() > 0) { in SuspendThreadByThreadId()
1034 bool updated = thread->ModifySuspendCount(self, +1, nullptr, debug_suspension); in SuspendThreadByThreadId()
1046 CHECK_NE(thread, self) << "Attempt to suspend the current thread for the debugger"; in SuspendThreadByThreadId()
1096 Thread* self = Thread::Current(); in SuspendAllForDebugger() local
1099 VLOG(threads) << *self << " SuspendAllForDebugger starting..."; in SuspendAllForDebugger()
1101 SuspendAllInternal(self, self, debug_thread, true); in SuspendAllForDebugger()
1106 if (!Locks::mutator_lock_->ExclusiveLockWithTimeout(self, 30 * 1000, 0)) { in SuspendAllForDebugger()
1109 Locks::mutator_lock_->ExclusiveUnlock(self); in SuspendAllForDebugger()
1112 Locks::mutator_lock_->ExclusiveLock(self); in SuspendAllForDebugger()
1113 Locks::mutator_lock_->ExclusiveUnlock(self); in SuspendAllForDebugger()
1122 VLOG(threads) << *self << " SuspendAllForDebugger complete"; in SuspendAllForDebugger()
1126 Thread* const self = Thread::Current(); in SuspendSelfForDebugger() local
1127 self->SetReadyForDebugInvoke(true); in SuspendSelfForDebugger()
1131 CHECK(self != debug_thread); in SuspendSelfForDebugger()
1132 CHECK_NE(self->GetState(), kRunnable); in SuspendSelfForDebugger()
1133 Locks::mutator_lock_->AssertNotHeld(self); in SuspendSelfForDebugger()
1137 DebugInvokeReq* pReq = self->GetInvokeReq(); in SuspendSelfForDebugger()
1143 MutexLock mu(self, *Locks::thread_suspend_count_lock_); in SuspendSelfForDebugger()
1144 bool updated = self->ModifySuspendCount(self, +1, nullptr, true); in SuspendSelfForDebugger()
1146 CHECK_GT(self->GetSuspendCount(), 0); in SuspendSelfForDebugger()
1148 VLOG(threads) << *self << " self-suspending (debugger)"; in SuspendSelfForDebugger()
1151 MutexLock mu(self, *Locks::thread_suspend_count_lock_); in SuspendSelfForDebugger()
1152 CHECK_EQ(self->GetDebugSuspendCount(), 0) << "Debugger detached without resuming us"; in SuspendSelfForDebugger()
1154 VLOG(threads) << *self << " not self-suspending because debugger detached during invoke"; in SuspendSelfForDebugger()
1160 self->ClearDebugInvokeReq(); in SuspendSelfForDebugger()
1170 MutexLock mu(self, *Locks::thread_suspend_count_lock_); in SuspendSelfForDebugger()
1171 while (self->GetSuspendCount() != 0) { in SuspendSelfForDebugger()
1172 Thread::resume_cond_->Wait(self); in SuspendSelfForDebugger()
1173 if (self->GetSuspendCount() != 0) { in SuspendSelfForDebugger()
1180 VLOG(jdwp) << *self << " still suspended after undo " in SuspendSelfForDebugger()
1181 << "(suspend count=" << self->GetSuspendCount() << ", " in SuspendSelfForDebugger()
1182 << "debug suspend count=" << self->GetDebugSuspendCount() << ")"; in SuspendSelfForDebugger()
1185 CHECK_EQ(self->GetSuspendCount(), 0); in SuspendSelfForDebugger()
1188 self->SetReadyForDebugInvoke(false); in SuspendSelfForDebugger()
1189 VLOG(threads) << *self << " self-reviving (debugger)"; in SuspendSelfForDebugger()
1193 Thread* self = Thread::Current(); in ResumeAllForDebugger() local
1196 VLOG(threads) << *self << " ResumeAllForDebugger starting..."; in ResumeAllForDebugger()
1199 Locks::mutator_lock_->AssertNotExclusiveHeld(self); in ResumeAllForDebugger()
1202 MutexLock thread_list_mu(self, *Locks::thread_list_lock_); in ResumeAllForDebugger()
1204 MutexLock suspend_count_mu(self, *Locks::thread_suspend_count_lock_); in ResumeAllForDebugger()
1221 if (thread == self || thread == debug_thread) { in ResumeAllForDebugger()
1229 bool updated = thread->ModifySuspendCount(self, -1, nullptr, true); in ResumeAllForDebugger()
1236 MutexLock mu(self, *Locks::thread_suspend_count_lock_); in ResumeAllForDebugger()
1237 Thread::resume_cond_->Broadcast(self); in ResumeAllForDebugger()
1240 VLOG(threads) << *self << " ResumeAllForDebugger complete"; in ResumeAllForDebugger()
1244 Thread* self = Thread::Current(); in UndoDebuggerSuspensions() local
1246 VLOG(threads) << *self << " UndoDebuggerSuspensions starting"; in UndoDebuggerSuspensions()
1249 MutexLock mu(self, *Locks::thread_list_lock_); in UndoDebuggerSuspensions()
1250 MutexLock mu2(self, *Locks::thread_suspend_count_lock_); in UndoDebuggerSuspensions()
1256 if (thread == self || thread->GetDebugSuspendCount() == 0) { in UndoDebuggerSuspensions()
1259 bool suspended = thread->ModifySuspendCount(self, in UndoDebuggerSuspensions()
1268 MutexLock mu(self, *Locks::thread_suspend_count_lock_); in UndoDebuggerSuspensions()
1269 Thread::resume_cond_->Broadcast(self); in UndoDebuggerSuspensions()
1272 VLOG(threads) << "UndoDebuggerSuspensions(" << *self << ") complete"; in UndoDebuggerSuspensions()
1277 Thread* self = Thread::Current(); in WaitForOtherNonDaemonThreadsToExit() local
1278 Locks::mutator_lock_->AssertNotHeld(self); in WaitForOtherNonDaemonThreadsToExit()
1282 MutexLock mu(self, *Locks::runtime_shutdown_lock_); in WaitForOtherNonDaemonThreadsToExit()
1286 MutexLock mu(self, *Locks::thread_list_lock_); in WaitForOtherNonDaemonThreadsToExit()
1293 if (thread != self && !thread->IsDaemon()) { in WaitForOtherNonDaemonThreadsToExit()
1303 Locks::thread_exit_cond_->Wait(self); in WaitForOtherNonDaemonThreadsToExit()
1309 Thread* self = Thread::Current(); in SuspendAllDaemonThreadsForShutdown() local
1313 MutexLock mu(self, *Locks::thread_list_lock_); in SuspendAllDaemonThreadsForShutdown()
1314 MutexLock mu2(self, *Locks::thread_suspend_count_lock_); in SuspendAllDaemonThreadsForShutdown()
1319 if (thread != self) { in SuspendAllDaemonThreadsForShutdown()
1320 bool updated = thread->ModifySuspendCount(self, +1, nullptr, false); in SuspendAllDaemonThreadsForShutdown()
1344 MutexLock mu(self, *Locks::thread_list_lock_); in SuspendAllDaemonThreadsForShutdown()
1346 if (thread != self && thread->GetState() == kRunnable) { in SuspendAllDaemonThreadsForShutdown()
1363 void ThreadList::Register(Thread* self) { in Register() argument
1364 DCHECK_EQ(self, Thread::Current()); in Register()
1368 self->ShortDump(oss); // We don't hold the mutator_lock_ yet and so cannot call Dump. in Register()
1369 LOG(INFO) << "ThreadList::Register() " << *self << "\n" << oss.str(); in Register()
1374 MutexLock mu(self, *Locks::thread_list_lock_); in Register()
1375 MutexLock mu2(self, *Locks::thread_suspend_count_lock_); in Register()
1380 bool updated = self->ModifySuspendCount(self, +1, nullptr, true); in Register()
1384 bool updated = self->ModifySuspendCount(self, +1, nullptr, false); in Register()
1387 CHECK(!Contains(self)); in Register()
1388 list_.push_back(self); in Register()
1393 self->SetIsGcMarkingAndUpdateEntrypoints(is_gc_marking); in Register()
1396 self->SetWeakRefAccessEnabled(weak_ref_access_enabled); in Register()
1400 void ThreadList::Unregister(Thread* self) { in Unregister() argument
1401 DCHECK_EQ(self, Thread::Current()); in Unregister()
1402 CHECK_NE(self->GetState(), kRunnable); in Unregister()
1403 Locks::mutator_lock_->AssertNotHeld(self); in Unregister()
1405 VLOG(threads) << "ThreadList::Unregister() " << *self; in Unregister()
1408 MutexLock mu(self, *Locks::thread_list_lock_); in Unregister()
1417 self->Destroy(); in Unregister()
1420 Trace::StoreExitingThreadInfo(self); in Unregister()
1422 uint32_t thin_lock_id = self->GetThreadId(); in Unregister()
1427 MutexLock mu(self, *Locks::thread_list_lock_); in Unregister()
1428 if (!Contains(self)) { in Unregister()
1430 self->GetThreadName(thread_name); in Unregister()
1436 MutexLock mu2(self, *Locks::thread_suspend_count_lock_); in Unregister()
1437 if (!self->IsSuspended()) { in Unregister()
1438 list_.remove(self); in Unregister()
1444 delete self; in Unregister()
1472 Thread* const self = Thread::Current(); in VisitRootsForSuspendedThreads() local
1477 MutexLock mu(self, *Locks::thread_list_lock_); in VisitRootsForSuspendedThreads()
1478 MutexLock mu2(self, *Locks::thread_suspend_count_lock_); in VisitRootsForSuspendedThreads()
1480 bool suspended = thread->ModifySuspendCount(self, +1, nullptr, false); in VisitRootsForSuspendedThreads()
1482 if (thread == self || thread->IsSuspended()) { in VisitRootsForSuspendedThreads()
1485 bool resumed = thread->ModifySuspendCount(self, -1, nullptr, false); in VisitRootsForSuspendedThreads()
1499 MutexLock mu2(self, *Locks::thread_suspend_count_lock_); in VisitRootsForSuspendedThreads()
1501 bool updated = thread->ModifySuspendCount(self, -1, nullptr, false); in VisitRootsForSuspendedThreads()
1514 uint32_t ThreadList::AllocThreadId(Thread* self) { in AllocThreadId() argument
1515 MutexLock mu(self, *Locks::allocated_thread_ids_lock_); in AllocThreadId()
1526 void ThreadList::ReleaseThreadId(Thread* self, uint32_t id) { in ReleaseThreadId() argument
1527 MutexLock mu(self, *Locks::allocated_thread_ids_lock_); in ReleaseThreadId()