63 64 // Used only to handle jni locks or other unmatched monitor enter/exit 65 // Internally they will use heavy weight monitor. 66 static void jni_enter (Handle obj, TRAPS); 67 static bool jni_try_enter(Handle obj, Thread* THREAD); // Implements Unsafe.tryMonitorEnter 68 static void jni_exit (oop obj, Thread* THREAD); 69 70 // Handle all interpreter, compiler and jni cases 71 static void wait (Handle obj, jlong millis, TRAPS); 72 static void notify (Handle obj, TRAPS); 73 static void notifyall (Handle obj, TRAPS); 74 75 // Special internal-use-only method for use by JVM infrastructure 76 // that needs to wait() on a java-level object but that can't risk 77 // throwing unexpected InterruptedExecutionExceptions. 78 static void waitUninterruptibly (Handle obj, jlong Millis, Thread * THREAD) ; 79 80 // used by classloading to free classloader object lock, 81 // wait on an internal lock, and reclaim original lock 82 // with original recursion count 83 static intptr_t complete_exit (Handle obj, TRAPS); 84 static void reenter (Handle obj, intptr_t recursion, TRAPS); 85 86 // thread-specific and global objectMonitor free list accessors 87 // static void verifyInUse (Thread * Self) ; too slow for general assert/debug 88 static ObjectMonitor * omAlloc (Thread * Self) ; 89 static void omRelease (Thread * Self, ObjectMonitor * m, bool FromPerThreadAlloc) ; 90 static void omFlush (Thread * Self) ; 91 92 // Inflate light weight monitor to heavy weight monitor 93 static ObjectMonitor* inflate(Thread * Self, oop obj); 94 // This version is only for internal use 95 static ObjectMonitor* inflate_helper(oop obj); 96 97 // Returns the identity hash value for an oop 98 // NOTE: It may cause monitor inflation 99 static intptr_t identity_hash_value_for(Handle obj); 100 static intptr_t FastHashCode (Thread * Self, oop obj) ; 101 102 // java.lang.Thread support 103 static bool current_thread_holds_lock(JavaThread* thread, Handle h_obj); 104 static LockOwnership query_lock_ownership(JavaThread * self, Handle h_obj); 139 // IllegalMonitorStateException. However, a pending exception may 140 // have to pass through, and we must also be able to deal with 141 // asynchronous exceptions. The caller is responsible for checking 142 // the threads pending exception if needed. 143 // doLock was added to support classloading with UnsyncloadClass which 144 // requires flag based choice of locking the classloader lock. 145 class ObjectLocker : public StackObj { 146 private: 147 Thread* _thread; 148 Handle _obj; 149 BasicLock _lock; 150 bool _dolock; // default true 151 public: 152 ObjectLocker(Handle obj, Thread* thread, bool doLock = true); 153 ~ObjectLocker(); 154 155 // Monitor behavior 156 void wait (TRAPS) { ObjectSynchronizer::wait (_obj, 0, CHECK); } // wait forever 157 void notify_all(TRAPS) { ObjectSynchronizer::notifyall(_obj, CHECK); } 158 void waitUninterruptibly (TRAPS) { ObjectSynchronizer::waitUninterruptibly (_obj, 0, CHECK);} 159 // complete_exit gives up lock completely, returning recursion count 160 // reenter reclaims lock with original recursion count 161 intptr_t complete_exit(TRAPS) { return ObjectSynchronizer::complete_exit(_obj, CHECK_0); } 162 void reenter(intptr_t recursion, TRAPS) { ObjectSynchronizer::reenter(_obj, recursion, CHECK); } 163 }; 164 165 #endif // SHARE_VM_RUNTIME_SYNCHRONIZER_HPP | 63 64 // Used only to handle jni locks or other unmatched monitor enter/exit 65 // Internally they will use heavy weight monitor. 66 static void jni_enter (Handle obj, TRAPS); 67 static bool jni_try_enter(Handle obj, Thread* THREAD); // Implements Unsafe.tryMonitorEnter 68 static void jni_exit (oop obj, Thread* THREAD); 69 70 // Handle all interpreter, compiler and jni cases 71 static void wait (Handle obj, jlong millis, TRAPS); 72 static void notify (Handle obj, TRAPS); 73 static void notifyall (Handle obj, TRAPS); 74 75 // Special internal-use-only method for use by JVM infrastructure 76 // that needs to wait() on a java-level object but that can't risk 77 // throwing unexpected InterruptedExecutionExceptions. 78 static void waitUninterruptibly (Handle obj, jlong Millis, Thread * THREAD) ; 79 80 // used by classloading to free classloader object lock, 81 // wait on an internal lock, and reclaim original lock 82 // with original recursion count 83 static void complete_exit(Handle obj, intptr_t *saved_recursions, intptr_t *saved_trace_exit_stack, TRAPS); 84 static void reenter (Handle obj, intptr_t saved_recursions, intptr_t saved_trace_exit_stack, TRAPS); 85 86 // thread-specific and global objectMonitor free list accessors 87 // static void verifyInUse (Thread * Self) ; too slow for general assert/debug 88 static ObjectMonitor * omAlloc (Thread * Self) ; 89 static void omRelease (Thread * Self, ObjectMonitor * m, bool FromPerThreadAlloc) ; 90 static void omFlush (Thread * Self) ; 91 92 // Inflate light weight monitor to heavy weight monitor 93 static ObjectMonitor* inflate(Thread * Self, oop obj); 94 // This version is only for internal use 95 static ObjectMonitor* inflate_helper(oop obj); 96 97 // Returns the identity hash value for an oop 98 // NOTE: It may cause monitor inflation 99 static intptr_t identity_hash_value_for(Handle obj); 100 static intptr_t FastHashCode (Thread * Self, oop obj) ; 101 102 // java.lang.Thread support 103 static bool current_thread_holds_lock(JavaThread* thread, Handle h_obj); 104 static LockOwnership query_lock_ownership(JavaThread * self, Handle h_obj); 139 // IllegalMonitorStateException. However, a pending exception may 140 // have to pass through, and we must also be able to deal with 141 // asynchronous exceptions. The caller is responsible for checking 142 // the threads pending exception if needed. 143 // doLock was added to support classloading with UnsyncloadClass which 144 // requires flag based choice of locking the classloader lock. 145 class ObjectLocker : public StackObj { 146 private: 147 Thread* _thread; 148 Handle _obj; 149 BasicLock _lock; 150 bool _dolock; // default true 151 public: 152 ObjectLocker(Handle obj, Thread* thread, bool doLock = true); 153 ~ObjectLocker(); 154 155 // Monitor behavior 156 void wait (TRAPS) { ObjectSynchronizer::wait (_obj, 0, CHECK); } // wait forever 157 void notify_all(TRAPS) { ObjectSynchronizer::notifyall(_obj, CHECK); } 158 void waitUninterruptibly (TRAPS) { ObjectSynchronizer::waitUninterruptibly (_obj, 0, CHECK);} 159 }; 160 161 #endif // SHARE_VM_RUNTIME_SYNCHRONIZER_HPP |