< prev index next >

src/hotspot/share/runtime/synchronizer.hpp

Print this page

109   static void jni_enter(Handle obj, JavaThread* current);
110   static void jni_exit(oop obj, TRAPS);
111 
112   // Handle all interpreter, compiler and jni cases
113   static int  wait(Handle obj, jlong millis, TRAPS);
114   static void notify(Handle obj, TRAPS);
115   static void notifyall(Handle obj, TRAPS);
116 
117   static bool quick_notify(oopDesc* obj, JavaThread* current, bool All);
118   static inline bool quick_enter(oop obj, BasicLock* Lock, JavaThread* current);
119 
120   // Special internal-use-only method for use by JVM infrastructure
121   // that needs to wait() on a java-level object but that can't risk
122   // throwing unexpected InterruptedExecutionExceptions.
123   static void waitUninterruptibly(Handle obj, jlong Millis, TRAPS);
124 
125 public:
126   static const char* inflate_cause_name(const InflateCause cause);
127 
128   inline static ObjectMonitor* read_monitor(markWord mark);

129   inline static ObjectMonitor* read_monitor(Thread* current, oop obj, markWord mark);
130 
131   // Returns the identity hash value for an oop
132   // NOTE: It may cause monitor inflation
133   static intptr_t FastHashCode(Thread* current, oop obj);
134 
135   // java.lang.Thread support
136   static bool current_thread_holds_lock(JavaThread* current, Handle h_obj);
137 
138   static JavaThread* get_lock_owner(ThreadsList * t_list, Handle h_obj);
139 
140   // JNI detach support
141   static void release_monitors_owned_by_thread(JavaThread* current);
142 
143   // Iterate over all ObjectMonitors.
144   template <typename Function>
145   static void monitors_iterate(Function function);
146 
147   // Iterate ObjectMonitors owned by any thread and where the owner `filter`
148   // returns true.

207   static size_t get_gvars_size();
208   static u_char* get_gvars_stw_random_addr();
209 
210   static void handle_sync_on_value_based_class(Handle obj, JavaThread* locking_thread);
211 };
212 
213 // ObjectLocker enforces balanced locking and can never throw an
214 // IllegalMonitorStateException. However, a pending exception may
215 // have to pass through, and we must also be able to deal with
216 // asynchronous exceptions. The caller is responsible for checking
217 // the thread's pending exception if needed.
218 // When using ObjectLocker the top native frames in the stack will
219 // not be seen in case we attempt preemption, since we start walking
220 // from the last Java anchor, so we disable it with NoPreemptMark.
221 class ObjectLocker : public StackObj {
222  private:
223   JavaThread* _thread;
224   Handle      _obj;
225   BasicLock   _lock;
226   NoPreemptMark _npm;

227  public:
228   ObjectLocker(Handle obj, JavaThread* current);
229   ~ObjectLocker();
230 
231   // Monitor behavior
232   void wait(TRAPS)  { ObjectSynchronizer::wait(_obj, 0, CHECK); } // wait forever
233   void wait_uninterruptibly(TRAPS)  { ObjectSynchronizer::waitUninterruptibly(_obj, 0, CHECK); } // wait forever
234   void notify_all(TRAPS)  { ObjectSynchronizer::notifyall(_obj, CHECK); }
235 };
236 
237 // Interface to visit monitors
238 class ObjectMonitorsView {
239 public:
240   // Visit monitors that belong to the given thread
241   virtual void visit(MonitorClosure* closure, JavaThread* thread) = 0;
242 };
243 
244 #endif // SHARE_RUNTIME_SYNCHRONIZER_HPP

109   static void jni_enter(Handle obj, JavaThread* current);
110   static void jni_exit(oop obj, TRAPS);
111 
112   // Handle all interpreter, compiler and jni cases
113   static int  wait(Handle obj, jlong millis, TRAPS);
114   static void notify(Handle obj, TRAPS);
115   static void notifyall(Handle obj, TRAPS);
116 
117   static bool quick_notify(oopDesc* obj, JavaThread* current, bool All);
118   static inline bool quick_enter(oop obj, BasicLock* Lock, JavaThread* current);
119 
120   // Special internal-use-only method for use by JVM infrastructure
121   // that needs to wait() on a java-level object but that can't risk
122   // throwing unexpected InterruptedExecutionExceptions.
123   static void waitUninterruptibly(Handle obj, jlong Millis, TRAPS);
124 
125 public:
126   static const char* inflate_cause_name(const InflateCause cause);
127 
128   inline static ObjectMonitor* read_monitor(markWord mark);
129   inline static ObjectMonitor* read_monitor(Thread* current, oop obj);
130   inline static ObjectMonitor* read_monitor(Thread* current, oop obj, markWord mark);
131 
132   // Returns the identity hash value for an oop
133   // NOTE: It may cause monitor inflation
134   static intptr_t FastHashCode(Thread* current, oop obj);
135 
136   // java.lang.Thread support
137   static bool current_thread_holds_lock(JavaThread* current, Handle h_obj);
138 
139   static JavaThread* get_lock_owner(ThreadsList * t_list, Handle h_obj);
140 
141   // JNI detach support
142   static void release_monitors_owned_by_thread(JavaThread* current);
143 
144   // Iterate over all ObjectMonitors.
145   template <typename Function>
146   static void monitors_iterate(Function function);
147 
148   // Iterate ObjectMonitors owned by any thread and where the owner `filter`
149   // returns true.

208   static size_t get_gvars_size();
209   static u_char* get_gvars_stw_random_addr();
210 
211   static void handle_sync_on_value_based_class(Handle obj, JavaThread* locking_thread);
212 };
213 
214 // ObjectLocker enforces balanced locking and can never throw an
215 // IllegalMonitorStateException. However, a pending exception may
216 // have to pass through, and we must also be able to deal with
217 // asynchronous exceptions. The caller is responsible for checking
218 // the thread's pending exception if needed.
219 // When using ObjectLocker the top native frames in the stack will
220 // not be seen in case we attempt preemption, since we start walking
221 // from the last Java anchor, so we disable it with NoPreemptMark.
222 class ObjectLocker : public StackObj {
223  private:
224   JavaThread* _thread;
225   Handle      _obj;
226   BasicLock   _lock;
227   NoPreemptMark _npm;
228   bool    _skip_exit;
229  public:
230   ObjectLocker(Handle obj, TRAPS);
231   ~ObjectLocker();
232 
233   // Monitor behavior
234   void wait_uninterruptibly(TRAPS);

235   void notify_all(TRAPS)  { ObjectSynchronizer::notifyall(_obj, CHECK); }
236 };
237 
238 // Interface to visit monitors
239 class ObjectMonitorsView {
240 public:
241   // Visit monitors that belong to the given thread
242   virtual void visit(MonitorClosure* closure, JavaThread* thread) = 0;
243 };
244 
245 #endif // SHARE_RUNTIME_SYNCHRONIZER_HPP
< prev index next >