Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: Finish updating wiki to match CR2/v2.02/5-for-jdk13.

...

RFE: 8153224 Monitor deflation prolong safepoints
         https://bugs.openjdk.java.net/browse/JDK-8153224

Full Webrev: http://cr.openjdk.java.net/~dcubed/8153224-webrev/45-for-jdk13.full/

Inc Webrev: http://cr.openjdk.java.net/~dcubed/8153224-webrev/45-for-jdk13.inc/

Background

This patch for Async Monitor Deflation is based on Carsten Varming's

...

ObjectMonitor::install_displaced_markword_in_object() is the new piece of code that handles all the racy situations with restoring an object's header asynchronously. The function is called from a couple few of places (deflation and , object monitor entry, and saving an ObjectMonitor* in an ObjectMonitorHandle). The restoration protocol for the object's header uses the mark bit along with the hash() value staying at zero to indicate that the object's header is being restored. Only one of the possible racing scenarios can win and the losing scenarios all adapt to the winning scenario's object header value.

...

If T-deflate wins the race, then T-hash will have to retry until the object and/or ObjectMonitor are stableat most once.

    T-hash                      ObjectMonitor              T-deflate
    -------------------------  +-----------------------+  -----------------------------------------------
    save_om_ptr() {           | owner=DEFLATER_MARKER |  deflate_monitor_using_JT() {
   1> atomic inc ref_count    | contentions=-max_jint |  cmpxchg(DEFLATER_MARKER, &owner, NULL)
   if (owner ==           | ref_count=0           |  if (waiters != 0 || ref_count != 0) {
          DEFLATER_MARKER &&  +-----------------------+  }
        contentions <= 0 &&             ||              prev = cmpxchg(-max_jint, &contentions, 0)
        ref_count <= 0) {            \/             1> if (prev == 0 &&
     restore obj header   +-----------------------+     owner == DEFLATER_MARKER &&
     atomic dec ref_count  | owner=DEFLATER_MARKER |    cmpxchg(-max_jint, &ref_count, 0) == 0) {
     2> return false to      | contentions=-max_jint |    restore obj header
cause a retry | ref_count=-max_jint | 2> finish the deflation
} +-----------------------+ }

...

In this T-hash wins scenario, the need for the "setting ref_count == 0" check to a large negative value in the third phase part of the protocol is illustrated.

...