equal
deleted
inserted
replaced
873 if (Self->is_Java_thread()) { |
873 if (Self->is_Java_thread()) { |
874 Self->clear_unhandled_oops(); |
874 Self->clear_unhandled_oops(); |
875 } |
875 } |
876 #endif // CHECK_UNHANDLED_OOPS |
876 #endif // CHECK_UNHANDLED_OOPS |
877 |
877 |
878 debug_only(check_prelock_state(Self, StrictSafepointChecks)); |
878 DEBUG_ONLY(check_prelock_state(Self, StrictSafepointChecks);) |
879 assert(_owner != Self, "invariant"); |
879 assert(_owner != Self, "invariant"); |
880 assert(_OnDeck != Self->_MutexEvent, "invariant"); |
880 assert(_OnDeck != Self->_MutexEvent, "invariant"); |
881 |
881 |
882 if (TryFast()) { |
882 if (TryFast()) { |
883 Exeunt: |
883 Exeunt: |
900 } |
900 } |
901 |
901 |
902 // Try a brief spin to avoid passing thru thread state transition ... |
902 // Try a brief spin to avoid passing thru thread state transition ... |
903 if (TrySpin(Self)) goto Exeunt; |
903 if (TrySpin(Self)) goto Exeunt; |
904 |
904 |
905 check_block_state(Self); |
905 DEBUG_ONLY(check_block_state(Self);) |
906 if (Self->is_Java_thread()) { |
906 if (Self->is_Java_thread()) { |
907 // Horrible dictu - we suffer through a state transition |
907 // Horrible dictu - we suffer through a state transition |
908 assert(rank() > Mutex::special, "Potential deadlock with special or lesser rank mutex"); |
908 assert(rank() > Mutex::special, "Potential deadlock with special or lesser rank mutex"); |
909 ThreadBlockInVM tbivm((JavaThread *) Self); |
909 ThreadBlockInVM tbivm((JavaThread *) Self); |
910 ILock(Self); |
910 ILock(Self); |
941 |
941 |
942 // Returns true if thread succeeds in grabbing the lock, otherwise false. |
942 // Returns true if thread succeeds in grabbing the lock, otherwise false. |
943 |
943 |
944 bool Monitor::try_lock() { |
944 bool Monitor::try_lock() { |
945 Thread * const Self = Thread::current(); |
945 Thread * const Self = Thread::current(); |
946 debug_only(check_prelock_state(Self, false)); |
946 DEBUG_ONLY(check_prelock_state(Self, false);) |
947 // assert(!thread->is_inside_signal_handler(), "don't lock inside signal handler"); |
947 // assert(!thread->is_inside_signal_handler(), "don't lock inside signal handler"); |
948 |
948 |
949 // Special case, where all Java threads are stopped. |
949 // Special case, where all Java threads are stopped. |
950 // The lock may have been acquired but _owner is not yet set. |
950 // The lock may have been acquired but _owner is not yet set. |
951 // In that case the VM thread can safely grab the lock. |
951 // In that case the VM thread can safely grab the lock. |
1318 |
1318 |
1319 } else { |
1319 } else { |
1320 // the thread is releasing this lock |
1320 // the thread is releasing this lock |
1321 |
1321 |
1322 Thread* old_owner = _owner; |
1322 Thread* old_owner = _owner; |
1323 debug_only(_last_owner = old_owner); |
1323 DEBUG_ONLY(_last_owner = old_owner;) |
1324 |
1324 |
1325 assert(old_owner != NULL, "removing the owner thread of an unowned mutex"); |
1325 assert(old_owner != NULL, "removing the owner thread of an unowned mutex"); |
1326 assert(old_owner == Thread::current(), "removing the owner thread of an unowned mutex"); |
1326 assert(old_owner == Thread::current(), "removing the owner thread of an unowned mutex"); |
1327 |
1327 |
1328 _owner = NULL; // set the owner |
1328 _owner = NULL; // set the owner |
1358 assert((!thread->is_Java_thread() || ((JavaThread *)thread)->thread_state() == _thread_in_vm) |
1358 assert((!thread->is_Java_thread() || ((JavaThread *)thread)->thread_state() == _thread_in_vm) |
1359 || rank() == Mutex::special, "wrong thread state for using locks"); |
1359 || rank() == Mutex::special, "wrong thread state for using locks"); |
1360 if (thread->is_VM_thread() && !allow_vm_block()) { |
1360 if (thread->is_VM_thread() && !allow_vm_block()) { |
1361 fatal("VM thread using lock %s (not allowed to block on)", name()); |
1361 fatal("VM thread using lock %s (not allowed to block on)", name()); |
1362 } |
1362 } |
1363 debug_only(if (rank() != Mutex::special) \ |
1363 DEBUG_ONLY(if (rank() != Mutex::special) \ |
1364 thread->check_for_valid_safepoint_state(false);) |
1364 thread->check_for_valid_safepoint_state(false);) |
1365 } |
1365 } |
1366 assert(!os::ThreadCrashProtection::is_crash_protected(thread), |
1366 assert(!os::ThreadCrashProtection::is_crash_protected(thread), |
1367 "locking not allowed when crash protection is set"); |
1367 "locking not allowed when crash protection is set"); |
1368 } |
1368 } |