hotspot/src/share/vm/runtime/synchronizer.cpp
changeset 31782 b23b74f8ae8d
parent 31345 1bba15125d8d
child 31856 614d6786ba55
equal deleted inserted replaced
31781:6bc2497120a9 31782:b23b74f8ae8d
    38 #include "runtime/objectMonitor.inline.hpp"
    38 #include "runtime/objectMonitor.inline.hpp"
    39 #include "runtime/osThread.hpp"
    39 #include "runtime/osThread.hpp"
    40 #include "runtime/stubRoutines.hpp"
    40 #include "runtime/stubRoutines.hpp"
    41 #include "runtime/synchronizer.hpp"
    41 #include "runtime/synchronizer.hpp"
    42 #include "runtime/thread.inline.hpp"
    42 #include "runtime/thread.inline.hpp"
       
    43 #include "runtime/vframe.hpp"
    43 #include "utilities/dtrace.hpp"
    44 #include "utilities/dtrace.hpp"
    44 #include "utilities/events.hpp"
    45 #include "utilities/events.hpp"
    45 #include "utilities/preserveException.hpp"
    46 #include "utilities/preserveException.hpp"
    46 
    47 
    47 #if defined(__GNUC__) && !defined(PPC64)
    48 #if defined(__GNUC__) && !defined(PPC64)
   925   // of active monitors passes the specified threshold.
   926   // of active monitors passes the specified threshold.
   926   // TODO: assert thread state is reasonable
   927   // TODO: assert thread state is reasonable
   927 
   928 
   928   if (ForceMonitorScavenge == 0 && Atomic::xchg (1, &ForceMonitorScavenge) == 0) {
   929   if (ForceMonitorScavenge == 0 && Atomic::xchg (1, &ForceMonitorScavenge) == 0) {
   929     if (ObjectMonitor::Knob_Verbose) {
   930     if (ObjectMonitor::Knob_Verbose) {
   930       ::printf ("Monitor scavenge - Induced STW @%s (%d)\n", Whence, ForceMonitorScavenge) ;
   931       tty->print_cr("INFO: Monitor scavenge - Induced STW @%s (%d)",
   931       ::fflush(stdout);
   932                     Whence, ForceMonitorScavenge) ;
       
   933       tty->flush();
   932     }
   934     }
   933     // Induce a 'null' safepoint to scavenge monitors
   935     // Induce a 'null' safepoint to scavenge monitors
   934     // Must VM_Operation instance be heap allocated as the op will be enqueue and posted
   936     // Must VM_Operation instance be heap allocated as the op will be enqueue and posted
   935     // to the VMthread and have a lifespan longer than that of this activation record.
   937     // to the VMthread and have a lifespan longer than that of this activation record.
   936     // The VMThread will delete the op when completed.
   938     // The VMThread will delete the op when completed.
   937     VMThread::execute(new VM_ForceAsyncSafepoint());
   939     VMThread::execute(new VM_ForceAsyncSafepoint());
   938 
   940 
   939     if (ObjectMonitor::Knob_Verbose) {
   941     if (ObjectMonitor::Knob_Verbose) {
   940       ::printf ("Monitor scavenge - STW posted @%s (%d)\n", Whence, ForceMonitorScavenge) ;
   942       tty->print_cr("INFO: Monitor scavenge - STW posted @%s (%d)",
   941       ::fflush(stdout);
   943                     Whence, ForceMonitorScavenge) ;
       
   944       tty->flush();
   942     }
   945     }
   943   }
   946   }
   944 }
   947 }
   945 
   948 
   946 void ObjectSynchronizer::verifyInUse(Thread *Self) {
   949 void ObjectSynchronizer::verifyInUse(Thread *Self) {
  1601   gMonitorFreeCount += nScavenged;
  1604   gMonitorFreeCount += nScavenged;
  1602 
  1605 
  1603   // Consider: audit gFreeList to ensure that gMonitorFreeCount and list agree.
  1606   // Consider: audit gFreeList to ensure that gMonitorFreeCount and list agree.
  1604 
  1607 
  1605   if (ObjectMonitor::Knob_Verbose) {
  1608   if (ObjectMonitor::Knob_Verbose) {
  1606     ::printf("Deflate: InCirc=%d InUse=%d Scavenged=%d ForceMonitorScavenge=%d : pop=%d free=%d\n",
  1609     tty->print_cr("INFO: Deflate: InCirc=%d InUse=%d Scavenged=%d "
  1607              nInCirculation, nInuse, nScavenged, ForceMonitorScavenge,
  1610                   "ForceMonitorScavenge=%d : pop=%d free=%d",
  1608              gMonitorPopulation, gMonitorFreeCount);
  1611                   nInCirculation, nInuse, nScavenged, ForceMonitorScavenge,
  1609     ::fflush(stdout);
  1612                   gMonitorPopulation, gMonitorFreeCount);
       
  1613     tty->flush();
  1610   }
  1614   }
  1611 
  1615 
  1612   ForceMonitorScavenge = 0;    // Reset
  1616   ForceMonitorScavenge = 0;    // Reset
  1613 
  1617 
  1614   // Move the scavenged monitors back to the global free list.
  1618   // Move the scavenged monitors back to the global free list.
  1641 
  1645 
  1642  public:
  1646  public:
  1643   ReleaseJavaMonitorsClosure(Thread* thread) : THREAD(thread) {}
  1647   ReleaseJavaMonitorsClosure(Thread* thread) : THREAD(thread) {}
  1644   void do_monitor(ObjectMonitor* mid) {
  1648   void do_monitor(ObjectMonitor* mid) {
  1645     if (mid->owner() == THREAD) {
  1649     if (mid->owner() == THREAD) {
       
  1650       if (ObjectMonitor::Knob_VerifyMatch != 0) {
       
  1651         Handle obj((oop) mid->object());
       
  1652         tty->print("INFO: unexpected locked object:");
       
  1653         javaVFrame::print_locked_object_class_name(tty, obj, "locked");
       
  1654         fatal(err_msg("exiting JavaThread=" INTPTR_FORMAT
       
  1655                       " unexpectedly owns ObjectMonitor=" INTPTR_FORMAT,
       
  1656                       THREAD, mid));
       
  1657       }
  1646       (void)mid->complete_exit(CHECK);
  1658       (void)mid->complete_exit(CHECK);
  1647     }
  1659     }
  1648   }
  1660   }
  1649 };
  1661 };
  1650 
  1662