< prev index next >

src/hotspot/cpu/x86/c1_MacroAssembler_x86.cpp

Print this page
@@ -46,10 +46,11 @@
    const int aligned_mask = BytesPerWord -1;
    const int hdr_offset = oopDesc::mark_offset_in_bytes();
    assert(hdr == rax, "hdr must be rax, for the cmpxchg instruction");
    assert_different_registers(hdr, obj, disp_hdr, tmp);
    int null_check_offset = -1;
+   Label count_locking, done;
  
    verify_oop(obj);
  
    // save object being locked into the BasicObjectLock
    movptr(Address(disp_hdr, BasicObjectLock::obj_offset()), obj);

@@ -70,11 +71,10 @@
      const Register thread = disp_hdr;
      get_thread(thread);
  #endif
      lightweight_lock(obj, hdr, thread, tmp, slow_case);
    } else  if (LockingMode == LM_LEGACY) {
-     Label done;
      // Load object header
      movptr(hdr, Address(obj, hdr_offset));
      // and mark it as unlocked
      orptr(hdr, markWord::unlocked_value);
      // save unlocked object header into the displaced header location on the stack

@@ -83,11 +83,11 @@
      // displaced header address in the object header - if it is not the same, get the
      // object header instead
      MacroAssembler::lock(); // must be immediately before cmpxchg!
      cmpxchgptr(disp_hdr, Address(obj, hdr_offset));
      // if the object header was the same, we're done
-     jcc(Assembler::equal, done);
+     jcc(Assembler::equal, count_locking);
      // if the object header was not the same, it is now in the hdr register
      // => test if it is a stack pointer into the same stack (recursive locking), i.e.:
      //
      // 1) (hdr & aligned_mask) == 0
      // 2) rsp <= hdr

@@ -105,14 +105,16 @@
      // location (null in the displaced hdr location indicates recursive locking)
      movptr(Address(disp_hdr, 0), hdr);
      // otherwise we don't care about the result and handle locking via runtime call
      jcc(Assembler::notZero, slow_case);
      // done
-     bind(done);
    }
+   jmp(done);
  
+   bind(count_locking);
    inc_held_monitor_count();
+   bind(done);
  
    return null_check_offset;
  }
  
  void C1_MacroAssembler::unlock_object(Register hdr, Register obj, Register disp_hdr, Label& slow_case) {

@@ -151,14 +153,14 @@
      MacroAssembler::lock(); // must be immediately before cmpxchg!
      cmpxchgptr(hdr, Address(obj, hdr_offset));
      // if the object header was not pointing to the displaced header,
      // we do unlocking via runtime call
      jcc(Assembler::notEqual, slow_case);
+     dec_held_monitor_count();
      // done
    }
    bind(done);
-   dec_held_monitor_count();
  }
  
  
  // Defines obj, preserves var_size_in_bytes
  void C1_MacroAssembler::try_allocate(Register obj, Register var_size_in_bytes, int con_size_in_bytes, Register t1, Register t2, Label& slow_case) {
< prev index next >