< prev index next >

src/hotspot/share/runtime/synchronizer.cpp

Print this page
rev 51786 : imported patch syncknobs-06-Knob_Verbose
rev 51787 : imported patch syncknobs-07-Knob_VerifyInUse
rev 51788 : imported patch syncknobs-08-Knob_VerifyMatch


1782     // constant-time list splice - prepend scavenged segment to gFreeList
1783     freeTailp->FreeNext = gFreeList;
1784     gFreeList = freeHeadp;
1785   }
1786   Thread::muxRelease(&gListLock);
1787 }
1788 
1789 // Monitor cleanup on JavaThread::exit
1790 
1791 // Iterate through monitor cache and attempt to release thread's monitors
1792 // Gives up on a particular monitor if an exception occurs, but continues
1793 // the overall iteration, swallowing the exception.
1794 class ReleaseJavaMonitorsClosure: public MonitorClosure {
1795  private:
1796   TRAPS;
1797 
1798  public:
1799   ReleaseJavaMonitorsClosure(Thread* thread) : THREAD(thread) {}
1800   void do_monitor(ObjectMonitor* mid) {
1801     if (mid->owner() == THREAD) {
1802       if (ObjectMonitor::Knob_VerifyMatch != 0) {
1803         ResourceMark rm;
1804         Handle obj(THREAD, (oop) mid->object());
1805         tty->print("INFO: unexpected locked object:");
1806         javaVFrame::print_locked_object_class_name(tty, obj, "locked");
1807         fatal("exiting JavaThread=" INTPTR_FORMAT
1808               " unexpectedly owns ObjectMonitor=" INTPTR_FORMAT,
1809               p2i(THREAD), p2i(mid));
1810       }
1811       (void)mid->complete_exit(CHECK);
1812     }
1813   }
1814 };
1815 
1816 // Release all inflated monitors owned by THREAD.  Lightweight monitors are
1817 // ignored.  This is meant to be called during JNI thread detach which assumes
1818 // all remaining monitors are heavyweight.  All exceptions are swallowed.
1819 // Scanning the extant monitor list can be time consuming.
1820 // A simple optimization is to add a per-thread flag that indicates a thread
1821 // called jni_monitorenter() during its lifetime.
1822 //
1823 // Instead of No_Savepoint_Verifier it might be cheaper to
1824 // use an idiom of the form:
1825 //   auto int tmp = SafepointSynchronize::_safepoint_counter ;
1826 //   <code that must not run at safepoint>
1827 //   guarantee (((tmp ^ _safepoint_counter) | (tmp & 1)) == 0) ;
1828 // Since the tests are extremely cheap we could leave them enabled
1829 // for normal product builds.
1830 




1782     // constant-time list splice - prepend scavenged segment to gFreeList
1783     freeTailp->FreeNext = gFreeList;
1784     gFreeList = freeHeadp;
1785   }
1786   Thread::muxRelease(&gListLock);
1787 }
1788 
1789 // Monitor cleanup on JavaThread::exit
1790 
1791 // Iterate through monitor cache and attempt to release thread's monitors
1792 // Gives up on a particular monitor if an exception occurs, but continues
1793 // the overall iteration, swallowing the exception.
1794 class ReleaseJavaMonitorsClosure: public MonitorClosure {
1795  private:
1796   TRAPS;
1797 
1798  public:
1799   ReleaseJavaMonitorsClosure(Thread* thread) : THREAD(thread) {}
1800   void do_monitor(ObjectMonitor* mid) {
1801     if (mid->owner() == THREAD) {









1802       (void)mid->complete_exit(CHECK);
1803     }
1804   }
1805 };
1806 
1807 // Release all inflated monitors owned by THREAD.  Lightweight monitors are
1808 // ignored.  This is meant to be called during JNI thread detach which assumes
1809 // all remaining monitors are heavyweight.  All exceptions are swallowed.
1810 // Scanning the extant monitor list can be time consuming.
1811 // A simple optimization is to add a per-thread flag that indicates a thread
1812 // called jni_monitorenter() during its lifetime.
1813 //
1814 // Instead of No_Savepoint_Verifier it might be cheaper to
1815 // use an idiom of the form:
1816 //   auto int tmp = SafepointSynchronize::_safepoint_counter ;
1817 //   <code that must not run at safepoint>
1818 //   guarantee (((tmp ^ _safepoint_counter) | (tmp & 1)) == 0) ;
1819 // Since the tests are extremely cheap we could leave them enabled
1820 // for normal product builds.
1821 


< prev index next >