< prev index next >

src/hotspot/share/runtime/mutex.cpp

Print this page
rev 56464 : 8231707: Improve Mutex inlining
Reviewed-by: coleenp, rehn

*** 68,88 **** "This lock should %s have a safepoint check for Java threads: %s", _safepoint_check_required ? "always" : "never", name()); } #endif // ASSERT ! void Mutex::lock(Thread* self) { ! check_safepoint_state(self); ! ! assert(_owner != self, "invariant"); ! ! Mutex* in_flight_mutex = NULL; DEBUG_ONLY(int retry_cnt = 0;) bool is_active_Java_thread = self->is_active_Java_thread(); ! while (!_lock.try_lock()) { ! // The lock is contended ! #ifdef ASSERT if (retry_cnt++ > 3) { log_trace(vmmutex)("JavaThread " INTPTR_FORMAT " on %d attempt trying to acquire vmmutex %s", p2i(self), retry_cnt, _name); } #endif // ASSERT --- 68,82 ---- "This lock should %s have a safepoint check for Java threads: %s", _safepoint_check_required ? "always" : "never", name()); } #endif // ASSERT ! void Mutex::lock_contended(Thread* self) { ! Mutex *in_flight_mutex = NULL; DEBUG_ONLY(int retry_cnt = 0;) bool is_active_Java_thread = self->is_active_Java_thread(); ! do { #ifdef ASSERT if (retry_cnt++ > 3) { log_trace(vmmutex)("JavaThread " INTPTR_FORMAT " on %d attempt trying to acquire vmmutex %s", p2i(self), retry_cnt, _name); } #endif // ASSERT
*** 100,117 **** } } else { _lock.lock(); break; } } assert_owner(NULL); set_owner(self); } void Mutex::lock() { ! this->lock(Thread::current()); } // Lock without safepoint check - a degenerate variant of lock() for use by // JavaThreads when it is known to be safe to not check for a safepoint when // acquiring this lock. If the thread blocks acquiring the lock it is not --- 94,122 ---- } } else { _lock.lock(); break; } + } while (!_lock.try_lock()); + } + + void Mutex::lock(Thread* self) { + check_safepoint_state(self); + + assert(_owner != self, "invariant"); + + if (!_lock.try_lock()) { + // The lock is contended, use contended slow-path function to lock + lock_contended(self); } assert_owner(NULL); set_owner(self); } void Mutex::lock() { ! lock(Thread::current()); } // Lock without safepoint check - a degenerate variant of lock() for use by // JavaThreads when it is known to be safe to not check for a safepoint when // acquiring this lock. If the thread blocks acquiring the lock it is not
< prev index next >