src/hotspot/share/runtime/synchronizer.cpp
changeset 52703 e7fdc9d9c376
parent 52459 cbe83e9c2100
child 53557 4cfe0e5a3b79
equal deleted inserted replaced
52702:10c6e9066819 52703:e7fdc9d9c376
    43 #include "runtime/safepointVerifiers.hpp"
    43 #include "runtime/safepointVerifiers.hpp"
    44 #include "runtime/sharedRuntime.hpp"
    44 #include "runtime/sharedRuntime.hpp"
    45 #include "runtime/stubRoutines.hpp"
    45 #include "runtime/stubRoutines.hpp"
    46 #include "runtime/synchronizer.hpp"
    46 #include "runtime/synchronizer.hpp"
    47 #include "runtime/thread.inline.hpp"
    47 #include "runtime/thread.inline.hpp"
       
    48 #include "runtime/timer.hpp"
    48 #include "runtime/vframe.hpp"
    49 #include "runtime/vframe.hpp"
    49 #include "runtime/vmThread.hpp"
    50 #include "runtime/vmThread.hpp"
    50 #include "utilities/align.hpp"
    51 #include "utilities/align.hpp"
    51 #include "utilities/dtrace.hpp"
    52 #include "utilities/dtrace.hpp"
    52 #include "utilities/events.hpp"
    53 #include "utilities/events.hpp"
  1616   }
  1617   }
  1617   return deflated_count;
  1618   return deflated_count;
  1618 }
  1619 }
  1619 
  1620 
  1620 void ObjectSynchronizer::prepare_deflate_idle_monitors(DeflateMonitorCounters* counters) {
  1621 void ObjectSynchronizer::prepare_deflate_idle_monitors(DeflateMonitorCounters* counters) {
  1621   counters->nInuse = 0;          // currently associated with objects
  1622   counters->nInuse = 0;            // currently associated with objects
  1622   counters->nInCirculation = 0;  // extant
  1623   counters->nInCirculation = 0;    // extant
  1623   counters->nScavenged = 0;      // reclaimed
  1624   counters->nScavenged = 0;        // reclaimed
       
  1625   counters->perThreadTimes = 0.0;  // per-thread scavenge times
  1624 }
  1626 }
  1625 
  1627 
  1626 void ObjectSynchronizer::deflate_idle_monitors(DeflateMonitorCounters* counters) {
  1628 void ObjectSynchronizer::deflate_idle_monitors(DeflateMonitorCounters* counters) {
  1627   assert(SafepointSynchronize::is_at_safepoint(), "must be at safepoint");
  1629   assert(SafepointSynchronize::is_at_safepoint(), "must be at safepoint");
  1628   bool deflated = false;
  1630   bool deflated = false;
  1658   Thread::muxRelease(&gListLock);
  1660   Thread::muxRelease(&gListLock);
  1659 
  1661 
  1660 }
  1662 }
  1661 
  1663 
  1662 void ObjectSynchronizer::finish_deflate_idle_monitors(DeflateMonitorCounters* counters) {
  1664 void ObjectSynchronizer::finish_deflate_idle_monitors(DeflateMonitorCounters* counters) {
       
  1665   if (log_is_enabled(Info, safepoint, cleanup)) {
       
  1666     // Report the cumulative time for deflating each thread's idle
       
  1667     // monitors. Note: if the work is split among more than one
       
  1668     // worker thread, then the reported time will likely be more
       
  1669     // than a beginning to end measurement of the phase.
       
  1670     log_info(safepoint, cleanup)("deflating per-thread idle monitors, %3.7f secs", counters->perThreadTimes);
       
  1671   }
       
  1672 
  1663   gMonitorFreeCount += counters->nScavenged;
  1673   gMonitorFreeCount += counters->nScavenged;
  1664 
  1674 
  1665   // Consider: audit gFreeList to ensure that gMonitorFreeCount and list agree.
  1675   // Consider: audit gFreeList to ensure that gMonitorFreeCount and list agree.
  1666 
  1676 
  1667   ForceMonitorScavenge = 0;    // Reset
  1677   ForceMonitorScavenge = 0;    // Reset
  1678 void ObjectSynchronizer::deflate_thread_local_monitors(Thread* thread, DeflateMonitorCounters* counters) {
  1688 void ObjectSynchronizer::deflate_thread_local_monitors(Thread* thread, DeflateMonitorCounters* counters) {
  1679   assert(SafepointSynchronize::is_at_safepoint(), "must be at safepoint");
  1689   assert(SafepointSynchronize::is_at_safepoint(), "must be at safepoint");
  1680 
  1690 
  1681   ObjectMonitor * freeHeadp = NULL;  // Local SLL of scavenged monitors
  1691   ObjectMonitor * freeHeadp = NULL;  // Local SLL of scavenged monitors
  1682   ObjectMonitor * freeTailp = NULL;
  1692   ObjectMonitor * freeTailp = NULL;
       
  1693   elapsedTimer timer;
       
  1694 
       
  1695   if (log_is_enabled(Info, safepoint, cleanup)) {
       
  1696     timer.start();
       
  1697   }
  1683 
  1698 
  1684   int deflated_count = deflate_monitor_list(thread->omInUseList_addr(), &freeHeadp, &freeTailp);
  1699   int deflated_count = deflate_monitor_list(thread->omInUseList_addr(), &freeHeadp, &freeTailp);
       
  1700 
       
  1701   timer.stop();
  1685 
  1702 
  1686   Thread::muxAcquire(&gListLock, "scavenge - return");
  1703   Thread::muxAcquire(&gListLock, "scavenge - return");
  1687 
  1704 
  1688   // Adjust counters
  1705   // Adjust counters
  1689   counters->nInCirculation += thread->omInUseCount;
  1706   counters->nInCirculation += thread->omInUseCount;
  1690   thread->omInUseCount -= deflated_count;
  1707   thread->omInUseCount -= deflated_count;
  1691   counters->nScavenged += deflated_count;
  1708   counters->nScavenged += deflated_count;
  1692   counters->nInuse += thread->omInUseCount;
  1709   counters->nInuse += thread->omInUseCount;
       
  1710   // For now, we only care about cumulative per-thread deflation time.
       
  1711   counters->perThreadTimes += timer.seconds();
  1693 
  1712 
  1694   // Move the scavenged monitors back to the global free list.
  1713   // Move the scavenged monitors back to the global free list.
  1695   if (freeHeadp != NULL) {
  1714   if (freeHeadp != NULL) {
  1696     guarantee(freeTailp != NULL && deflated_count > 0, "invariant");
  1715     guarantee(freeTailp != NULL && deflated_count > 0, "invariant");
  1697     assert(freeTailp->FreeNext == NULL, "invariant");
  1716     assert(freeTailp->FreeNext == NULL, "invariant");