Skip to content

Commit

Permalink
8316179: Use consistent naming for lightweight locking in MacroAssembler
Browse files Browse the repository at this point in the history
Reviewed-by: shade
Backport-of: 639ba13c4b0ada1c2ae0a46e99ed707c219b3e53
  • Loading branch information
rkennke committed Apr 5, 2024
1 parent bf1e7ec commit 3059637
Show file tree
Hide file tree
Showing 13 changed files with 30 additions and 30 deletions.
4 changes: 2 additions & 2 deletions src/hotspot/cpu/aarch64/aarch64.ad
Original file line number Diff line number Diff line change
Expand Up @@ -3867,7 +3867,7 @@ encode %{
__ b(cont);
} else {
assert(LockingMode == LM_LIGHTWEIGHT, "must be");
__ fast_lock(oop, disp_hdr, tmp, rscratch1, cont);
__ lightweight_lock(oop, disp_hdr, tmp, rscratch1, cont);
__ b(cont);
}

Expand Down Expand Up @@ -3945,7 +3945,7 @@ encode %{
__ b(cont);
} else {
assert(LockingMode == LM_LIGHTWEIGHT, "must be");
__ fast_unlock(oop, tmp, box, disp_hdr, cont);
__ lightweight_unlock(oop, tmp, box, disp_hdr, cont);
__ b(cont);
}

