< prev index next >

src/hotspot/share/runtime/objectMonitor.cpp

Print this page
*** 332,11 ***
      // TODO-FIXME: check for integer overflow!  BUGID 6557169.
      _recursions++;
      return true;
    }
  
!   if (current->is_lock_owned((address)cur)) {
      assert(_recursions == 0, "internal state error");
      _recursions = 1;
      set_owner_from_BasicLock(cur, current);  // Convert from BasicLock* to Thread*.
      return true;
    }
--- 332,11 ---
      // TODO-FIXME: check for integer overflow!  BUGID 6557169.
      _recursions++;
      return true;
    }
  
!   if (LockingMode != LM_LIGHTWEIGHT && current->is_lock_owned((address)cur)) {
      assert(_recursions == 0, "internal state error");
      _recursions = 1;
      set_owner_from_BasicLock(cur, current);  // Convert from BasicLock* to Thread*.
      return true;
    }

*** 598,10 ***
--- 598,26 ---
    // We leave owner == DEFLATER_MARKER and contentions < 0
    // to force any racing threads to retry.
    return true;  // Success, ObjectMonitor has been deflated.
  }
  
+ // We might access the dead object headers for parsable heap walk, make sure
+ // headers are in correct shape, e.g. monitors deflated.
+ void ObjectMonitor::maybe_deflate_dead(oop* p) {
+   oop obj = *p;
+   assert(obj != NULL, "must not yet been cleared");
+   markWord mark = obj->mark();
+   if (mark.has_monitor()) {
+     ObjectMonitor* monitor = mark.monitor();
+     if (p == monitor->_object.ptr_raw()) {
+       assert(monitor->object_peek() == obj, "lock object must match");
+       markWord dmw = monitor->header();
+       obj->set_mark(dmw);
+     }
+   }
+ }
+ 
  // Install the displaced mark word (dmw) of a deflating ObjectMonitor
  // into the header of the object associated with the monitor. This
  // idempotent method is called by a thread that is deflating a
  // monitor and by other threads that have detected a race with the
  // deflation process.

*** 1133,11 ***
  // of such futile wakups is low.
  
  void ObjectMonitor::exit(JavaThread* current, bool not_suspended) {
    void* cur = owner_raw();
    if (current != cur) {
!     if (current->is_lock_owned((address)cur)) {
        assert(_recursions == 0, "invariant");
        set_owner_from_BasicLock(cur, current);  // Convert from BasicLock* to Thread*.
        _recursions = 0;
      } else {
        // Apparent unbalanced locking ...
--- 1149,11 ---
  // of such futile wakups is low.
  
  void ObjectMonitor::exit(JavaThread* current, bool not_suspended) {
    void* cur = owner_raw();
    if (current != cur) {
!     if (LockingMode != LM_LIGHTWEIGHT && current->is_lock_owned((address)cur)) {
        assert(_recursions == 0, "invariant");
        set_owner_from_BasicLock(cur, current);  // Convert from BasicLock* to Thread*.
        _recursions = 0;
      } else {
        // Apparent unbalanced locking ...

*** 1353,11 ***
  intx ObjectMonitor::complete_exit(JavaThread* current) {
    assert(InitDone, "Unexpectedly not initialized");
  
    void* cur = owner_raw();
    if (current != cur) {
!     if (current->is_lock_owned((address)cur)) {
        assert(_recursions == 0, "internal state error");
        set_owner_from_BasicLock(cur, current);  // Convert from BasicLock* to Thread*.
        _recursions = 0;
      }
    }
--- 1369,11 ---
  intx ObjectMonitor::complete_exit(JavaThread* current) {
    assert(InitDone, "Unexpectedly not initialized");
  
    void* cur = owner_raw();
    if (current != cur) {
!     if (LockingMode != LM_LIGHTWEIGHT && current->is_lock_owned((address)cur)) {
        assert(_recursions == 0, "internal state error");
        set_owner_from_BasicLock(cur, current);  // Convert from BasicLock* to Thread*.
        _recursions = 0;
      }
    }

*** 1402,14 ***
  // (IMSE). If there is a pending exception and the specified thread
  // is not the owner, that exception will be replaced by the IMSE.
  bool ObjectMonitor::check_owner(TRAPS) {
    JavaThread* current = THREAD;
    void* cur = owner_raw();
    if (cur == current) {
      return true;
    }
!   if (current->is_lock_owned((address)cur)) {
      set_owner_from_BasicLock(cur, current);  // Convert from BasicLock* to Thread*.
      _recursions = 0;
      return true;
    }
    THROW_MSG_(vmSymbols::java_lang_IllegalMonitorStateException(),
--- 1418,15 ---
  // (IMSE). If there is a pending exception and the specified thread
  // is not the owner, that exception will be replaced by the IMSE.
  bool ObjectMonitor::check_owner(TRAPS) {
    JavaThread* current = THREAD;
    void* cur = owner_raw();
+   assert(cur != anon_owner_ptr(), "no anon owner here");
    if (cur == current) {
      return true;
    }
!   if (LockingMode != LM_LIGHTWEIGHT && current->is_lock_owned((address)cur)) {
      set_owner_from_BasicLock(cur, current);  // Convert from BasicLock* to Thread*.
      _recursions = 0;
      return true;
    }
    THROW_MSG_(vmSymbols::java_lang_IllegalMonitorStateException(),
< prev index next >