< prev index next >

src/hotspot/share/runtime/basicLock.cpp

Print this page
@@ -22,20 +22,29 @@
   *
   */
  
  #include "precompiled.hpp"
  #include "oops/oop.inline.hpp"
- #include "runtime/basicLock.hpp"
+ #include "runtime/basicLock.inline.hpp"
+ #include "runtime/objectMonitor.hpp"
  #include "runtime/synchronizer.hpp"
+ #include "utilities/globalDefinitions.hpp"
  
  void BasicLock::print_on(outputStream* st, oop owner) const {
    st->print("monitor");
-   markWord mark_word = displaced_header();
-   if (mark_word.value() != 0) {
-     // Print monitor info if there's an owning oop and it refers to this BasicLock.
-     bool print_monitor_info = (owner != nullptr) && (owner->mark() == markWord::from_pointer((void*)this));
-     mark_word.print_on(st, print_monitor_info);
+   if (LockingMode == LM_LIGHTWEIGHT) {
+     ObjectMonitor* mon = object_monitor_cache();
+     if (mon != nullptr) {
+       mon->print_on(st);
+     }
+   } else {
+     markWord mark_word = displaced_header();
+     if (mark_word.value() != 0) {
+       // Print monitor info if there's an owning oop and it refers to this BasicLock.
+       bool print_monitor_info = (owner != nullptr) && (owner->mark() == markWord::from_pointer((void*)this));
+       mark_word.print_on(st, print_monitor_info);
+     }
    }
  }
  
  void BasicLock::move_to(oop obj, BasicLock* dest) {
    // Check to see if we need to inflate the lock. This is only needed

@@ -80,12 +89,17 @@
        // value is either 0, neutral, or 3.  But with the advent of the
        // store-before-CAS avoidance in fast_lock/compiler_lock_object
        // we can find any flavor mark in the displaced mark.
      }
      dest->set_displaced_header(displaced_header());
+   } else if (LockingMode == LM_LIGHTWEIGHT) {
+     // Preserve the ObjectMonitor*, the cache is cleared when a box is reused
+     // and only read while the lock is held, so no stale ObjectMonitor* is
+     // encountered.
+     dest->set_object_monitor_cache(object_monitor_cache());
    }
  #ifdef ASSERT
    else {
-     dest->set_displaced_header(markWord(badDispHeaderDeopt));
+     dest->set_bad_metadata_deopt();
    }
  #endif
  }
< prev index next >