hotspot/src/share/vm/runtime/synchronizer.cpp
changeset 37250 2fecd8bdc8e9
parent 37092 0e56e3c9d545
child 37251 9fc139ad74b5
equal deleted inserted replaced
37248:11a660dbbb8e 37250:2fecd8bdc8e9
   202 // recursive enter and exit, so they go here instead.
   202 // recursive enter and exit, so they go here instead.
   203 // Note that we can't safely call AsyncPrintJavaStack() from within
   203 // Note that we can't safely call AsyncPrintJavaStack() from within
   204 // quick_enter() as our thread state remains _in_Java.
   204 // quick_enter() as our thread state remains _in_Java.
   205 
   205 
   206 bool ObjectSynchronizer::quick_enter(oop obj, Thread * Self,
   206 bool ObjectSynchronizer::quick_enter(oop obj, Thread * Self,
   207                                      BasicLock * Lock) {
   207                                      BasicLock * lock) {
   208   assert(!SafepointSynchronize::is_at_safepoint(), "invariant");
   208   assert(!SafepointSynchronize::is_at_safepoint(), "invariant");
   209   assert(Self->is_Java_thread(), "invariant");
   209   assert(Self->is_Java_thread(), "invariant");
   210   assert(((JavaThread *) Self)->thread_state() == _thread_in_Java, "invariant");
   210   assert(((JavaThread *) Self)->thread_state() == _thread_in_Java, "invariant");
   211   NoSafepointVerifier nsv;
   211   NoSafepointVerifier nsv;
   212   if (obj == NULL) return false;       // Need to throw NPE
   212   if (obj == NULL) return false;       // Need to throw NPE
   224 
   224 
   225     if (owner == Self) {
   225     if (owner == Self) {
   226       m->_recursions++;
   226       m->_recursions++;
   227       return true;
   227       return true;
   228     }
   228     }
       
   229 
       
   230     // This Java Monitor is inflated so obj's header will never be
       
   231     // displaced to this thread's BasicLock. Make the displaced header
       
   232     // non-NULL so this BasicLock is not seen as recursive nor as
       
   233     // being locked. We do this unconditionally so that this thread's
       
   234     // BasicLock cannot be mis-interpreted by any stack walkers. For
       
   235     // performance reasons, stack walkers generally first check for
       
   236     // Biased Locking in the object's header, the second check is for
       
   237     // stack-locking in the object's header, the third check is for
       
   238     // recursive stack-locking in the displaced header in the BasicLock,
       
   239     // and last are the inflated Java Monitor (ObjectMonitor) checks.
       
   240     lock->set_displaced_header(markOopDesc::unused_mark());
   229 
   241 
   230     if (owner == NULL &&
   242     if (owner == NULL &&
   231         Atomic::cmpxchg_ptr(Self, &(m->_owner), NULL) == NULL) {
   243         Atomic::cmpxchg_ptr(Self, &(m->_owner), NULL) == NULL) {
   232       assert(m->_recursions == 0, "invariant");
   244       assert(m->_recursions == 0, "invariant");
   233       assert(m->_owner == Self, "invariant");
   245       assert(m->_owner == Self, "invariant");