Expand Down
4 changes: 2 additions & 2 deletions src/hotspot/cpu/aarch64/c1_MacroAssembler_aarch64.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ int C1_MacroAssembler::lock_object(Register hdr, Register obj, Register disp_hdr
// Load object header
ldr(hdr, Address(obj, hdr_offset));
if (LockingMode == LM_LIGHTWEIGHT) {
fast_lock(obj, hdr, rscratch1, rscratch2, slow_case);
lightweight_lock(obj, hdr, rscratch1, rscratch2, slow_case);
} else {
// and mark it as unlocked
orr(hdr, hdr, markWord::unlocked_value);
Expand Down Expand Up @@ -166,7 +166,7 @@ void C1_MacroAssembler::unlock_object(Register hdr, Register obj, Register disp_
// be encoded.
tst(hdr, markWord::monitor_value);
br(Assembler::NE, slow_case);
fast_unlock(obj, hdr, rscratch1, rscratch2, slow_case);
lightweight_unlock(obj, hdr, rscratch1, rscratch2, slow_case);
} else {
// 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
Expand Down
4 changes: 2 additions & 2 deletions src/hotspot/cpu/aarch64/interp_masm_aarch64.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -756,7 +756,7 @@ void InterpreterMacroAssembler::lock_object(Register lock_reg)

if (LockingMode == LM_LIGHTWEIGHT) {
ldr(tmp, Address(obj_reg, oopDesc::mark_offset_in_bytes()));
fast_lock(obj_reg, tmp, rscratch1, rscratch2, slow_case);
lightweight_lock(obj_reg, tmp, rscratch1, rscratch2, slow_case);
b(done);
} else {
if (UseBiasedLocking) {
Expand Down Expand Up @@ -903,7 +903,7 @@ void InterpreterMacroAssembler::unlock_object(Register lock_reg)

ldr(header_reg, Address(obj_reg, oopDesc::mark_offset_in_bytes()));
tbnz(header_reg, exact_log2(markWord::monitor_value), slow_case);
fast_unlock(obj_reg, header_reg, swap_reg, rscratch1, slow_case);
lightweight_unlock(obj_reg, header_reg, swap_reg, rscratch1, slow_case);
b(done);
bind(slow_case);
} else {
Expand Down
8 changes: 4 additions & 4 deletions src/hotspot/cpu/aarch64/macroAssembler_aarch64.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5423,14 +5423,14 @@ void MacroAssembler::spin_wait() {
}
}

// Implements fast-locking.
// Implements lightweight-locking.
// Branches to slow upon failure to lock the object, with ZF cleared.
// Falls through upon success with ZF set.
//
// - obj: the object to be locked
// - hdr: the header, already loaded from obj, will be destroyed
// - t1, t2: temporary registers, will be destroyed
void MacroAssembler::fast_lock(Register obj, Register hdr, Register t1, Register t2, Label& slow) {
void MacroAssembler::lightweight_lock(Register obj, Register hdr, Register t1, Register t2, Label& slow) {
assert(LockingMode == LM_LIGHTWEIGHT, "only used with new lightweight locking");
assert_different_registers(obj, hdr, t1, t2);

Expand All @@ -5455,14 +5455,14 @@ void MacroAssembler::fast_lock(Register obj, Register hdr, Register t1, Register
strw(t1, Address(rthread, JavaThread::lock_stack_top_offset()));
}

// Implements fast-unlocking.
// Implements lightweight-unlocking.
// Branches to slow upon failure, with ZF cleared.
// Falls through upon success, with ZF set.
//
// - obj: the object to be unlocked
// - hdr: the (pre-loaded) header of the object
// - t1, t2: temporary registers
void MacroAssembler::fast_unlock(Register obj, Register hdr, Register t1, Register t2, Label& slow) {
void MacroAssembler::lightweight_unlock(Register obj, Register hdr, Register t1, Register t2, Label& slow) {
assert(LockingMode == LM_LIGHTWEIGHT, "only used with new lightweight locking");
assert_different_registers(obj, hdr, t1, t2);

Expand Down
4 changes: 2 additions & 2 deletions src/hotspot/cpu/aarch64/macroAssembler_aarch64.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -1424,8 +1424,8 @@ class MacroAssembler: public Assembler {
// Code for java.lang.Thread::onSpinWait() intrinsic.
void spin_wait();

void fast_lock(Register obj, Register hdr, Register t1, Register t2, Label& slow);
void fast_unlock(Register obj, Register hdr, Register t1, Register t2, Label& slow);
void lightweight_lock(Register obj, Register hdr, Register t1, Register t2, Label& slow);
void lightweight_unlock(Register obj, Register hdr, Register t1, Register t2, Label& slow);

private:
// Check the current thread doesn't need a cross modify fence.
Expand Down
4 changes: 2 additions & 2 deletions src/hotspot/cpu/aarch64/sharedRuntime_aarch64.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1812,7 +1812,7 @@ nmethod* SharedRuntime::generate_native_wrapper(MacroAssembler* masm,
} else {
assert(LockingMode == LM_LIGHTWEIGHT, "must be");
__ ldr(swap_reg, Address(obj_reg, oopDesc::mark_offset_in_bytes()));
__ fast_lock(obj_reg, swap_reg, tmp, rscratch1, slow_path_lock);
__ lightweight_lock(obj_reg, swap_reg, tmp, rscratch1, slow_path_lock);
}
// Slow path will re-enter here

Expand Down Expand Up @@ -1963,7 +1963,7 @@ nmethod* SharedRuntime::generate_native_wrapper(MacroAssembler* masm,
assert(LockingMode == LM_LIGHTWEIGHT, "");
__ ldr(old_hdr, Address(obj_reg, oopDesc::mark_offset_in_bytes()));
__ tbnz(old_hdr, exact_log2(markWord::monitor_value), slow_path_unlock);
__ fast_unlock(obj_reg, old_hdr, swap_reg, rscratch1, slow_path_unlock);
__ lightweight_unlock(obj_reg, old_hdr, swap_reg, rscratch1, slow_path_unlock);
}

// slow path re-enters here
Expand Down
4 changes: 2 additions & 2 deletions src/hotspot/cpu/x86/c1_MacroAssembler_x86.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ int C1_MacroAssembler::lock_object(Register hdr, Register obj, Register disp_hdr
#endif
// Load object header
movptr(hdr, Address(obj, hdr_offset));
fast_lock_impl(obj, hdr, thread, scratch, slow_case);
lightweight_lock(obj, hdr, thread, scratch, slow_case);
} else {
Label done;

Expand Down Expand Up @@ -134,7 +134,7 @@ void C1_MacroAssembler::unlock_object(Register hdr, Register obj, Register disp_
verify_oop(obj);
movptr(disp_hdr, Address(obj, hdr_offset));
andptr(disp_hdr, ~(int32_t)markWord::lock_mask_in_place);
fast_unlock_impl(obj, disp_hdr, hdr, slow_case);
lightweight_unlock(obj, disp_hdr, hdr, slow_case);
} else {
Label done;

Expand Down
4 changes: 2 additions & 2 deletions src/hotspot/cpu/x86/c2_MacroAssembler_x86.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -545,7 +545,7 @@ void C2_MacroAssembler::fast_lock(Register objReg, Register boxReg, Register tmp
}
} else {
assert(LockingMode == LM_LIGHTWEIGHT, "");
fast_lock_impl(objReg, tmpReg, thread, scrReg, DONE_LABEL);
lightweight_lock(objReg, tmpReg, thread, scrReg, DONE_LABEL);
xorl(tmpReg, tmpReg); // Set ZF=1 to indicate success
}
jmp(DONE_LABEL);
Expand Down Expand Up @@ -859,7 +859,7 @@ void C2_MacroAssembler::fast_unlock(Register objReg, Register boxReg, Register t
bind (Stacked);
if (LockingMode == LM_LIGHTWEIGHT) {
mov(boxReg, tmpReg);
fast_unlock_impl(objReg, boxReg, tmpReg, DONE_LABEL);
lightweight_unlock(objReg, boxReg, tmpReg, DONE_LABEL);
xorl(tmpReg, tmpReg);
} else if (LockingMode == LM_LEGACY) {
movptr(tmpReg, Address (boxReg, 0)); // re-fetch
Expand Down
4 changes: 2 additions & 2 deletions src/hotspot/cpu/x86/interp_masm_x86.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1260,7 +1260,7 @@ void InterpreterMacroAssembler::lock_object(Register lock_reg) {
#endif
// Load object header, prepare for CAS from unlocked to locked.
movptr(swap_reg, Address(obj_reg, oopDesc::mark_offset_in_bytes()));
fast_lock_impl(obj_reg, swap_reg, thread, tmp_reg, slow_case);
lightweight_lock(obj_reg, swap_reg, thread, tmp_reg, slow_case);
jmp(done);
} else {
// Load immediate 1 into swap_reg %rax
Expand Down Expand Up @@ -1395,7 +1395,7 @@ void InterpreterMacroAssembler::unlock_object(Register lock_reg) {
// Try to swing header from locked to unlock.
movptr(swap_reg, Address(obj_reg, oopDesc::mark_offset_in_bytes()));
andptr(swap_reg, ~(int32_t)markWord::lock_mask_in_place);
fast_unlock_impl(obj_reg, swap_reg, header_reg, slow_case);
lightweight_unlock(obj_reg, swap_reg, header_reg, slow_case);
jmp(done);
} else {
if (UseBiasedLocking) {
Expand Down
8 changes: 4 additions & 4 deletions src/hotspot/cpu/x86/macroAssembler_x86.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8774,15 +8774,15 @@ void MacroAssembler::get_thread(Register thread) {

#endif // !WIN32 || _LP64

// Implements fast-locking.
// Implements lightweight-locking.
// Branches to slow upon failure to lock the object, with ZF cleared.
// Falls through upon success with unspecified ZF.
//
// obj: the object to be locked
// hdr: the (pre-loaded) header of the object, must be rax
// thread: the thread which attempts to lock obj
// tmp: a temporary register
void MacroAssembler::fast_lock_impl(Register obj, Register hdr, Register thread, Register tmp, Label& slow) {
void MacroAssembler::lightweight_lock(Register obj, Register hdr, Register thread, Register tmp, Label& slow) {
assert(hdr == rax, "header must be in rax for cmpxchg");
assert_different_registers(obj, hdr, thread, tmp);

Expand Down Expand Up @@ -8810,14 +8810,14 @@ void MacroAssembler::fast_lock_impl(Register obj, Register hdr, Register thread,
movl(Address(thread, JavaThread::lock_stack_top_offset()), tmp);
}

// Implements fast-unlocking.
// Implements lightweight-unlocking.
// Branches to slow upon failure, with ZF cleared.
// Falls through upon success, with unspecified ZF.
//
// obj: the object to be unlocked
// hdr: the (pre-loaded) header of the object, must be rax
// tmp: a temporary register
void MacroAssembler::fast_unlock_impl(Register obj, Register hdr, Register tmp, Label& slow) {
void MacroAssembler::lightweight_unlock(Register obj, Register hdr, Register tmp, Label& slow) {
assert(hdr == rax, "header must be in rax for cmpxchg");
assert_different_registers(obj, hdr, tmp);

Expand Down
4 changes: 2 additions & 2 deletions src/hotspot/cpu/x86/macroAssembler_x86.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -1925,8 +1925,8 @@ class MacroAssembler: public Assembler {

void vallones(XMMRegister dst, int vector_len);

void fast_lock_impl(Register obj, Register hdr, Register thread, Register tmp, Label& slow);
void fast_unlock_impl(Register obj, Register hdr, Register tmp, Label& slow);
void lightweight_lock(Register obj, Register hdr, Register thread, Register tmp, Label& slow);
void lightweight_unlock(Register obj, Register hdr, Register tmp, Label& slow);
};

/**
Expand Down
4 changes: 2 additions & 2 deletions src/hotspot/cpu/x86/sharedRuntime_x86_32.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1864,7 +1864,7 @@ nmethod* SharedRuntime::generate_native_wrapper(MacroAssembler* masm,
assert(LockingMode == LM_LIGHTWEIGHT, "must be");
// Load object header
__ movptr(swap_reg, Address(obj_reg, oopDesc::mark_offset_in_bytes()));
__ fast_lock_impl(obj_reg, swap_reg, thread, lock_reg, slow_path_lock);
__ lightweight_lock(obj_reg, swap_reg, thread, lock_reg, slow_path_lock);
}
// Slow path will re-enter here
__ bind(lock_done);
Expand Down Expand Up @@ -2036,7 +2036,7 @@ nmethod* SharedRuntime::generate_native_wrapper(MacroAssembler* masm,
assert(LockingMode == LM_LIGHTWEIGHT, "must be");
__ movptr(swap_reg, Address(obj_reg, oopDesc::mark_offset_in_bytes()));
__ andptr(swap_reg, ~(int32_t)markWord::lock_mask_in_place);
__ fast_unlock_impl(obj_reg, swap_reg, lock_reg, slow_path_unlock);
__ lightweight_unlock(obj_reg, swap_reg, lock_reg, slow_path_unlock);
}

// slow path re-enters here
Expand Down
4 changes: 2 additions & 2 deletions src/hotspot/cpu/x86/sharedRuntime_x86_64.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2113,7 +2113,7 @@ nmethod* SharedRuntime::generate_native_wrapper(MacroAssembler* masm,
assert(LockingMode == LM_LIGHTWEIGHT, "must be");
// Load object header
__ movptr(swap_reg, Address(obj_reg, oopDesc::mark_offset_in_bytes()));
__ fast_lock_impl(obj_reg, swap_reg, r15_thread, rscratch1, slow_path_lock);
__ lightweight_lock(obj_reg, swap_reg, r15_thread, rscratch1, slow_path_lock);
}

// Slow path will re-enter here
Expand Down Expand Up @@ -2267,7 +2267,7 @@ nmethod* SharedRuntime::generate_native_wrapper(MacroAssembler* masm,
assert(LockingMode == LM_LIGHTWEIGHT, "must be");
__ movptr(swap_reg, Address(obj_reg, oopDesc::mark_offset_in_bytes()));
__ andptr(swap_reg, ~(int32_t)markWord::lock_mask_in_place);
__ fast_unlock_impl(obj_reg, swap_reg, lock_reg, slow_path_unlock);
__ lightweight_unlock(obj_reg, swap_reg, lock_reg, slow_path_unlock);
}

// slow path re-enters here
Expand Down

0 comments on commit 3059637

Please sign in to comment.