2082 // the caller has verified mark->has_monitor() == true. The object
2083 // parameter is needed to verify that ObjectMonitor* has not been
2084 // deflated and reused for another object.
2085 //
2086 // This function returns true if the ObjectMonitor* has been safely
2087 // saved. This function returns false if we have lost a race with
2088 // async deflation; the caller should retry as appropriate.
2089 //
2090 bool ObjectMonitorHandle::save_om_ptr(oop object, markOop mark) {
2091 guarantee(mark->has_monitor(), "sanity check: mark=" INTPTR_FORMAT,
2092 p2i(mark));
2093
2094 ObjectMonitor * om_ptr = mark->monitor();
2095 om_ptr->inc_ref_count();
2096
2097 if (AsyncDeflateIdleMonitors) {
2098 // Race here if monitor is not owned! The above ref_count bump
2099 // will cause subsequent async deflation to skip it. However,
2100 // previous or concurrent async deflation is a race.
2101 if (om_ptr->_owner == DEFLATER_MARKER && om_ptr->_contentions <= 0) {
2102 // Async deflation is in progress. Attempt to restore the
2103 // header/dmw to the object's header so that we only retry once
2104 // if the deflater thread happens to be slow.
2105 om_ptr->install_displaced_markword_in_object(object);
2106 om_ptr->dec_ref_count();
2107 return false;
2108 }
2109 // The ObjectMonitor could have been deflated and reused for
2110 // another object before we bumped the ref_count so make sure
2111 // our object still refers to this ObjectMonitor.
2112 const markOop tmp = object->mark();
2113 if (!tmp->has_monitor() || tmp->monitor() != om_ptr) {
2114 // Async deflation and reuse won the race so we have to retry.
2115 // Skip object header restoration since that's already done.
2116 om_ptr->dec_ref_count();
2117 return false;
2118 }
2119 }
2120
2121 guarantee(_om_ptr == NULL, "sanity check: _om_ptr=" INTPTR_FORMAT,
2122 p2i(_om_ptr));
2123 _om_ptr = om_ptr;
2124 return true;
2125 }
2126
2127 // For internal use by ObjectSynchronizer::inflate().
|
2082 // the caller has verified mark->has_monitor() == true. The object
2083 // parameter is needed to verify that ObjectMonitor* has not been
2084 // deflated and reused for another object.
2085 //
2086 // This function returns true if the ObjectMonitor* has been safely
2087 // saved. This function returns false if we have lost a race with
2088 // async deflation; the caller should retry as appropriate.
2089 //
2090 bool ObjectMonitorHandle::save_om_ptr(oop object, markOop mark) {
2091 guarantee(mark->has_monitor(), "sanity check: mark=" INTPTR_FORMAT,
2092 p2i(mark));
2093
2094 ObjectMonitor * om_ptr = mark->monitor();
2095 om_ptr->inc_ref_count();
2096
2097 if (AsyncDeflateIdleMonitors) {
2098 // Race here if monitor is not owned! The above ref_count bump
2099 // will cause subsequent async deflation to skip it. However,
2100 // previous or concurrent async deflation is a race.
2101 if (om_ptr->_owner == DEFLATER_MARKER && om_ptr->_contentions <= 0) {
2102 // Async deflation is in progress.
2103 if (om_ptr->ref_count() <= 0) {
2104 // And our ref_count increment above lost the race to async
2105 // deflation. Attempt to restore the header/dmw to the
2106 // object's header so that we only retry once if the deflater
2107 // thread happens to be slow.
2108 om_ptr->install_displaced_markword_in_object(object);
2109 om_ptr->dec_ref_count();
2110 return false;
2111 }
2112 }
2113 // The ObjectMonitor could have been deflated and reused for
2114 // another object before we bumped the ref_count so make sure
2115 // our object still refers to this ObjectMonitor.
2116 const markOop tmp = object->mark();
2117 if (!tmp->has_monitor() || tmp->monitor() != om_ptr) {
2118 // Async deflation and reuse won the race so we have to retry.
2119 // Skip object header restoration since that's already done.
2120 om_ptr->dec_ref_count();
2121 return false;
2122 }
2123 }
2124
2125 guarantee(_om_ptr == NULL, "sanity check: _om_ptr=" INTPTR_FORMAT,
2126 p2i(_om_ptr));
2127 _om_ptr = om_ptr;
2128 return true;
2129 }
2130
2131 // For internal use by ObjectSynchronizer::inflate().
|