Lines Matching refs:self

67 static inline void SleepIfRuntimeDeleted(Thread* self) {  in SleepIfRuntimeDeleted()  argument
68 if (self != nullptr) { in SleepIfRuntimeDeleted()
69 JNIEnvExt* const env = self->GetJniEnv(); in SleepIfRuntimeDeleted()
71 DCHECK(self->IsDaemon()); in SleepIfRuntimeDeleted()
111 static inline bool WaitBrieflyFor(AtomicInteger* testLoc, Thread* self, Pred pred) { in WaitBrieflyFor() argument
119 JNIEnvExt* const env = self == nullptr ? nullptr : self->GetJniEnv(); in WaitBrieflyFor()
233 void BaseMutex::CheckSafeToWait(Thread* self) { in CheckSafeToWait() argument
234 if (self == nullptr) { in CheckSafeToWait()
239 CHECK(self->GetHeldMutex(level_) == this || level_ == kMonitorLock) in CheckSafeToWait()
245 BaseMutex* held_mutex = self->GetHeldMutex(static_cast<LockLevel>(i)); in CheckSafeToWait()
257 auto is_suspending_for_user_code = [self]() NO_THREAD_SAFETY_ANALYSIS { in CheckSafeToWait()
258 return self->GetUserCodeSuspendCount() != 0; in CheckSafeToWait()
419 void Mutex::ExclusiveLock(Thread* self) { in ExclusiveLock() argument
420 DCHECK(self == nullptr || self == Thread::Current()); in ExclusiveLock()
422 AssertNotHeld(self); in ExclusiveLock()
424 if (!recursive_ || !IsExclusiveHeld(self)) { in ExclusiveLock()
433 ScopedContentionRecorder scr(this, SafeGetTid(self), GetExclusiveOwnerTid()); in ExclusiveLock()
437 if (!WaitBrieflyFor(&state_and_contenders_, self, in ExclusiveLock()
444 self->CheckEmptyCheckpointFromMutex(); in ExclusiveLock()
457 SleepIfRuntimeDeleted(self); in ExclusiveLock()
471 DCHECK_EQ(GetExclusiveOwnerTid(), 0) << " my tid = " << SafeGetTid(self) in ExclusiveLock()
473 exclusive_owner_.store(SafeGetTid(self), std::memory_order_relaxed); in ExclusiveLock()
474 RegisterAsLocked(self); in ExclusiveLock()
480 AssertHeld(self); in ExclusiveLock()
484 bool Mutex::ExclusiveTryLock(Thread* self) { in ExclusiveTryLock() argument
485 DCHECK(self == nullptr || self == Thread::Current()); in ExclusiveTryLock()
487 AssertNotHeld(self); in ExclusiveTryLock()
489 if (!recursive_ || !IsExclusiveHeld(self)) { in ExclusiveTryLock()
513 exclusive_owner_.store(SafeGetTid(self), std::memory_order_relaxed); in ExclusiveTryLock()
514 RegisterAsLocked(self); in ExclusiveTryLock()
520 AssertHeld(self); in ExclusiveTryLock()
525 bool Mutex::ExclusiveTryLockWithSpinning(Thread* self) { in ExclusiveTryLockWithSpinning() argument
531 if (ExclusiveTryLock(self)) { in ExclusiveTryLockWithSpinning()
535 if (!WaitBrieflyFor(&state_and_contenders_, self, in ExclusiveTryLockWithSpinning()
541 return ExclusiveTryLock(self); in ExclusiveTryLockWithSpinning()
567 void Mutex::ExclusiveUnlock(Thread* self) { in ExclusiveUnlock() argument
568 if (kIsDebugBuild && self != nullptr && self != Thread::Current()) { in ExclusiveUnlock()
571 if (self != nullptr) { in ExclusiveUnlock()
572 self->GetThreadName(name1); in ExclusiveUnlock()
580 AssertHeld(self); in ExclusiveUnlock()
588 RegisterAsUnlocked(self); in ExclusiveUnlock()
684 void ReaderWriterMutex::ExclusiveLock(Thread* self) { in ExclusiveLock() argument
685 DCHECK(self == nullptr || self == Thread::Current()); in ExclusiveLock()
686 AssertNotExclusiveHeld(self); in ExclusiveLock()
696 ScopedContentionRecorder scr(this, SafeGetTid(self), GetExclusiveOwnerTid()); in ExclusiveLock()
697 if (!WaitBrieflyFor(&state_, self, [](int32_t v) { return v == 0; })) { in ExclusiveLock()
700 self->CheckEmptyCheckpointFromMutex(); in ExclusiveLock()
709 SleepIfRuntimeDeleted(self); in ExclusiveLock()
719 exclusive_owner_.store(SafeGetTid(self), std::memory_order_relaxed); in ExclusiveLock()
720 RegisterAsLocked(self); in ExclusiveLock()
721 AssertExclusiveHeld(self); in ExclusiveLock()
724 void ReaderWriterMutex::ExclusiveUnlock(Thread* self) { in ExclusiveUnlock() argument
725 DCHECK(self == nullptr || self == Thread::Current()); in ExclusiveUnlock()
726 AssertExclusiveHeld(self); in ExclusiveUnlock()
727 RegisterAsUnlocked(self); in ExclusiveUnlock()
756 bool ReaderWriterMutex::ExclusiveLockWithTimeout(Thread* self, int64_t ms, int32_t ns) { in ExclusiveLockWithTimeout() argument
757 DCHECK(self == nullptr || self == Thread::Current()); in ExclusiveLockWithTimeout()
775 ScopedContentionRecorder scr(this, SafeGetTid(self), GetExclusiveOwnerTid()); in ExclusiveLockWithTimeout()
776 if (!WaitBrieflyFor(&state_, self, [](int32_t v) { return v == 0; })) { in ExclusiveLockWithTimeout()
779 self->CheckEmptyCheckpointFromMutex(); in ExclusiveLockWithTimeout()
792 SleepIfRuntimeDeleted(self); in ExclusiveLockWithTimeout()
809 exclusive_owner_.store(SafeGetTid(self), std::memory_order_relaxed); in ExclusiveLockWithTimeout()
810 RegisterAsLocked(self); in ExclusiveLockWithTimeout()
811 AssertSharedHeld(self); in ExclusiveLockWithTimeout()
817 void ReaderWriterMutex::HandleSharedLockContention(Thread* self, int32_t cur_state) { in HandleSharedLockContention() argument
819 ScopedContentionRecorder scr(this, SafeGetTid(self), GetExclusiveOwnerTid()); in HandleSharedLockContention()
820 if (!WaitBrieflyFor(&state_, self, [](int32_t v) { return v >= 0; })) { in HandleSharedLockContention()
823 self->CheckEmptyCheckpointFromMutex(); in HandleSharedLockContention()
830 SleepIfRuntimeDeleted(self); in HandleSharedLockContention()
836 bool ReaderWriterMutex::SharedTryLock(Thread* self) { in SharedTryLock() argument
837 DCHECK(self == nullptr || self == Thread::Current()); in SharedTryLock()
860 RegisterAsLocked(self); in SharedTryLock()
861 AssertSharedHeld(self); in SharedTryLock()
865 bool ReaderWriterMutex::IsSharedHeld(const Thread* self) const { in IsSharedHeld()
866 DCHECK(self == nullptr || self == Thread::Current()); in IsSharedHeld()
868 if (UNLIKELY(self == nullptr)) { // Handle unattached threads. in IsSharedHeld()
869 result = IsExclusiveHeld(self); // TODO: a better best effort here. in IsSharedHeld()
871 result = (self->GetHeldMutex(level_) == this); in IsSharedHeld()
946 void ConditionVariable::Broadcast(Thread* self) { in Broadcast() argument
947 DCHECK(self == nullptr || self == Thread::Current()); in Broadcast()
950 DCHECK_EQ(guard_.GetExclusiveOwnerTid(), SafeGetTid(self)); in Broadcast()
978 void ConditionVariable::Signal(Thread* self) { in Signal() argument
979 DCHECK(self == nullptr || self == Thread::Current()); in Signal()
980 guard_.AssertExclusiveHeld(self); in Signal()
988 void ConditionVariable::Wait(Thread* self) { in Wait() argument
989 guard_.CheckSafeToWait(self); in Wait()
990 WaitHoldingLocks(self); in Wait()
993 void ConditionVariable::WaitHoldingLocks(Thread* self) { in WaitHoldingLocks() argument
994 DCHECK(self == nullptr || self == Thread::Current()); in WaitHoldingLocks()
995 guard_.AssertExclusiveHeld(self); in WaitHoldingLocks()
1003 guard_.ExclusiveUnlock(self); in WaitHoldingLocks()
1012 SleepIfRuntimeDeleted(self); in WaitHoldingLocks()
1013 guard_.ExclusiveLock(self); in WaitHoldingLocks()
1029 bool ConditionVariable::TimedWait(Thread* self, int64_t ms, int32_t ns) { in TimedWait() argument
1030 DCHECK(self == nullptr || self == Thread::Current()); in TimedWait()
1032 guard_.AssertExclusiveHeld(self); in TimedWait()
1033 guard_.CheckSafeToWait(self); in TimedWait()
1043 guard_.ExclusiveUnlock(self); in TimedWait()
1054 SleepIfRuntimeDeleted(self); in TimedWait()
1055 guard_.ExclusiveLock(self); in TimedWait()