diff options
author | 2017-11-20 23:58:35 +0000 | |
---|---|---|
committer | 2017-11-20 23:58:35 +0000 | |
commit | af9341087aab0146b8323ece156bde8130948465 (patch) | |
tree | d79c8ff901ab2017dd6308f9bd43d02b877a5c9e /openjdkjvmti/events.h | |
parent | e5a2ae30bdbe379695dc886861b23dce57de0825 (diff) |
Revert "Make JVMTI DisposeEnvironment and GetEnv thread safe."
This reverts commit e5a2ae30bdbe379695dc886861b23dce57de0825.
Reason for revert: fails art-gc-gss-tlab column.
Test: None
Bug: 69465262
Change-Id: I70af77297bc7870d281ed8ffb319d144ddb12838
Diffstat (limited to 'openjdkjvmti/events.h')
-rw-r--r-- | openjdkjvmti/events.h | 67 |
1 files changed, 17 insertions, 50 deletions
diff --git a/openjdkjvmti/events.h b/openjdkjvmti/events.h index c73215f07b..a99ed7b212 100644 --- a/openjdkjvmti/events.h +++ b/openjdkjvmti/events.h @@ -158,10 +158,6 @@ struct EventMasks { void HandleChangedCapabilities(const jvmtiCapabilities& caps, bool caps_added); }; -namespace impl { -template <ArtJvmtiEvent kEvent> struct EventHandlerFunc { }; -} // namespace impl - // Helper class for event handling. class EventHandler { public: @@ -173,10 +169,10 @@ class EventHandler { // Register an env. It is assumed that this happens on env creation, that is, no events are // enabled, yet. - void RegisterArtJvmTiEnv(ArtJvmTiEnv* env) REQUIRES(!envs_lock_); + void RegisterArtJvmTiEnv(ArtJvmTiEnv* env); // Remove an env. - void RemoveArtJvmTiEnv(ArtJvmTiEnv* env) REQUIRES(!envs_lock_); + void RemoveArtJvmTiEnv(ArtJvmTiEnv* env); bool IsEventEnabledAnywhere(ArtJvmtiEvent event) const { if (!EventMask::EventIsInRange(event)) { @@ -188,15 +184,13 @@ class EventHandler { jvmtiError SetEvent(ArtJvmTiEnv* env, art::Thread* thread, ArtJvmtiEvent event, - jvmtiEventMode mode) - REQUIRES(!envs_lock_); + jvmtiEventMode mode); // Dispatch event to all registered environments. Since this one doesn't have a JNIEnv* it doesn't // matter if it has the mutator_lock. template <ArtJvmtiEvent kEvent, typename ...Args> ALWAYS_INLINE - inline void DispatchEvent(art::Thread* thread, Args... args) const - REQUIRES(!envs_lock_); + inline void DispatchEvent(art::Thread* thread, Args... args) const; // Dispatch event to all registered environments stashing exceptions as needed. This works since // JNIEnv* is always the second argument if it is passed to an event. Needed since C++ does not @@ -206,8 +200,7 @@ class EventHandler { // the event to allocate local references. template <ArtJvmtiEvent kEvent, typename ...Args> ALWAYS_INLINE - inline void DispatchEvent(art::Thread* thread, JNIEnv* jnienv, Args... args) const - REQUIRES(!envs_lock_); + inline void DispatchEvent(art::Thread* thread, JNIEnv* jnienv, Args... args) const; // Tell the event handler capabilities were added/lost so it can adjust the sent events.If // caps_added is true then caps is all the newly set capabilities of the jvmtiEnv. If it is false @@ -215,50 +208,30 @@ class EventHandler { ALWAYS_INLINE inline void HandleChangedCapabilities(ArtJvmTiEnv* env, const jvmtiCapabilities& caps, - bool added) - REQUIRES(!envs_lock_); + bool added); // Dispatch event to the given environment, only. template <ArtJvmtiEvent kEvent, typename ...Args> ALWAYS_INLINE - inline void DispatchEventOnEnv(ArtJvmTiEnv* env, - art::Thread* thread, - JNIEnv* jnienv, - Args... args) const - REQUIRES(!envs_lock_); + inline void DispatchEventOnEnv( + ArtJvmTiEnv* env, art::Thread* thread, JNIEnv* jnienv, Args... args) const; // Dispatch event to the given environment, only. template <ArtJvmtiEvent kEvent, typename ...Args> ALWAYS_INLINE - inline void DispatchEventOnEnv(ArtJvmTiEnv* env, art::Thread* thread, Args... args) const - REQUIRES(!envs_lock_); + inline void DispatchEventOnEnv(ArtJvmTiEnv* env, art::Thread* thread, Args... args) const; private: - template <ArtJvmtiEvent kEvent, typename ...Args> - ALWAYS_INLINE - inline std::vector<impl::EventHandlerFunc<kEvent>> CollectEvents(art::Thread* thread, - Args... args) const - REQUIRES(!envs_lock_); - template <ArtJvmtiEvent kEvent> ALWAYS_INLINE - inline bool ShouldDispatchOnThread(ArtJvmTiEnv* env, art::Thread* thread) const; + static inline bool ShouldDispatchOnThread(ArtJvmTiEnv* env, art::Thread* thread); template <ArtJvmtiEvent kEvent, typename ...Args> ALWAYS_INLINE - static inline void ExecuteCallback(impl::EventHandlerFunc<kEvent> handler, - JNIEnv* env, - Args... args) - REQUIRES(!envs_lock_); + static inline void ExecuteCallback(ArtJvmTiEnv* env, Args... args); template <ArtJvmtiEvent kEvent, typename ...Args> ALWAYS_INLINE - static inline void ExecuteCallback(impl::EventHandlerFunc<kEvent> handler, Args... args) - REQUIRES(!envs_lock_); - - // Public for use to collect dispatches - template <ArtJvmtiEvent kEvent, typename ...Args> - ALWAYS_INLINE inline bool ShouldDispatch(ArtJvmTiEnv* env, art::Thread* thread, Args... args) const; ALWAYS_INLINE @@ -268,9 +241,7 @@ class EventHandler { // Recalculates the event mask for the given event. ALWAYS_INLINE - inline void RecalculateGlobalEventMask(ArtJvmtiEvent event) REQUIRES(!envs_lock_); - ALWAYS_INLINE - inline void RecalculateGlobalEventMaskLocked(ArtJvmtiEvent event) REQUIRES(envs_lock_); + inline void RecalculateGlobalEventMask(ArtJvmtiEvent event); template <ArtJvmtiEvent kEvent> ALWAYS_INLINE inline void DispatchClassFileLoadHookEvent(art::Thread* thread, @@ -282,8 +253,7 @@ class EventHandler { jint class_data_len, const unsigned char* class_data, jint* new_class_data_len, - unsigned char** new_class_data) const - REQUIRES(!envs_lock_); + unsigned char** new_class_data) const; void HandleEventType(ArtJvmtiEvent event, bool enable); void HandleLocalAccessCapabilityAdded(); @@ -291,13 +261,10 @@ class EventHandler { bool OtherMonitorEventsEnabledAnywhere(ArtJvmtiEvent event); - // List of all JvmTiEnv objects that have been created, in their creation order. It is a std::list - // since we mostly access it by iterating over the entire thing, only ever append to the end, and - // need to be able to remove arbitrary elements from it. - std::list<ArtJvmTiEnv*> envs GUARDED_BY(envs_lock_); - - // Top level lock. Nothing at all should be held when we lock this. - mutable art::Mutex envs_lock_ ACQUIRED_BEFORE(art::Locks::instrument_entrypoints_lock_); + // List of all JvmTiEnv objects that have been created, in their creation order. + // NB Some elements might be null representing envs that have been deleted. They should be skipped + // anytime this list is used. + std::vector<ArtJvmTiEnv*> envs; // A union of all enabled events, anywhere. EventMask global_mask; |