< prev index next >

src/hotspot/cpu/riscv/c1_MacroAssembler_riscv.cpp

Print this page
@@ -81,12 +81,12 @@
      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(temp, Address(obj, hdr_offset));
-     cmpxchgptr(hdr, disp_hdr, temp, t1, done, /*fallthough*/nullptr);
      // if the object header was the same, we're done
+     cmpxchgptr(hdr, disp_hdr, temp, t1, done, /*fallthough*/nullptr);
      // 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

@@ -104,15 +104,16 @@
      // 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);
+ 
      // done
      bind(done);
+     inc_held_monitor_count();
    }
  
-   increment(Address(xthread, JavaThread::held_monitor_count_offset()));
    return null_check_offset;
  }
  
  void C1_MacroAssembler::unlock_object(Register hdr, Register obj, Register disp_hdr, Register temp, Label& slow_case) {
    const int aligned_mask = BytesPerWord - 1;

@@ -144,15 +145,15 @@
        la(temp, Address(obj, hdr_offset));
        cmpxchgptr(disp_hdr, hdr, temp, t1, done, &slow_case);
      } else {
        cmpxchgptr(disp_hdr, hdr, obj, t1, done, &slow_case);
      }
+ 
      // done
      bind(done);
+     dec_held_monitor_count();
    }
- 
-   decrement(Address(xthread, JavaThread::held_monitor_count_offset()));
  }
  
  // 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 >