namespace art { class ArtField; class ScopedObjectAccessAlreadyRunnable; class Thread; class Closure; namespace mirror { class Throwable;
} // namespace mirror
} // namespace art
namespace openjdkjvmti {
class EventHandler;
// Gains the user_code_suspension_lock_ and ensures that the code will not suspend for user-code. class SCOPED_CAPABILITY ScopedNoUserCodeSuspension { public: explicit ScopedNoUserCodeSuspension(art::Thread* self)
ACQUIRE(art::Locks::user_code_suspension_lock_);
~ScopedNoUserCodeSuspension() RELEASE(art::Locks::user_code_suspension_lock_);
private:
art::Thread* self_;
};
// The struct that we store in the art::Thread::custom_tls_ that maps the jvmtiEnvs to the data // stored with that thread. This is needed since different jvmtiEnvs are not supposed to share TLS // data but we only have a single slot in Thread objects to store data. struct JvmtiGlobalTLSData : public art::TLSData {
std::unordered_map<jvmtiEnv*, constvoid*> data GUARDED_BY(art::Locks::thread_list_lock_);
// The depth of the last frame where popping using PopFrame it is not allowed. It is set to // kNoDisallowedPopFrame if all frames can be popped. See b/117615146 for more information. static constexpr size_t kNoDisallowedPopFrame = -1;
size_t disable_pop_frame_depth = kNoDisallowedPopFrame;
};
class ThreadUtil { public: staticvoidRegister(EventHandler* event_handler); staticvoid Unregister();
// To be called when it is safe to cache data. This means that we have at least entered the // RuntimePhase::kInit but we might or might not have already called VMInit event. staticvoid CacheData();
// Called just after we have sent the VMInit callback so that ThreadUtil can do final setup. This // ensures that there are no timing issues between the two callbacks. staticvoid VMInitEventSent() REQUIRES_SHARED(art::Locks::mutator_lock_);
// Handle a jvmtiEnv going away. staticvoid RemoveEnvironment(jvmtiEnv* env);
// Returns true if we decoded the thread and it is alive, false otherwise with an appropriate // error placed into 'err'. A thread is alive if it has had it's 'start' function called and has // (or at least could have) executed managed code and has not yet returned past it's first managed // frame. This means that the thread returned might have IsStillStarting() return true. Code that // does not consider that alive should check manually. staticbool GetAliveNativeThread(jthread thread, const art::ScopedObjectAccessAlreadyRunnable& soa, /*out*/ art::Thread** thr, /*out*/ jvmtiError* err)
REQUIRES_SHARED(art::Locks::mutator_lock_)
REQUIRES(art::Locks::thread_list_lock_);
// Returns true if we decoded the thread, false otherwise with an appropriate error placed into // 'err' staticbool GetNativeThread(jthread thread, const art::ScopedObjectAccessAlreadyRunnable& soa, /*out*/ art::Thread** thr, /*out*/ jvmtiError* err)
REQUIRES_SHARED(art::Locks::mutator_lock_)
REQUIRES(art::Locks::thread_list_lock_);
// Go to sleep if this thread is suspended. staticvoid SuspendCheck(art::Thread* self)
REQUIRES(!art::Locks::mutator_lock_, !art::Locks::user_code_suspension_lock_);
// Returns true if the thread would be suspended if it locks the mutator-lock or calls // SuspendCheck. This function is called with the user_code_suspension_lock already held. staticbool WouldSuspendForUserCodeLocked(art::Thread* self)
REQUIRES(art::Locks::user_code_suspension_lock_,
!art::Locks::thread_suspend_count_lock_);
// Returns true if this thread would go to sleep if it locks the mutator-lock or calls // SuspendCheck. staticbool WouldSuspendForUserCode(art::Thread* self)
REQUIRES(!art::Locks::user_code_suspension_lock_,
!art::Locks::thread_suspend_count_lock_);
private: // We need to make sure only one thread tries to suspend threads at a time so we can get the // 'suspend-only-once' behavior the spec requires. Internally, ART considers suspension to be a // counted state, allowing a single thread to be suspended multiple times by different users. This // makes mapping into the JVMTI idea of thread suspension difficult. We have decided to split the // difference and ensure that JVMTI tries to treat suspension as the boolean flag as much as // possible with the suspend/resume methods but only do best effort. On the other hand // GetThreadState will be totally accurate as much as possible. This means that calling // ResumeThread on a thread that has state JVMTI_THREAD_STATE_SUSPENDED will not necessarily // cause the thread to wake up if the thread is suspended for the debugger or gc or something. static jvmtiError SuspendSelf(art::Thread* self)
REQUIRES(!art::Locks::mutator_lock_, !art::Locks::user_code_suspension_lock_); static jvmtiError SuspendOther(art::Thread* self, jthread target_jthread)
REQUIRES(!art::Locks::mutator_lock_, !art::Locks::user_code_suspension_lock_);
static art::ArtField* context_class_loader_;
};
} // namespace openjdkjvmti
#endif// ART_OPENJDKJVMTI_TI_THREAD_H_
Messung V0.5 in Prozent
¤ Dauer der Verarbeitung: 0.10 Sekunden
(vorverarbeitet am 2026-06-29)
¤
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.