< prev index next >

src/hotspot/share/runtime/objectMonitor.cpp

Print this page
rev 56046 : v2.00 -> v2.05 (CR5/v2.05/8-for-jdk13) patches combined into one; merge with 8229212.patch; merge with jdk-14+11; merge with 8230184.patch.
rev 56048 : Add OM_CACHE_LINE_SIZE so that ObjectMonitor cache line sizes can be experimented with independently of DEFAULT_CACHE_LINE_SIZE; for SPARC and X64 configs that use 128 for DEFAULT_CACHE_LINE_SIZE, we are experimenting with 64; move _previous_owner_tid and _allocation_state fields to share the cache line with ObjectMonitor::_header; put ObjectMonitor::_ref_count on its own cache line after _owner; add 'int* count_p' parameter to deflate_monitor_list() and deflate_monitor_list_using_JT() and push counter updates down to where the ObjectMonitors are actually removed from the in-use lists; monitors_iterate() async deflation check should use negative ref_count; add 'JavaThread* target' param to deflate_per_thread_idle_monitors_using_JT() add deflate_common_idle_monitors_using_JT() to make it clear which JavaThread* is the target of the work and which is the calling JavaThread* (self); g_free_list, g_om_in_use_list and g_om_in_use_count are now static to synchronizer.cpp (reduce scope); add more diagnostic info to some assert()'s; minor code cleanups and code motion; save_om_ptr() should detect a race with a deflating thread that is bailing out and cause a retry when the ref_count field is not positive; merge with jdk-14+11; add special GC support for TestHumongousClassLoader.java; merge with 8230184.patch.


2094 bool ObjectMonitorHandle::save_om_ptr(oop object, markWord mark) {
2095   guarantee(mark.has_monitor(), "sanity check: mark=" INTPTR_FORMAT,
2096             mark.value());
2097 
2098   ObjectMonitor * om_ptr = mark.monitor();
2099   om_ptr->inc_ref_count();
2100 
2101   if (AsyncDeflateIdleMonitors) {
2102     // Race here if monitor is not owned! The above ref_count bump
2103     // will cause subsequent async deflation to skip it. However,
2104     // previous or concurrent async deflation is a race.
2105     if (om_ptr->owner_is_DEFLATER_MARKER() && om_ptr->ref_count() <= 0) {
2106       // Async deflation is in progress and our ref_count increment
2107       // above lost the race to async deflation. Attempt to restore
2108       // the header/dmw to the object's header so that we only retry
2109       // once if the deflater thread happens to be slow.
2110       om_ptr->install_displaced_markword_in_object(object);
2111       om_ptr->dec_ref_count();
2112       return false;
2113     }







2114     // The ObjectMonitor could have been deflated and reused for
2115     // another object before we bumped the ref_count so make sure
2116     // our object still refers to this ObjectMonitor.
2117     const markWord tmp = object->mark();
2118     if (!tmp.has_monitor() || tmp.monitor() != om_ptr) {
2119       // Async deflation and reuse won the race so we have to retry.
2120       // Skip object header restoration since that's already done.
2121       om_ptr->dec_ref_count();
2122       return false;
2123     }
2124   }
2125 
2126   ADIM_guarantee(_om_ptr == NULL, "sanity check: _om_ptr=" INTPTR_FORMAT,
2127                  p2i(_om_ptr));
2128   _om_ptr = om_ptr;
2129   return true;
2130 }
2131 
2132 // For internal use by ObjectSynchronizer::inflate().
2133 void ObjectMonitorHandle::set_om_ptr(ObjectMonitor * om_ptr) {


2094 bool ObjectMonitorHandle::save_om_ptr(oop object, markWord mark) {
2095   guarantee(mark.has_monitor(), "sanity check: mark=" INTPTR_FORMAT,
2096             mark.value());
2097 
2098   ObjectMonitor * om_ptr = mark.monitor();
2099   om_ptr->inc_ref_count();
2100 
2101   if (AsyncDeflateIdleMonitors) {
2102     // Race here if monitor is not owned! The above ref_count bump
2103     // will cause subsequent async deflation to skip it. However,
2104     // previous or concurrent async deflation is a race.
2105     if (om_ptr->owner_is_DEFLATER_MARKER() && om_ptr->ref_count() <= 0) {
2106       // Async deflation is in progress and our ref_count increment
2107       // above lost the race to async deflation. Attempt to restore
2108       // the header/dmw to the object's header so that we only retry
2109       // once if the deflater thread happens to be slow.
2110       om_ptr->install_displaced_markword_in_object(object);
2111       om_ptr->dec_ref_count();
2112       return false;
2113     }
2114     if (om_ptr->ref_count() <= 0) {
2115       // Async deflation is in the process of bailing out, but has not
2116       // yet restored the ref_count field so we return false to force
2117       // a retry. We want a positive ref_count value for a true return.
2118       om_ptr->dec_ref_count();
2119       return false;
2120     }
2121     // The ObjectMonitor could have been deflated and reused for
2122     // another object before we bumped the ref_count so make sure
2123     // our object still refers to this ObjectMonitor.
2124     const markWord tmp = object->mark();
2125     if (!tmp.has_monitor() || tmp.monitor() != om_ptr) {
2126       // Async deflation and reuse won the race so we have to retry.
2127       // Skip object header restoration since that's already done.
2128       om_ptr->dec_ref_count();
2129       return false;
2130     }
2131   }
2132 
2133   ADIM_guarantee(_om_ptr == NULL, "sanity check: _om_ptr=" INTPTR_FORMAT,
2134                  p2i(_om_ptr));
2135   _om_ptr = om_ptr;
2136   return true;
2137 }
2138 
2139 // For internal use by ObjectSynchronizer::inflate().
2140 void ObjectMonitorHandle::set_om_ptr(ObjectMonitor * om_ptr) {
< prev index next >