Lines Matching refs:art
67 art::ArtField* ThreadUtil::context_class_loader_ = nullptr;
69 ScopedNoUserCodeSuspension::ScopedNoUserCodeSuspension(art::Thread* self) : self_(self) { in ScopedNoUserCodeSuspension()
70 DCHECK_EQ(self, art::Thread::Current()); in ScopedNoUserCodeSuspension()
74 art::Locks::user_code_suspension_lock_->AssertNotHeld(self_); in ScopedNoUserCodeSuspension()
77 art::Locks::user_code_suspension_lock_->ExclusiveLock(self_); in ScopedNoUserCodeSuspension()
79 art::Locks::user_code_suspension_lock_->ExclusiveUnlock(self_); in ScopedNoUserCodeSuspension()
83 art::Locks::user_code_suspension_lock_->AssertHeld(self_); in ScopedNoUserCodeSuspension()
90 art::Locks::user_code_suspension_lock_->ExclusiveUnlock(self_); in ~ScopedNoUserCodeSuspension()
93 struct ThreadCallback : public art::ThreadLifecycleCallback {
94 jthread GetThreadObject(art::Thread* self) REQUIRES_SHARED(art::Locks::mutator_lock_) { in GetThreadObject()
102 void Post(art::Thread* self) REQUIRES_SHARED(art::Locks::mutator_lock_) { in Post()
103 DCHECK_EQ(self, art::Thread::Current()); in Post()
105 art::ScopedThreadSuspension sts(self, art::ThreadState::kNative); in Post()
111 void ThreadStart(art::Thread* self) override REQUIRES_SHARED(art::Locks::mutator_lock_) { in ThreadStart()
126 if (art::kIsDebugBuild) { in ThreadStart()
142 void ThreadDeath(art::Thread* self) override REQUIRES_SHARED(art::Locks::mutator_lock_) { in ThreadDeath()
153 art::Runtime* runtime = art::Runtime::Current(); in Register()
158 art::ScopedThreadStateChange stsc(art::Thread::Current(), in Register()
159 art::ThreadState::kWaitingForDebuggerToAttach); in Register()
160 art::ScopedSuspendAll ssa("Add thread callback"); in Register()
169 gThreadCallback.Post<ArtJvmtiEvent::kThreadStart>(art::Thread::Current()); in VMInitEventSent()
173 static void WaitForSystemDaemonStart(art::Thread* self) REQUIRES_SHARED(art::Locks::mutator_lock_) { in WaitForSystemDaemonStart()
175 art::ScopedThreadStateChange strc(self, art::kNative); in WaitForSystemDaemonStart()
177 jni->CallStaticVoidMethod(art::WellKnownClasses::java_lang_Daemons, in WaitForSystemDaemonStart()
178 art::WellKnownClasses::java_lang_Daemons_waitForDaemonStart); in WaitForSystemDaemonStart()
190 art::Thread* self = art::Thread::Current(); in CacheData()
191 art::ScopedObjectAccess soa(self); in CacheData()
192 art::ObjPtr<art::mirror::Class> thread_class = in CacheData()
193 soa.Decode<art::mirror::Class>(art::WellKnownClasses::java_lang_Thread); in CacheData()
204 art::ScopedThreadStateChange stsc(art::Thread::Current(), in Unregister()
205 art::ThreadState::kWaitingForDebuggerToAttach); in Unregister()
206 art::ScopedSuspendAll ssa("Remove thread callback"); in Unregister()
207 art::Runtime* runtime = art::Runtime::Current(); in Unregister()
212 art::Thread* self = art::Thread::Current(); in GetCurrentThread()
214 art::ScopedObjectAccess soa(self); in GetCurrentThread()
229 const art::ScopedObjectAccessAlreadyRunnable& soa, in GetNativeThread()
230 /*out*/ art::Thread** thr, in GetNativeThread()
233 *thr = art::Thread::Current(); in GetNativeThread()
235 } else if (!soa.Env()->IsInstanceOf(thread, art::WellKnownClasses::java_lang_Thread)) { in GetNativeThread()
239 *thr = art::Thread::FromManagedThread(soa, thread); in GetNativeThread()
245 const art::ScopedObjectAccessAlreadyRunnable& soa, in GetAliveNativeThread()
246 /*out*/ art::Thread** thr, in GetAliveNativeThread()
250 } else if (*thr == nullptr || (*thr)->GetState() == art::ThreadState::kTerminated) { in GetAliveNativeThread()
266 art::Thread* self = art::Thread::Current(); in GetThreadInfo()
267 art::ScopedObjectAccess soa(self); in GetThreadInfo()
268 art::MutexLock mu(self, *art::Locks::thread_list_lock_); in GetThreadInfo()
270 art::Thread* target; in GetThreadInfo()
292 art::ObjPtr<art::mirror::Object> peer = target->GetPeerFromOtherThread(); in GetThreadInfo()
296 art::ArtField* f = art::jni::DecodeArtField(art::WellKnownClasses::java_lang_Thread_group); in GetThreadInfo()
298 art::ObjPtr<art::mirror::Object> group = f->GetObject(peer); in GetThreadInfo()
308 art::ObjPtr<art::mirror::Object> ccl = peer != nullptr in GetThreadInfo()
317 art::ObjPtr<art::mirror::Object> peer = soa.Decode<art::mirror::Object>(thread); in GetThreadInfo()
321 art::ArtField* f = art::jni::DecodeArtField(art::WellKnownClasses::java_lang_Thread_name); in GetThreadInfo()
323 art::ObjPtr<art::mirror::Object> name = f->GetObject(peer); in GetThreadInfo()
342 art::ArtField* f = art::jni::DecodeArtField(art::WellKnownClasses::java_lang_Thread_priority); in GetThreadInfo()
349 art::ArtField* f = art::jni::DecodeArtField(art::WellKnownClasses::java_lang_Thread_daemon); in GetThreadInfo()
356 art::ArtField* f = art::jni::DecodeArtField(art::WellKnownClasses::java_lang_Thread_group); in GetThreadInfo()
358 art::ObjPtr<art::mirror::Object> group = f->GetObject(peer); in GetThreadInfo()
366 art::ObjPtr<art::mirror::Object> ccl = peer != nullptr in GetThreadInfo()
380 art::Thread* native_thread;
381 art::ThreadState art_state;
386 static InternalThreadState GetNativeThreadState(art::Thread* target) in GetNativeThreadState()
387 REQUIRES_SHARED(art::Locks::mutator_lock_) in GetNativeThreadState()
388 REQUIRES(art::Locks::thread_list_lock_, art::Locks::user_code_suspension_lock_) { in GetNativeThreadState()
390 art::MutexLock tscl_mu(art::Thread::Current(), *art::Locks::thread_suspend_count_lock_); in GetNativeThreadState()
393 thread_state.art_state = art::ThreadState::kStarting; in GetNativeThreadState()
403 art::ThreadState internal_thread_state = state.art_state; in GetJvmtiThreadStateFromInternal()
422 case art::ThreadState::kRunnable: in GetJvmtiThreadStateFromInternal()
423 case art::ThreadState::kWaitingWeakGcRootRead: in GetJvmtiThreadStateFromInternal()
424 case art::ThreadState::kSuspended: in GetJvmtiThreadStateFromInternal()
433 case art::ThreadState::kNative: in GetJvmtiThreadStateFromInternal()
440 case art::ThreadState::kBlocked: in GetJvmtiThreadStateFromInternal()
444 case art::ThreadState::kWaiting: in GetJvmtiThreadStateFromInternal()
450 case art::ThreadState::kTimedWaiting: in GetJvmtiThreadStateFromInternal()
456 case art::ThreadState::kSleeping: in GetJvmtiThreadStateFromInternal()
464 case art::ThreadState::kWaitingForDebuggerSend: in GetJvmtiThreadStateFromInternal()
465 case art::ThreadState::kWaitingForDebuggerToAttach: in GetJvmtiThreadStateFromInternal()
466 case art::ThreadState::kWaitingInMainDebuggerLoop: in GetJvmtiThreadStateFromInternal()
467 case art::ThreadState::kWaitingForDebuggerSuspension: in GetJvmtiThreadStateFromInternal()
468 case art::ThreadState::kWaitingForLockInflation: in GetJvmtiThreadStateFromInternal()
469 case art::ThreadState::kWaitingForTaskProcessor: in GetJvmtiThreadStateFromInternal()
470 case art::ThreadState::kWaitingForGcToComplete: in GetJvmtiThreadStateFromInternal()
471 case art::ThreadState::kWaitingForCheckPointsToRun: in GetJvmtiThreadStateFromInternal()
472 case art::ThreadState::kWaitingPerformingGc: in GetJvmtiThreadStateFromInternal()
473 case art::ThreadState::kWaitingForJniOnLoad: in GetJvmtiThreadStateFromInternal()
474 case art::ThreadState::kWaitingInMainSignalCatcherLoop: in GetJvmtiThreadStateFromInternal()
475 case art::ThreadState::kWaitingForSignalCatcherOutput: in GetJvmtiThreadStateFromInternal()
476 case art::ThreadState::kWaitingForDeoptimization: in GetJvmtiThreadStateFromInternal()
477 case art::ThreadState::kWaitingForMethodTracingStart: in GetJvmtiThreadStateFromInternal()
478 case art::ThreadState::kWaitingForVisitObjects: in GetJvmtiThreadStateFromInternal()
479 case art::ThreadState::kWaitingForGetObjectsAllocated: in GetJvmtiThreadStateFromInternal()
480 case art::ThreadState::kWaitingForGcThreadFlip: in GetJvmtiThreadStateFromInternal()
481 case art::ThreadState::kNativeForAbort: in GetJvmtiThreadStateFromInternal()
487 case art::ThreadState::kStarting: in GetJvmtiThreadStateFromInternal()
488 case art::ThreadState::kTerminated: in GetJvmtiThreadStateFromInternal()
500 case art::ThreadState::kTerminated: in GetJavaStateFromInternal()
503 case art::ThreadState::kRunnable: in GetJavaStateFromInternal()
504 case art::ThreadState::kNative: in GetJavaStateFromInternal()
505 case art::ThreadState::kWaitingWeakGcRootRead: in GetJavaStateFromInternal()
506 case art::ThreadState::kSuspended: in GetJavaStateFromInternal()
509 case art::ThreadState::kTimedWaiting: in GetJavaStateFromInternal()
510 case art::ThreadState::kSleeping: in GetJavaStateFromInternal()
513 case art::ThreadState::kBlocked: in GetJavaStateFromInternal()
516 case art::ThreadState::kStarting: in GetJavaStateFromInternal()
519 case art::ThreadState::kWaiting: in GetJavaStateFromInternal()
520 case art::ThreadState::kWaitingForTaskProcessor: in GetJavaStateFromInternal()
521 case art::ThreadState::kWaitingForLockInflation: in GetJavaStateFromInternal()
522 case art::ThreadState::kWaitingForGcToComplete: in GetJavaStateFromInternal()
523 case art::ThreadState::kWaitingPerformingGc: in GetJavaStateFromInternal()
524 case art::ThreadState::kWaitingForCheckPointsToRun: in GetJavaStateFromInternal()
525 case art::ThreadState::kWaitingForDebuggerSend: in GetJavaStateFromInternal()
526 case art::ThreadState::kWaitingForDebuggerToAttach: in GetJavaStateFromInternal()
527 case art::ThreadState::kWaitingInMainDebuggerLoop: in GetJavaStateFromInternal()
528 case art::ThreadState::kWaitingForDebuggerSuspension: in GetJavaStateFromInternal()
529 case art::ThreadState::kWaitingForDeoptimization: in GetJavaStateFromInternal()
530 case art::ThreadState::kWaitingForGetObjectsAllocated: in GetJavaStateFromInternal()
531 case art::ThreadState::kWaitingForJniOnLoad: in GetJavaStateFromInternal()
532 case art::ThreadState::kWaitingForSignalCatcherOutput: in GetJavaStateFromInternal()
533 case art::ThreadState::kWaitingInMainSignalCatcherLoop: in GetJavaStateFromInternal()
534 case art::ThreadState::kWaitingForMethodTracingStart: in GetJavaStateFromInternal()
535 case art::ThreadState::kWaitingForVisitObjects: in GetJavaStateFromInternal()
536 case art::ThreadState::kWaitingForGcThreadFlip: in GetJavaStateFromInternal()
537 case art::ThreadState::kNativeForAbort: in GetJavaStateFromInternal()
545 void ThreadUtil::SuspendCheck(art::Thread* self) { in SuspendCheck()
546 art::ScopedObjectAccess soa(self); in SuspendCheck()
551 bool ThreadUtil::WouldSuspendForUserCodeLocked(art::Thread* self) { in WouldSuspendForUserCodeLocked()
552 DCHECK(self == art::Thread::Current()); in WouldSuspendForUserCodeLocked()
553 art::MutexLock tscl_mu(self, *art::Locks::thread_suspend_count_lock_); in WouldSuspendForUserCodeLocked()
557 bool ThreadUtil::WouldSuspendForUserCode(art::Thread* self) { in WouldSuspendForUserCode()
558 DCHECK(self == art::Thread::Current()); in WouldSuspendForUserCode()
559 art::MutexLock ucsl_mu(self, *art::Locks::user_code_suspension_lock_); in WouldSuspendForUserCode()
570 art::Thread* self = art::Thread::Current(); in GetThreadState()
574 art::ScopedObjectAccess soa(self); in GetThreadState()
575 art::MutexLock tll_mu(self, *art::Locks::thread_list_lock_); in GetThreadState()
577 art::Thread* target = nullptr; in GetThreadState()
582 if (state.art_state != art::ThreadState::kStarting) { in GetThreadState()
600 DCHECK_EQ(state.art_state, art::ThreadState::kStarting); in GetThreadState()
607 art::ScopedObjectAccess soa(self); in GetThreadState()
608 art::StackHandleScope<1> hs(self); in GetThreadState()
611 art::Handle<art::mirror::Object> peer(hs.NewHandle(soa.Decode<art::mirror::Object>(thread))); in GetThreadState()
612 art::ObjPtr<art::mirror::Class> thread_klass = in GetThreadState()
613 soa.Decode<art::mirror::Class>(art::WellKnownClasses::java_lang_Thread); in GetThreadState()
617 art::ArtField* started_field = thread_klass->FindDeclaredInstanceField("started", "Z"); in GetThreadState()
634 art::Thread* current = art::Thread::Current(); in GetAllThreads()
636 art::ScopedObjectAccess soa(current); in GetAllThreads()
638 art::MutexLock mu(current, *art::Locks::thread_list_lock_); in GetAllThreads()
639 std::list<art::Thread*> thread_list = art::Runtime::Current()->GetThreadList()->GetList(); in GetAllThreads()
641 std::vector<art::ObjPtr<art::mirror::Object>> peers; in GetAllThreads()
643 for (art::Thread* thread : thread_list) { in GetAllThreads()
649 art::ObjPtr<art::mirror::Object> peer = thread->GetPeerFromOtherThread(); in GetAllThreads()
675 static void RemoveTLSData(art::Thread* target, void* ctx) REQUIRES(art::Locks::thread_list_lock_) { in RemoveTLSData()
677 art::Locks::thread_list_lock_->AssertHeld(art::Thread::Current()); in RemoveTLSData()
685 art::Thread* self = art::Thread::Current(); in RemoveEnvironment()
686 art::MutexLock mu(self, *art::Locks::thread_list_lock_); in RemoveEnvironment()
687 art::ThreadList* list = art::Runtime::Current()->GetThreadList(); in RemoveEnvironment()
692 art::Thread* self = art::Thread::Current(); in SetThreadLocalStorage()
693 art::ScopedObjectAccess soa(self); in SetThreadLocalStorage()
694 art::MutexLock mu(self, *art::Locks::thread_list_lock_); in SetThreadLocalStorage()
695 art::Thread* target = nullptr; in SetThreadLocalStorage()
708 JvmtiGlobalTLSData* ThreadUtil::GetOrCreateGlobalTLSData(art::Thread* thread) { in GetOrCreateGlobalTLSData()
718 JvmtiGlobalTLSData* ThreadUtil::GetGlobalTLSData(art::Thread* thread) { in GetGlobalTLSData()
729 art::Thread* self = art::Thread::Current(); in GetThreadLocalStorage()
730 art::ScopedObjectAccess soa(self); in GetThreadLocalStorage()
731 art::MutexLock mu(self, *art::Locks::thread_list_lock_); in GetThreadLocalStorage()
732 art::Thread* target = nullptr; in GetThreadLocalStorage()
768 art::Thread* self = art::Thread::Attach(data->name.c_str(), true, data->thread); in AgentCallback()
773 art::ScopedObjectAccess soa(self); in AgentCallback()
785 art::MutexLock mu(art::Thread::Current(), *art::Locks::runtime_shutdown_lock_); in AgentCallback()
786 art::Runtime::Current()->EndThreadBirth(); in AgentCallback()
810 JNIEnv* env = art::Thread::Current()->GetJniEnv(); in RunAgentThread()
811 if (thread == nullptr || !env->IsInstanceOf(thread, art::WellKnownClasses::java_lang_Thread)) { in RunAgentThread()
819 art::Runtime* runtime = art::Runtime::Current(); in RunAgentThread()
820 art::MutexLock mu(art::Thread::Current(), *art::Locks::runtime_shutdown_lock_); in RunAgentThread()
838 data->java_vm = art::Runtime::Current()->GetJavaVM(); in RunAgentThread()
844 env->GetObjectField(thread, art::WellKnownClasses::java_lang_Thread_name))); in RunAgentThread()
859 art::Runtime* runtime = art::Runtime::Current(); in RunAgentThread()
860 art::MutexLock mu(art::Thread::Current(), *art::Locks::runtime_shutdown_lock_); in RunAgentThread()
869 jvmtiError ThreadUtil::SuspendOther(art::Thread* self, in SuspendOther()
878 art::ScopedObjectAccess soa(self); in SuspendOther()
879 art::MutexLock thread_list_mu(self, *art::Locks::thread_list_lock_); in SuspendOther()
880 art::Thread* target = nullptr; in SuspendOther()
885 art::ThreadState state = target->GetState(); in SuspendOther()
886 if (state == art::ThreadState::kStarting || target->IsStillStarting()) { in SuspendOther()
889 art::MutexLock thread_suspend_count_mu(self, *art::Locks::thread_suspend_count_lock_); in SuspendOther()
896 art::Thread* ret_target = art::Runtime::Current()->GetThreadList()->SuspendThreadByPeer( in SuspendOther()
899 art::SuspendReason::kForUserCode, in SuspendOther()
914 jvmtiError ThreadUtil::SuspendSelf(art::Thread* self) { in SuspendSelf()
915 CHECK(self == art::Thread::Current()); in SuspendSelf()
917 art::MutexLock mu(self, *art::Locks::user_code_suspension_lock_); in SuspendSelf()
918 art::MutexLock thread_list_mu(self, *art::Locks::thread_suspend_count_lock_); in SuspendSelf()
924 if (!self->ModifySuspendCount(self, +1, nullptr, art::SuspendReason::kForUserCode)) { in SuspendSelf()
937 art::Thread* self = art::Thread::Current(); in SuspendThread()
940 art::ScopedObjectAccess soa(self); in SuspendThread()
941 art::MutexLock mu(self, *art::Locks::thread_list_lock_); in SuspendThread()
942 art::Thread* target = nullptr; in SuspendThread()
962 art::Thread* self = art::Thread::Current(); in ResumeThread()
963 art::Thread* target; in ResumeThread()
971 art::ScopedObjectAccess soa(self); in ResumeThread()
972 art::MutexLock tll_mu(self, *art::Locks::thread_list_lock_); in ResumeThread()
985 art::MutexLock thread_suspend_count_mu(self, *art::Locks::thread_suspend_count_lock_); in ResumeThread()
994 if (!art::Runtime::Current()->GetThreadList()->Resume(target, in ResumeThread()
995 art::SuspendReason::kForUserCode)) { in ResumeThread()
1008 art::Thread* self = art::Thread::Current(); in IsCurrentThread()
1009 art::ScopedObjectAccess soa(self); in IsCurrentThread()
1010 art::MutexLock mu(self, *art::Locks::thread_list_lock_); in IsCurrentThread()
1011 art::Thread* target = nullptr; in IsCurrentThread()
1078 art::Thread* self = art::Thread::Current(); in StopThread()
1079 art::ScopedObjectAccess soa(self); in StopThread()
1080 art::StackHandleScope<1> hs(self); in StopThread()
1084 art::ObjPtr<art::mirror::Object> obj(soa.Decode<art::mirror::Object>(exception)); in StopThread()
1088 art::Handle<art::mirror::Throwable> exc(hs.NewHandle(obj->AsThrowable())); in StopThread()
1089 art::Locks::thread_list_lock_->ExclusiveLock(self); in StopThread()
1090 art::Thread* target = nullptr; in StopThread()
1093 art::Locks::thread_list_lock_->ExclusiveUnlock(self); in StopThread()
1095 } else if (target->GetState() == art::ThreadState::kStarting || target->IsStillStarting()) { in StopThread()
1096 art::Locks::thread_list_lock_->ExclusiveUnlock(self); in StopThread()
1099 struct StopThreadClosure : public art::Closure { in StopThread()
1101 explicit StopThreadClosure(art::Handle<art::mirror::Throwable> except) : exception_(except) { } in StopThread()
1103 void Run(art::Thread* me) override REQUIRES_SHARED(art::Locks::mutator_lock_) { in StopThread()
1112 art::Handle<art::mirror::Throwable> exception_; in StopThread()
1125 art::Thread* self = art::Thread::Current(); in InterruptThread()
1126 art::ScopedObjectAccess soa(self); in InterruptThread()
1127 art::MutexLock tll_mu(self, *art::Locks::thread_list_lock_); in InterruptThread()
1128 art::Thread* target = nullptr; in InterruptThread()
1132 } else if (target->GetState() == art::ThreadState::kStarting || target->IsStillStarting()) { in InterruptThread()