Home | History | Annotate | Download | only in openjdkjvmti

Lines Matching defs:thread

58 #include "thread-current-inl.h"
69 ScopedNoUserCodeSuspension::ScopedNoUserCodeSuspension(art::Thread* self) : self_(self) {
70 DCHECK_EQ(self, art::Thread::Current());
94 jthread GetThreadObject(art::Thread* self) REQUIRES_SHARED(art::Locks::mutator_lock_) {
102 void Post(art::Thread* self) REQUIRES_SHARED(art::Locks::mutator_lock_) {
103 DCHECK_EQ(self, art::Thread::Current());
104 ScopedLocalRef<jthread> thread(self->GetJniEnv(), GetThreadObject(self));
108 thread.get());
111 void ThreadStart(art::Thread* self) override REQUIRES_SHARED(art::Locks::mutator_lock_) {
115 // System daemon threads are things like the finalizer or gc thread. It would be dangerous to
131 !android::base::StartsWith(name, "Jit thread pool") &&
132 !android::base::StartsWith(name, "Runtime worker thread")) {
133 LOG(FATAL) << "Unexpected thread before start: " << name << " id: "
142 void ThreadDeath(art::Thread* self) override REQUIRES_SHARED(art::Locks::mutator_lock_) {
158 art::ScopedThreadStateChange stsc(art::Thread::Current(),
160 art::ScopedSuspendAll ssa("Add thread callback");
167 // We moved to VMInit. Report the main thread as started (it was attached early, and must not be
169 gThreadCallback.Post<ArtJvmtiEvent::kThreadStart>(art::Thread::Current());
173 static void WaitForSystemDaemonStart(art::Thread* self) REQUIRES_SHARED(art::Locks::mutator_lock_) {
190 art::Thread* self = art::Thread::Current();
204 art::ScopedThreadStateChange stsc(art::Thread::Current(),
206 art::ScopedSuspendAll ssa("Remove thread callback");
212 art::Thread* self = art::Thread::Current();
227 // Get the native thread. The spec says a null object denotes the current thread.
228 bool ThreadUtil::GetNativeThread(jthread thread,
230 /*out*/ art::Thread** thr,
232 if (thread == nullptr) {
233 *thr = art::Thread::Current();
235 } else if (!soa.Env()->IsInstanceOf(thread, art::WellKnownClasses::java_lang_Thread)) {
239 *thr = art::Thread::FromManagedThread(soa, thread);
244 bool ThreadUtil::GetAliveNativeThread(jthread thread,
246 /*out*/ art::Thread** thr,
248 if (!GetNativeThread(thread, soa, thr, err)) {
258 jvmtiError ThreadUtil::GetThreadInfo(jvmtiEnv* env, jthread thread, jvmtiThreadInfo* info_ptr) {
266 art::Thread* self = art::Thread::Current();
270 art::Thread* target;
272 if (!GetNativeThread(thread, soa, &target, &err)) {
278 // Have a native thread object, this thread is alive.
315 // Only the peer. This thread has either not been started, or is dead. Read things from
317 art::ObjPtr<art::mirror::Object> peer = soa.Decode<art::mirror::Object>(thread);
380 art::Thread* native_thread;
385 // Return the thread's (or current thread, if null) thread state.
386 static InternalThreadState GetNativeThreadState(art::Thread* target)
390 art::MutexLock tscl_mu(art::Thread::Current(), *art::Locks::thread_suspend_count_lock_);
407 // Suspended can be set with any thread state so check it here. Even if the thread isn't in
415 // Interrupted can be set with any thread state so check it here.
419 // Enumerate all the thread states and fill in the other bits. This contains the results of
482 // All of these are causing the thread to wait for an indeterminate amount of time but isn't
544 // Suspends the current thread if it has any suspend requests on it.
545 void ThreadUtil::SuspendCheck(art::Thread* self) {
551 bool ThreadUtil::WouldSuspendForUserCodeLocked(art::Thread* self) {
552 DCHECK(self == art::Thread::Current());
557 bool ThreadUtil::WouldSuspendForUserCode(art::Thread* self) {
558 DCHECK(self == art::Thread::Current());
564 jthread thread,
570 art::Thread* self = art::Thread::Current();
577 art::Thread* target = nullptr;
578 if (!GetNativeThread(thread, soa, &target, &err)) {
585 // Translate internal thread state to JVMTI and Java state.
590 // different mask if a thread got suspended due to user-code. However, this is for
602 if (thread == nullptr) {
603 // No native thread, and no Java thread? We must be starting up. Report as wrong phase.
611 art::Handle<art::mirror::Object> peer(hs.NewHandle(soa.Decode<art::mirror::Object>(thread)));
634 art::Thread* current = art::Thread::Current();
639 std::list<art::Thread*> thread_list = art::Runtime::Current()->GetThreadList()->GetList();
643 for (art::Thread* thread : thread_list) {
645 if (thread->IsStillStarting()) {
649 art::ObjPtr<art::mirror::Object> peer = thread->GetPeerFromOtherThread();
675 static void RemoveTLSData(art::Thread* target, void* ctx) REQUIRES(art::Locks::thread_list_lock_) {
677 art::Locks::thread_list_lock_->AssertHeld(art::Thread::Current());
685 art::Thread* self = art::Thread::Current();
691 jvmtiError ThreadUtil::SetThreadLocalStorage(jvmtiEnv* env, jthread thread, const void* data) {
692 art::Thread* self = art::Thread::Current();
695 art::Thread* target = nullptr;
697 if (!GetAliveNativeThread(thread, soa, &target, &err)) {
708 JvmtiGlobalTLSData* ThreadUtil::GetOrCreateGlobalTLSData(art::Thread* thread) {
709 JvmtiGlobalTLSData* data = GetGlobalTLSData(thread);
713 thread->SetCustomTLS(kJvmtiTlsKey, new JvmtiGlobalTLSData);
714 return GetGlobalTLSData(thread);
718 JvmtiGlobalTLSData* ThreadUtil::GetGlobalTLSData(art::Thread* thread) {
719 return reinterpret_cast<JvmtiGlobalTLSData*>(thread->GetCustomTLS(kJvmtiTlsKey));
723 jthread thread,
729 art::Thread* self = art::Thread::Current();
732 art::Thread* target = nullptr;
734 if (!GetAliveNativeThread(thread, soa, &target, &err)) {
756 jthread thread;
765 CHECK(data->thread != nullptr);
768 art::Thread* self = art::Thread::Attach(data->name.c_str(), true, data->thread);
769 CHECK(self != nullptr) << "threads_being_born_ should have ensured thread could be attached.";
770 // The name in Attach() is only for logging. Set the thread name. This is important so
771 // that the thread is no longer seen as starting up.
779 env->DeleteGlobalRef(data->thread);
780 data->thread = nullptr;
783 // The StartThreadBirth was called in the parent thread. We let the runtime know we are up
785 art::MutexLock mu(art::Thread::Current(), *art::Locks::runtime_shutdown_lock_);
792 // Detach the thread.
800 jthread thread,
810 JNIEnv* env = art::Thread::Current()->GetJniEnv();
811 if (thread == nullptr || !env->IsInstanceOf(thread, art::WellKnownClasses::java_lang_Thread)) {
820 art::MutexLock mu(art::Thread::Current(), *art::Locks::runtime_shutdown_lock_);
837 data->thread = env->NewGlobalRef(thread);
844 env->GetObjectField(thread, art::WellKnownClasses::java_lang_Thread_name)));
846 data->name = "JVMTI Agent Thread";
858 // If the create succeeded the other thread will call EndThreadBirth.
860 art::MutexLock mu(art::Thread::Current(), *art::Locks::runtime_shutdown_lock_);
869 jvmtiError ThreadUtil::SuspendOther(art::Thread* self,
880 art::Thread* target = nullptr;
896 art::Thread* ret_target = art::Runtime::Current()->GetThreadList()->SuspendThreadByPeer(
902 // TODO It would be good to get more information about why exactly the thread failed to
914 jvmtiError ThreadUtil::SuspendSelf(art::Thread* self) {
915 CHECK(self == art::Thread::Current());
920 // This can only happen if we race with another thread to suspend 'self' and we lose.
936 jvmtiError ThreadUtil::SuspendThread(jvmtiEnv* env ATTRIBUTE_UNUSED, jthread thread) {
937 art::Thread* self = art::Thread::Current();
942 art::Thread* target = nullptr;
944 if (!GetAliveNativeThread(thread, soa, &target, &err)) {
953 return SuspendOther(self, thread);
958 jthread thread) {
959 if (thread == nullptr) {
962 art::Thread* self = art::Thread::Current();
963 art::Thread* target;
965 // Make sure we won't get suspended ourselves while in the middle of resuming another thread.
969 // NB This does a SuspendCheck (during thread state change) so we need to make sure we don't
974 if (!GetAliveNativeThread(thread, soa, &target, &err)) {
991 // It is okay that we don't have a thread_list_lock here since we know that the thread cannot
1008 art::Thread* self = art::Thread::Current();
1011 art::Thread* target = nullptr;
1022 // current thread is present multiple times. In that case we need to suspend only once and either
1024 // it didn't. We also want to handle the current thread last to make the behavior of the code
1036 // running thread. These indexes we need to handle specially since we need to only actually
1076 jthread thread,
1078 art::Thread* self = art::Thread::Current();
1090 art::Thread* target = nullptr;
1092 if (!GetAliveNativeThread(thread, soa, &target, &err)) {
1103 void Run(art::Thread* me) override REQUIRES_SHARED(art::Locks::mutator_lock_) {
1104 // Make sure the thread is prepared to notice the exception.
1107 // Wake up the thread if it is sleeping.
1119 // Something went wrong, probably the thread died.
1124 jvmtiError ThreadUtil::InterruptThread(jvmtiEnv* env ATTRIBUTE_UNUSED, jthread thread) {
1125 art::Thread* self = art::Thread::Current();
1128 art::Thread* target = nullptr;
1130 if (!GetAliveNativeThread(thread, soa, &target, &err)) {