< prev index next >

src/hotspot/cpu/riscv/c2_MacroAssembler_riscv.cpp

Print this page
*** 124,11 ***
    // The object's monitor m is unlocked iff m->owner == nullptr,
    // otherwise m->owner may contain a thread or a stack address.
    //
    // Try to CAS m->owner from null to current thread.
    add(tmp, disp_hdr, (in_bytes(ObjectMonitor::owner_offset()) - markWord::monitor_value));
!   cmpxchg(/*memory address*/tmp, /*expected value*/zr, /*new value*/xthread, Assembler::int64, Assembler::aq,
            Assembler::rl, /*result*/flag); // cas succeeds if flag == zr(expected)
  
    if (LockingMode != LM_LIGHTWEIGHT) {
      // Store a non-null value into the box to avoid looking like a re-entrant
      // lock. The fast-path monitor unlock code checks for
--- 124,13 ---
    // The object's monitor m is unlocked iff m->owner == nullptr,
    // otherwise m->owner may contain a thread or a stack address.
    //
    // Try to CAS m->owner from null to current thread.
    add(tmp, disp_hdr, (in_bytes(ObjectMonitor::owner_offset()) - markWord::monitor_value));
!   Register tid = t0;
+   mv(tid, Address(xthread, JavaThread::lock_id_offset()));
+   cmpxchg(/*memory address*/tmp, /*expected value*/zr, /*new value*/tid, Assembler::int64, Assembler::aq,
            Assembler::rl, /*result*/flag); // cas succeeds if flag == zr(expected)
  
    if (LockingMode != LM_LIGHTWEIGHT) {
      // Store a non-null value into the box to avoid looking like a re-entrant
      // lock. The fast-path monitor unlock code checks for

*** 138,11 ***
      sd(tmp, Address(box, BasicLock::displaced_header_offset_in_bytes()));
    }
  
    beqz(flag, cont); // CAS success means locking succeeded
  
!   bne(flag, xthread, cont); // Check for recursive locking
  
    // Recursive lock case
    mv(flag, zr);
    increment(Address(disp_hdr, in_bytes(ObjectMonitor::recursions_offset()) - markWord::monitor_value), 1, t0, tmp);
  
--- 140,11 ---
      sd(tmp, Address(box, BasicLock::displaced_header_offset_in_bytes()));
    }
  
    beqz(flag, cont); // CAS success means locking succeeded
  
!   bne(flag, tid, cont); // Check for recursive locking
  
    // Recursive lock case
    mv(flag, zr);
    increment(Address(disp_hdr, in_bytes(ObjectMonitor::recursions_offset()) - markWord::monitor_value), 1, t0, tmp);
  

*** 219,14 ***
  
    if (LockingMode == LM_LIGHTWEIGHT) {
      // If the owner is anonymous, we need to fix it -- in an outline stub.
      Register tmp2 = disp_hdr;
      ld(tmp2, Address(tmp, ObjectMonitor::owner_offset()));
!     test_bit(t0, tmp2, exact_log2(ObjectMonitor::ANONYMOUS_OWNER));
      C2HandleAnonOMOwnerStub* stub = new (Compile::current()->comp_arena()) C2HandleAnonOMOwnerStub(tmp, tmp2);
      Compile::current()->output()->add_stub(stub);
!     bnez(t0, stub->entry(), /* is_far */ true);
      bind(stub->continuation());
    }
  
    ld(disp_hdr, Address(tmp, ObjectMonitor::recursions_offset()));
  
--- 221,14 ---
  
    if (LockingMode == LM_LIGHTWEIGHT) {
      // If the owner is anonymous, we need to fix it -- in an outline stub.
      Register tmp2 = disp_hdr;
      ld(tmp2, Address(tmp, ObjectMonitor::owner_offset()));
!     mv(t0, (int64_t)ObjectMonitor::ANONYMOUS_OWNER);
      C2HandleAnonOMOwnerStub* stub = new (Compile::current()->comp_arena()) C2HandleAnonOMOwnerStub(tmp, tmp2);
      Compile::current()->output()->add_stub(stub);
!     beq(t0, tmp2, stub->entry(), /* is_far */ true);
      bind(stub->continuation());
    }
  
    ld(disp_hdr, Address(tmp, ObjectMonitor::recursions_offset()));
  
< prev index next >