< prev index next >

src/hotspot/cpu/riscv/c1_MacroAssembler_riscv.cpp

Print this page
*** 57,85 ***
    Label done;
    int null_check_offset = -1;
  
    verify_oop(obj);
  
-   // save object being locked into the BasicObjectLock
-   sd(obj, Address(disp_hdr, BasicObjectLock::obj_offset_in_bytes()));
- 
    null_check_offset = offset();
  
    if (DiagnoseSyncOnValueBasedClasses != 0) {
      load_klass(hdr, obj);
      lwu(hdr, Address(hdr, Klass::access_flags_offset()));
      andi(t0, hdr, JVM_ACC_IS_VALUE_BASED_CLASS);
      bnez(t0, slow_case, true /* is_far */);
    }
  
!   // Load object header
!   ld(hdr, Address(obj, hdr_offset));
!   // and mark it as unlocked
-   ori(hdr, hdr, markWord::unlocked_value);
-   // save unlocked object header into the displaced header location on the stack
-   sd(hdr, Address(disp_hdr, 0));
-   // test if object header is still the same (i.e. unlocked), and if so, store the
-   // displaced header address in the object header - if it is not the same, get the
-   // object header instead
-   la(t1, Address(obj, hdr_offset));
-   cmpxchgptr(hdr, disp_hdr, t1, t0, done, /*fallthough*/NULL);
-   // if the object header was the same, we're done
-   // 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) sp <= hdr
-   // 3) hdr <= sp + page_size
-   //
-   // these 3 tests can be done by evaluating the following expression:
-   //
-   // (hdr -sp) & (aligned_mask - page_size)
-   //
-   // assuming both the stack pointer and page_size have their least
-   // significant 2 bits cleared and page_size is a power of 2
-   sub(hdr, hdr, sp);
-   mv(t0, aligned_mask - os::vm_page_size());
-   andr(hdr, hdr, t0);
-   // for recursive locking, the result is zero => save it in the displaced header
-   // location (NULL in the displaced hdr location indicates recursive locking)
-   sd(hdr, Address(disp_hdr, 0));
-   // otherwise we don't care about the result and handle locking via runtime call
-   bnez(hdr, slow_case, /* is_far */ true);
-   bind(done);
    return null_check_offset;
  }
  
  void C1_MacroAssembler::unlock_object(Register hdr, Register obj, Register disp_hdr, Label& slow_case) {
    const int aligned_mask = BytesPerWord - 1;
    const int hdr_offset = oopDesc::mark_offset_in_bytes();
!   assert(hdr != obj && hdr != disp_hdr && obj != disp_hdr, "registers must be different");
-   Label done;
  
-   // load displaced header
-   ld(hdr, Address(disp_hdr, 0));
-   // if the loaded hdr is NULL we had recursive locking
-   // if we had recursive locking, we are done
-   beqz(hdr, done);
-   // load object
-   ld(obj, Address(disp_hdr, BasicObjectLock::obj_offset_in_bytes()));
    verify_oop(obj);
!   // test if object header is pointing to the displaced header, and if so, restore
!   // the displaced header in the object - if the object header is not pointing to
!   // the displaced header, get the object header instead
-   // if the object header was not pointing to the displaced header,
-   // we do unlocking via runtime call
-   if (hdr_offset) {
-     la(t0, Address(obj, hdr_offset));
-     cmpxchgptr(disp_hdr, hdr, t0, t1, done, &slow_case);
-   } else {
-     cmpxchgptr(disp_hdr, hdr, obj, t1, done, &slow_case);
-   }
-   bind(done);
  }
  
  // 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 tmp1, Register tmp2, Label& slow_case) {
    if (UseTLAB) {
--- 57,34 ---
    Label done;
    int null_check_offset = -1;
  
    verify_oop(obj);
  
    null_check_offset = offset();
  
    if (DiagnoseSyncOnValueBasedClasses != 0) {
      load_klass(hdr, obj);
      lwu(hdr, Address(hdr, Klass::access_flags_offset()));
      andi(t0, hdr, JVM_ACC_IS_VALUE_BASED_CLASS);
      bnez(t0, slow_case, true /* is_far */);
    }
  
!   ld(hdr, Address(obj, oopDesc::mark_offset_in_bytes()));
!   fast_lock(obj, hdr, disp_hdr, t0, t1, slow_case);
! 
    return null_check_offset;
  }
  
  void C1_MacroAssembler::unlock_object(Register hdr, Register obj, Register disp_hdr, Label& slow_case) {
    const int aligned_mask = BytesPerWord - 1;
    const int hdr_offset = oopDesc::mark_offset_in_bytes();
!   assert_different_registers(hdr, obj, disp_hdr);
  
    verify_oop(obj);
! 
!   ld(hdr, Address(obj, oopDesc::mark_offset_in_bytes()));
!   fast_unlock(obj, hdr, t0, t1, slow_case);
  }
  
  // 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 tmp1, Register tmp2, Label& slow_case) {
    if (UseTLAB) {
< prev index next >