hotspot/src/share/vm/runtime/objectMonitor.cpp
changeset 32614 b7b2407bc7e5
parent 31856 614d6786ba55
child 32622 7ed47d0b888a
equal deleted inserted replaced
32613:73bec9f941d7 32614:b7b2407bc7e5
   403     event.set_previousOwner((TYPE_JAVALANGTHREAD)_previous_owner_tid);
   403     event.set_previousOwner((TYPE_JAVALANGTHREAD)_previous_owner_tid);
   404     event.set_address((TYPE_ADDRESS)(uintptr_t)(this->object_addr()));
   404     event.set_address((TYPE_ADDRESS)(uintptr_t)(this->object_addr()));
   405     event.commit();
   405     event.commit();
   406   }
   406   }
   407 
   407 
   408   if (ObjectMonitor::_sync_ContendedLockAttempts != NULL) {
   408   OM_PERFDATA_OP(ContendedLockAttempts, inc());
   409     ObjectMonitor::_sync_ContendedLockAttempts->inc();
       
   410   }
       
   411 }
   409 }
   412 
   410 
   413 
   411 
   414 // Caveat: TryLock() is not necessarily serializing if it returns failure.
   412 // Caveat: TryLock() is not necessarily serializing if it returns failure.
   415 // Callers must compensate as needed.
   413 // Callers must compensate as needed.
   572     // Keep a tally of the # of futile wakeups.
   570     // Keep a tally of the # of futile wakeups.
   573     // Note that the counter is not protected by a lock or updated by atomics.
   571     // Note that the counter is not protected by a lock or updated by atomics.
   574     // That is by design - we trade "lossy" counters which are exposed to
   572     // That is by design - we trade "lossy" counters which are exposed to
   575     // races during updates for a lower probe effect.
   573     // races during updates for a lower probe effect.
   576     TEVENT(Inflated enter - Futile wakeup);
   574     TEVENT(Inflated enter - Futile wakeup);
   577     if (ObjectMonitor::_sync_FutileWakeups != NULL) {
   575     // This PerfData object can be used in parallel with a safepoint.
   578       ObjectMonitor::_sync_FutileWakeups->inc();
   576     // See the work around in PerfDataManager::destroy().
   579     }
   577     OM_PERFDATA_OP(FutileWakeups, inc());
   580     ++nWakeups;
   578     ++nWakeups;
   581 
   579 
   582     // Assuming this is not a spurious wakeup we'll normally find _succ == Self.
   580     // Assuming this is not a spurious wakeup we'll normally find _succ == Self.
   583     // We can defer clearing _succ until after the spin completes
   581     // We can defer clearing _succ until after the spin completes
   584     // TrySpin() must tolerate being called with _succ == Self.
   582     // TrySpin() must tolerate being called with _succ == Self.
   746 
   744 
   747     // Invariant: after clearing _succ a contending thread
   745     // Invariant: after clearing _succ a contending thread
   748     // *must* retry  _owner before parking.
   746     // *must* retry  _owner before parking.
   749     OrderAccess::fence();
   747     OrderAccess::fence();
   750 
   748 
   751     if (ObjectMonitor::_sync_FutileWakeups != NULL) {
   749     // This PerfData object can be used in parallel with a safepoint.
   752       ObjectMonitor::_sync_FutileWakeups->inc();
   750     // See the work around in PerfDataManager::destroy().
   753     }
   751     OM_PERFDATA_OP(FutileWakeups, inc());
   754   }
   752   }
   755 
   753 
   756   // Self has acquired the lock -- Unlink Self from the cxq or EntryList .
   754   // Self has acquired the lock -- Unlink Self from the cxq or EntryList .
   757   // Normally we'll find Self on the EntryList.
   755   // Normally we'll find Self on the EntryList.
   758   // Unlinking from the EntryList is constant-time and atomic-free.
   756   // Unlinking from the EntryList is constant-time and atomic-free.
  1300 
  1298 
  1301   DTRACE_MONITOR_PROBE(contended__exit, this, object(), Self);
  1299   DTRACE_MONITOR_PROBE(contended__exit, this, object(), Self);
  1302   Trigger->unpark();
  1300   Trigger->unpark();
  1303 
  1301 
  1304   // Maintain stats and report events to JVMTI
  1302   // Maintain stats and report events to JVMTI
  1305   if (ObjectMonitor::_sync_Parks != NULL) {
  1303   OM_PERFDATA_OP(Parks, inc());
  1306     ObjectMonitor::_sync_Parks->inc();
       
  1307   }
       
  1308 }
  1304 }
  1309 
  1305 
  1310 
  1306 
  1311 // -----------------------------------------------------------------------------
  1307 // -----------------------------------------------------------------------------
  1312 // Class Loader deadlock handling.
  1308 // Class Loader deadlock handling.
  1763     TEVENT(Empty-Notify);
  1759     TEVENT(Empty-Notify);
  1764     return;
  1760     return;
  1765   }
  1761   }
  1766   DTRACE_MONITOR_PROBE(notify, this, object(), THREAD);
  1762   DTRACE_MONITOR_PROBE(notify, this, object(), THREAD);
  1767   INotify(THREAD);
  1763   INotify(THREAD);
  1768   if (ObjectMonitor::_sync_Notifications != NULL) {
  1764   OM_PERFDATA_OP(Notifications, inc(1));
  1769     ObjectMonitor::_sync_Notifications->inc(1);
       
  1770   }
       
  1771 }
  1765 }
  1772 
  1766 
  1773 
  1767 
  1774 // The current implementation of notifyAll() transfers the waiters one-at-a-time
  1768 // The current implementation of notifyAll() transfers the waiters one-at-a-time
  1775 // from the waitset to the EntryList. This could be done more efficiently with a
  1769 // from the waitset to the EntryList. This could be done more efficiently with a
  1790   while (_WaitSet != NULL) {
  1784   while (_WaitSet != NULL) {
  1791     tally++;
  1785     tally++;
  1792     INotify(THREAD);
  1786     INotify(THREAD);
  1793   }
  1787   }
  1794 
  1788 
  1795   if (tally != 0 && ObjectMonitor::_sync_Notifications != NULL) {
  1789   OM_PERFDATA_OP(Notifications, inc(tally));
  1796     ObjectMonitor::_sync_Notifications->inc(tally);
       
  1797   }
       
  1798 }
  1790 }
  1799 
  1791 
  1800 // -----------------------------------------------------------------------------
  1792 // -----------------------------------------------------------------------------
  1801 // Adaptive Spinning Support
  1793 // Adaptive Spinning Support
  1802 //
  1794 //