diff options
Diffstat (limited to 'runtime/runtime_callbacks.h')
-rw-r--r-- | runtime/runtime_callbacks.h | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/runtime/runtime_callbacks.h b/runtime/runtime_callbacks.h index e8f1824262..fa686d30e1 100644 --- a/runtime/runtime_callbacks.h +++ b/runtime/runtime_callbacks.h @@ -29,12 +29,14 @@ namespace art { namespace mirror { class Class; class ClassLoader; +class Object; } // namespace mirror class ArtMethod; class ClassLoadCallback; class Thread; class MethodCallback; +class Monitor; class ThreadLifecycleCallback; // Note: RuntimeCallbacks uses the mutator lock to synchronize the callback lists. A thread must @@ -73,6 +75,25 @@ class RuntimePhaseCallback { virtual void NextRuntimePhase(RuntimePhase phase) REQUIRES_SHARED(Locks::mutator_lock_) = 0; }; +class MonitorCallback { + public: + // Called just before the thread goes to sleep to wait for the monitor to become unlocked. + virtual void MonitorContendedLocking(Monitor* mon) REQUIRES_SHARED(Locks::mutator_lock_) = 0; + // Called just after the monitor has been successfully acquired when it was already locked. + virtual void MonitorContendedLocked(Monitor* mon) REQUIRES_SHARED(Locks::mutator_lock_) = 0; + // Called on entry to the Object#wait method regardless of whether or not the call is valid. + virtual void ObjectWaitStart(Handle<mirror::Object> obj, int64_t millis_timeout) + REQUIRES_SHARED(Locks::mutator_lock_) = 0; + + // Called just after the monitor has woken up from going to sleep for a wait(). At this point the + // thread does not possess a lock on the monitor. This will only be called for threads wait calls + // where the thread did (or at least could have) gone to sleep. + virtual void MonitorWaitFinished(Monitor* m, bool timed_out) + REQUIRES_SHARED(Locks::mutator_lock_) = 0; + + virtual ~MonitorCallback() {} +}; + class RuntimeCallbacks { public: void AddThreadLifecycleCallback(ThreadLifecycleCallback* cb) REQUIRES(Locks::mutator_lock_); @@ -120,6 +141,16 @@ class RuntimeCallbacks { /*out*/void** new_implementation) REQUIRES_SHARED(Locks::mutator_lock_); + void MonitorContendedLocking(Monitor* m) REQUIRES_SHARED(Locks::mutator_lock_); + void MonitorContendedLocked(Monitor* m) REQUIRES_SHARED(Locks::mutator_lock_); + void ObjectWaitStart(Handle<mirror::Object> m, int64_t timeout) + REQUIRES_SHARED(Locks::mutator_lock_); + void MonitorWaitFinished(Monitor* m, bool timed_out) + REQUIRES_SHARED(Locks::mutator_lock_); + + void AddMonitorCallback(MonitorCallback* cb) REQUIRES_SHARED(Locks::mutator_lock_); + void RemoveMonitorCallback(MonitorCallback* cb) REQUIRES_SHARED(Locks::mutator_lock_); + private: std::vector<ThreadLifecycleCallback*> thread_callbacks_ GUARDED_BY(Locks::mutator_lock_); @@ -131,6 +162,8 @@ class RuntimeCallbacks { GUARDED_BY(Locks::mutator_lock_); std::vector<MethodCallback*> method_callbacks_ GUARDED_BY(Locks::mutator_lock_); + std::vector<MonitorCallback*> monitor_callbacks_ + GUARDED_BY(Locks::mutator_lock_); }; } // namespace art |