< prev index next >

src/share/vm/runtime/synchronizer.cpp

Print this page




1685   GVars.stwCycle++;
1686 }
1687 
1688 // Monitor cleanup on JavaThread::exit
1689 
1690 // Iterate through monitor cache and attempt to release thread's monitors
1691 // Gives up on a particular monitor if an exception occurs, but continues
1692 // the overall iteration, swallowing the exception.
1693 class ReleaseJavaMonitorsClosure: public MonitorClosure {
1694  private:
1695   TRAPS;
1696 
1697  public:
1698   ReleaseJavaMonitorsClosure(Thread* thread) : THREAD(thread) {}
1699   void do_monitor(ObjectMonitor* mid) {
1700     if (mid->owner() == THREAD) {
1701       if (ObjectMonitor::Knob_VerifyMatch != 0) {
1702         Handle obj((oop) mid->object());
1703         tty->print("INFO: unexpected locked object:");
1704         javaVFrame::print_locked_object_class_name(tty, obj, "locked");
1705         fatal(err_msg("exiting JavaThread=" INTPTR_FORMAT
1706                       " unexpectedly owns ObjectMonitor=" INTPTR_FORMAT,
1707                       THREAD, mid));
1708       }
1709       (void)mid->complete_exit(CHECK);
1710     }
1711   }
1712 };
1713 
1714 // Release all inflated monitors owned by THREAD.  Lightweight monitors are
1715 // ignored.  This is meant to be called during JNI thread detach which assumes
1716 // all remaining monitors are heavyweight.  All exceptions are swallowed.
1717 // Scanning the extant monitor list can be time consuming.
1718 // A simple optimization is to add a per-thread flag that indicates a thread
1719 // called jni_monitorenter() during its lifetime.
1720 //
1721 // Instead of No_Savepoint_Verifier it might be cheaper to
1722 // use an idiom of the form:
1723 //   auto int tmp = SafepointSynchronize::_safepoint_counter ;
1724 //   <code that must not run at safepoint>
1725 //   guarantee (((tmp ^ _safepoint_counter) | (tmp & 1)) == 0) ;
1726 // Since the tests are extremely cheap we could leave them enabled
1727 // for normal product builds.




1685   GVars.stwCycle++;
1686 }
1687 
1688 // Monitor cleanup on JavaThread::exit
1689 
1690 // Iterate through monitor cache and attempt to release thread's monitors
1691 // Gives up on a particular monitor if an exception occurs, but continues
1692 // the overall iteration, swallowing the exception.
1693 class ReleaseJavaMonitorsClosure: public MonitorClosure {
1694  private:
1695   TRAPS;
1696 
1697  public:
1698   ReleaseJavaMonitorsClosure(Thread* thread) : THREAD(thread) {}
1699   void do_monitor(ObjectMonitor* mid) {
1700     if (mid->owner() == THREAD) {
1701       if (ObjectMonitor::Knob_VerifyMatch != 0) {
1702         Handle obj((oop) mid->object());
1703         tty->print("INFO: unexpected locked object:");
1704         javaVFrame::print_locked_object_class_name(tty, obj, "locked");
1705         fatal("exiting JavaThread=" INTPTR_FORMAT
1706               " unexpectedly owns ObjectMonitor=" INTPTR_FORMAT,
1707               THREAD, mid);
1708       }
1709       (void)mid->complete_exit(CHECK);
1710     }
1711   }
1712 };
1713 
1714 // Release all inflated monitors owned by THREAD.  Lightweight monitors are
1715 // ignored.  This is meant to be called during JNI thread detach which assumes
1716 // all remaining monitors are heavyweight.  All exceptions are swallowed.
1717 // Scanning the extant monitor list can be time consuming.
1718 // A simple optimization is to add a per-thread flag that indicates a thread
1719 // called jni_monitorenter() during its lifetime.
1720 //
1721 // Instead of No_Savepoint_Verifier it might be cheaper to
1722 // use an idiom of the form:
1723 //   auto int tmp = SafepointSynchronize::_safepoint_counter ;
1724 //   <code that must not run at safepoint>
1725 //   guarantee (((tmp ^ _safepoint_counter) | (tmp & 1)) == 0) ;
1726 // Since the tests are extremely cheap we could leave them enabled
1727 // for normal product builds.


< prev index next >