Lines Matching defs:self
76 Monitor::Monitor(Thread* self, Thread* owner, mirror::Object* obj, int32_t hash_code)
87 monitor_id_(MonitorPool::ComputeMonitorId(this, self)) {
94 CHECK(owner == nullptr || owner == self || owner->IsSuspended());
98 Monitor::Monitor(Thread* self, Thread* owner, mirror::Object* obj, int32_t hash_code,
116 CHECK(owner == nullptr || owner == self || owner->IsSuspended());
130 bool Monitor::Install(Thread* self) {
131 MutexLock mu(self, monitor_lock_); // Uncontended mutex acquisition as monitor isn't yet public.
132 CHECK(owner_ == nullptr || owner_ == self || owner_->IsSuspended());
257 void Monitor::AtraceMonitorLock(Thread* self, mirror::Object* obj, bool is_wait) {
259 AtraceMonitorLockImpl(self, obj, is_wait);
263 void Monitor::AtraceMonitorLockImpl(Thread* self, mirror::Object* obj, bool is_wait) {
267 NthCallerWithDexPcVisitor visitor(self, is_wait ? 1U : 0U);
317 void Monitor::Lock(Thread* self) {
318 MutexLock mu(self, monitor_lock_);
321 owner_ = self;
326 locking_method_ = self->GetCurrentMethod(&locking_dex_pc_);
329 } else if (owner_ == self) { // Recursive.
341 monitor_lock_.Unlock(self); // Let go of locks in order.
342 self->SetMonitorEnterObject(GetObject());
345 ScopedThreadStateChange tsc(self, kBlocked); // Change to blocked and give up mutator_lock_.
348 MutexLock mu2(self, monitor_lock_);
362 ArtMethod* m = self->GetCurrentMethod(&pc);
371 monitor_contenders_.Wait(self); // Still contended so wait.
402 ArtMethod* m = self->GetCurrentMethod(&pc);
418 LogContentionEvent(self,
429 self->SetMonitorEnterObject(nullptr);
430 monitor_lock_.Lock(self); // Reacquire locks in order.
434 AtraceMonitorLock(self, GetObject(), false /* is_wait */);
444 Thread* self = Thread::Current();
445 self->ThrowNewExceptionV("Ljava/lang/IllegalMonitorStateException;", fmt, args);
448 self->Dump(ss);
450 << self->GetException()->Dump() << "\n" << ss.str();
533 bool Monitor::Unlock(Thread* self) {
534 DCHECK(self != nullptr);
537 MutexLock mu(self, monitor_lock_);
542 if (owner == self) {
550 monitor_contenders_.Signal(self);
559 FailedUnlock(GetObject(), self->GetThreadId(), owner_thread_id, this);
563 void Monitor::Wait(Thread* self, int64_t ms, int32_t ns,
565 DCHECK(self != nullptr);
568 monitor_lock_.Lock(self);
571 if (owner_ != self) {
572 monitor_lock_.Unlock(self);
585 monitor_lock_.Unlock(self);
586 self->ThrowNewExceptionF("Ljava/lang/IllegalArgumentException;",
601 AppendToWaitSet(self);
614 AtraceMonitorLock(self, GetObject(), true /* is_wait */);
621 ScopedThreadSuspension sts(self, why);
623 // Pseudo-atomically wait on self's wait_cond_ and release the monitor lock.
624 MutexLock mu(self, *self->GetWaitMutex());
629 DCHECK(self->GetWaitMonitor() == nullptr);
630 self->SetWaitMonitor(this);
633 monitor_contenders_.Signal(self);
634 monitor_lock_.Unlock(self);
637 if (self->IsInterruptedLocked()) {
642 self->GetWaitConditionVariable()->Wait(self);
645 self->GetWaitConditionVariable()->TimedWait(self, ms, ns);
647 was_interrupted = self->IsInterruptedLocked();
656 MutexLock mu(self, *self->GetWaitMutex());
657 DCHECK(self->GetWaitMonitor() != nullptr);
658 self->SetWaitMonitor(nullptr);
673 MutexLock mu(self, *self->GetWaitMutex());
674 self->SetInterruptedLocked(false);
676 self->ThrowNewException("Ljava/lang/InterruptedException;", nullptr);
682 Lock(self);
683 monitor_lock_.Lock(self);
684 self->GetWaitMutex()->AssertNotHeld(self);
692 owner_ = self;
697 RemoveFromWaitSet(self);
699 monitor_lock_.Unlock(self);
702 void Monitor::Notify(Thread* self) {
703 DCHECK(self != nullptr);
704 MutexLock mu(self, monitor_lock_);
706 if (owner_ != self) {
717 MutexLock wait_mu(self, *thread->GetWaitMutex());
719 thread->GetWaitConditionVariable()->Signal(self);
725 void Monitor::NotifyAll(Thread* self) {
726 DCHECK(self != nullptr);
727 MutexLock mu(self, monitor_lock_);
729 if (owner_ != self) {
742 bool Monitor::Deflate(Thread* self, mirror::Object* obj) {
750 MutexLock mu(self, monitor->monitor_lock_);
791 void Monitor::Inflate(Thread* self, Thread* owner, mirror::Object* obj, int32_t hash_code) {
792 DCHECK(self != nullptr);
795 Monitor* m = MonitorPool::CreateMonitor(self, owner, obj, hash_code);
797 if (m->Install(self)) {
808 MonitorPool::ReleaseMonitor(self, m);
812 void Monitor::InflateThinLocked(Thread* self, Handle<mirror::Object> obj, LockWord lock_word,
816 if (owner_thread_id == self->GetThreadId()) {
818 Inflate(self, self, obj.Get(), hash_code);
822 self->SetMonitorEnterObject(obj.Get());
826 ScopedThreadSuspension sts(self, kBlocked);
835 Inflate(self, owner, obj.Get(), hash_code);
839 self->SetMonitorEnterObject(nullptr);
855 mirror::Object* Monitor::MonitorEnter(Thread* self, mirror::Object* obj) {
856 DCHECK(self != nullptr);
858 self->AssertThreadSuspensionIsAllowable();
860 uint32_t thread_id = self->GetThreadId();
862 StackHandleScope<1> hs(self);
870 AtraceMonitorLock(self, h_obj.Get(), false /* is_wait */);
886 AtraceMonitorLock(self, h_obj.Get(), false /* is_wait */);
891 AtraceMonitorLock(self, h_obj.Get(), false /* is_wait */);
898 InflateThinLocked(self, h_obj, lock_word, 0);
912 InflateThinLocked(self, h_obj, lock_word, 0);
919 mon->Lock(self);
924 Inflate(self, nullptr, h_obj.Get(), lock_word.GetHashCode());
934 bool Monitor::MonitorExit(Thread* self, mirror::Object* obj) {
935 DCHECK(self != nullptr);
937 self->AssertThreadSuspensionIsAllowable();
939 StackHandleScope<1> hs(self);
947 FailedUnlock(h_obj.Get(), self->GetThreadId(), 0u, nullptr);
950 uint32_t thread_id = self->GetThreadId();
983 return mon->Unlock(self);
993 void Monitor::Wait(Thread* self, mirror::Object *obj, int64_t ms, int32_t ns,
995 DCHECK(self != nullptr);
1006 uint32_t thread_id = self->GetThreadId();
1014 Inflate(self, self, obj, 0);
1027 mon->Wait(self, ms, ns, interruptShouldThrow, why);
1030 void Monitor::DoNotify(Thread* self, mirror::Object* obj, bool notify_all) {
1031 DCHECK(self != nullptr);
1041 uint32_t thread_id = self->GetThreadId();
1054 mon->NotifyAll(self);
1056 mon->Notify(self);
1096 Thread* self = Thread::Current();
1097 MutexLock mu(self, *thread->GetWaitMutex());
1282 Thread* self = Thread::Current();
1283 self, monitor_list_lock_);
1287 MonitorPool::ReleaseMonitors(self, &list_);
1298 Thread* self = Thread::Current();
1299 MutexLock mu(self, monitor_list_lock_);
1301 monitor_add_condition_.Broadcast(self);
1306 Thread* self = Thread::Current();
1307 MutexLock mu(self, monitor_list_lock_);
1308 monitor_add_condition_.Broadcast(self);
1312 Thread* self = Thread::Current();
1313 MutexLock mu(self, monitor_list_lock_);
1315 (kUseReadBarrier && !self->GetWeakRefAccessEnabled()))) {
1316 monitor_add_condition_.WaitHoldingLocks(self);
1322 Thread* self = Thread::Current();
1323 MutexLock mu(self, monitor_list_lock_);
1333 MonitorPool::ReleaseMonitor(self, m);