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) {
|