Skip to content

Commit 3059637

Browse files
committedApr 5, 2024
8316179: Use consistent naming for lightweight locking in MacroAssembler
Reviewed-by: shade Backport-of: 639ba13c4b0ada1c2ae0a46e99ed707c219b3e53
1 parent bf1e7ec commit 3059637

13 files changed

+30
-30
lines changed
 

‎src/hotspot/cpu/aarch64/aarch64.ad

+2-2
Original file line numberDiff line numberDiff line change
@@ -3867,7 +3867,7 @@ encode %{
38673867
__ b(cont);
38683868
} else {
38693869
assert(LockingMode == LM_LIGHTWEIGHT, "must be");
3870-
__ fast_lock(oop, disp_hdr, tmp, rscratch1, cont);
3870+
__ lightweight_lock(oop, disp_hdr, tmp, rscratch1, cont);
38713871
__ b(cont);
38723872
}
38733873

@@ -3945,7 +3945,7 @@ encode %{
39453945
__ b(cont);
39463946
} else {
39473947
assert(LockingMode == LM_LIGHTWEIGHT, "must be");
3948-
__ fast_unlock(oop, tmp, box, disp_hdr, cont);
3948+
__ lightweight_unlock(oop, tmp, box, disp_hdr, cont);
39493949
__ b(cont);
39503950
}
39513951

‎src/hotspot/cpu/aarch64/c1_MacroAssembler_aarch64.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ int C1_MacroAssembler::lock_object(Register hdr, Register obj, Register disp_hdr
9090
// Load object header
9191
ldr(hdr, Address(obj, hdr_offset));
9292
if (LockingMode == LM_LIGHTWEIGHT) {
93-
fast_lock(obj, hdr, rscratch1, rscratch2, slow_case);
93+
lightweight_lock(obj, hdr, rscratch1, rscratch2, slow_case);
9494
} else {
9595
// and mark it as unlocked
9696
orr(hdr, hdr, markWord::unlocked_value);
@@ -166,7 +166,7 @@ void C1_MacroAssembler::unlock_object(Register hdr, Register obj, Register disp_
166166
// be encoded.
167167
tst(hdr, markWord::monitor_value);
168168
br(Assembler::NE, slow_case);
169-
fast_unlock(obj, hdr, rscratch1, rscratch2, slow_case);
169+
lightweight_unlock(obj, hdr, rscratch1, rscratch2, slow_case);
170170
} else {
171171
// test if object header is pointing to the displaced header, and if so, restore
172172
// the displaced header in the object - if the object header is not pointing to

‎src/hotspot/cpu/aarch64/interp_masm_aarch64.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -756,7 +756,7 @@ void InterpreterMacroAssembler::lock_object(Register lock_reg)
756756

757757
if (LockingMode == LM_LIGHTWEIGHT) {
758758
ldr(tmp, Address(obj_reg, oopDesc::mark_offset_in_bytes()));
759-
fast_lock(obj_reg, tmp, rscratch1, rscratch2, slow_case);
759+
lightweight_lock(obj_reg, tmp, rscratch1, rscratch2, slow_case);
760760
b(done);
761761
} else {
762762
if (UseBiasedLocking) {
@@ -903,7 +903,7 @@ void InterpreterMacroAssembler::unlock_object(Register lock_reg)
903903

904904
ldr(header_reg, Address(obj_reg, oopDesc::mark_offset_in_bytes()));
905905
tbnz(header_reg, exact_log2(markWord::monitor_value), slow_case);
906-
fast_unlock(obj_reg, header_reg, swap_reg, rscratch1, slow_case);
906+
lightweight_unlock(obj_reg, header_reg, swap_reg, rscratch1, slow_case);
907907
b(done);
908908
bind(slow_case);
909909
} else {

‎src/hotspot/cpu/aarch64/macroAssembler_aarch64.cpp

+4-4
Original file line numberDiff line numberDiff line change
@@ -5423,14 +5423,14 @@ void MacroAssembler::spin_wait() {
54235423
}
54245424
}
54255425

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

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

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

‎src/hotspot/cpu/aarch64/macroAssembler_aarch64.hpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -1424,8 +1424,8 @@ class MacroAssembler: public Assembler {
14241424
// Code for java.lang.Thread::onSpinWait() intrinsic.
14251425
void spin_wait();
14261426

1427-
void fast_lock(Register obj, Register hdr, Register t1, Register t2, Label& slow);
1428-
void fast_unlock(Register obj, Register hdr, Register t1, Register t2, Label& slow);
1427+
void lightweight_lock(Register obj, Register hdr, Register t1, Register t2, Label& slow);
1428+
void lightweight_unlock(Register obj, Register hdr, Register t1, Register t2, Label& slow);
14291429

14301430
private:
14311431
// Check the current thread doesn't need a cross modify fence.

‎src/hotspot/cpu/aarch64/sharedRuntime_aarch64.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -1812,7 +1812,7 @@ nmethod* SharedRuntime::generate_native_wrapper(MacroAssembler* masm,
18121812
} else {
18131813
assert(LockingMode == LM_LIGHTWEIGHT, "must be");
18141814
__ ldr(swap_reg, Address(obj_reg, oopDesc::mark_offset_in_bytes()));
1815-
__ fast_lock(obj_reg, swap_reg, tmp, rscratch1, slow_path_lock);
1815+
__ lightweight_lock(obj_reg, swap_reg, tmp, rscratch1, slow_path_lock);
18161816
}
18171817
// Slow path will re-enter here
18181818

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

19691969
// slow path re-enters here

‎src/hotspot/cpu/x86/c1_MacroAssembler_x86.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ int C1_MacroAssembler::lock_object(Register hdr, Register obj, Register disp_hdr
6969
#endif
7070
// Load object header
7171
movptr(hdr, Address(obj, hdr_offset));
72-
fast_lock_impl(obj, hdr, thread, scratch, slow_case);
72+
lightweight_lock(obj, hdr, thread, scratch, slow_case);
7373
} else {
7474
Label done;
7575

@@ -134,7 +134,7 @@ void C1_MacroAssembler::unlock_object(Register hdr, Register obj, Register disp_
134134
verify_oop(obj);
135135
movptr(disp_hdr, Address(obj, hdr_offset));
136136
andptr(disp_hdr, ~(int32_t)markWord::lock_mask_in_place);
137-
fast_unlock_impl(obj, disp_hdr, hdr, slow_case);
137+
lightweight_unlock(obj, disp_hdr, hdr, slow_case);
138138
} else {
139139
Label done;
140140

‎src/hotspot/cpu/x86/c2_MacroAssembler_x86.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -545,7 +545,7 @@ void C2_MacroAssembler::fast_lock(Register objReg, Register boxReg, Register tmp
545545
}
546546
} else {
547547
assert(LockingMode == LM_LIGHTWEIGHT, "");
548-
fast_lock_impl(objReg, tmpReg, thread, scrReg, DONE_LABEL);
548+
lightweight_lock(objReg, tmpReg, thread, scrReg, DONE_LABEL);
549549
xorl(tmpReg, tmpReg); // Set ZF=1 to indicate success
550550
}
551551
jmp(DONE_LABEL);
@@ -859,7 +859,7 @@ void C2_MacroAssembler::fast_unlock(Register objReg, Register boxReg, Register t
859859
bind (Stacked);
860860
if (LockingMode == LM_LIGHTWEIGHT) {
861861
mov(boxReg, tmpReg);
862-
fast_unlock_impl(objReg, boxReg, tmpReg, DONE_LABEL);
862+
lightweight_unlock(objReg, boxReg, tmpReg, DONE_LABEL);
863863
xorl(tmpReg, tmpReg);
864864
} else if (LockingMode == LM_LEGACY) {
865865
movptr(tmpReg, Address (boxReg, 0)); // re-fetch

‎src/hotspot/cpu/x86/interp_masm_x86.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -1260,7 +1260,7 @@ void InterpreterMacroAssembler::lock_object(Register lock_reg) {
12601260
#endif
12611261
// Load object header, prepare for CAS from unlocked to locked.
12621262
movptr(swap_reg, Address(obj_reg, oopDesc::mark_offset_in_bytes()));
1263-
fast_lock_impl(obj_reg, swap_reg, thread, tmp_reg, slow_case);
1263+
lightweight_lock(obj_reg, swap_reg, thread, tmp_reg, slow_case);
12641264
jmp(done);
12651265
} else {
12661266
// Load immediate 1 into swap_reg %rax
@@ -1395,7 +1395,7 @@ void InterpreterMacroAssembler::unlock_object(Register lock_reg) {
13951395
// Try to swing header from locked to unlock.
13961396
movptr(swap_reg, Address(obj_reg, oopDesc::mark_offset_in_bytes()));
13971397
andptr(swap_reg, ~(int32_t)markWord::lock_mask_in_place);
1398-
fast_unlock_impl(obj_reg, swap_reg, header_reg, slow_case);
1398+
lightweight_unlock(obj_reg, swap_reg, header_reg, slow_case);
13991399
jmp(done);
14001400
} else {
14011401
if (UseBiasedLocking) {

‎src/hotspot/cpu/x86/macroAssembler_x86.cpp

+4-4
Original file line numberDiff line numberDiff line change
@@ -8774,15 +8774,15 @@ void MacroAssembler::get_thread(Register thread) {
87748774

87758775
#endif // !WIN32 || _LP64
87768776

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

@@ -8810,14 +8810,14 @@ void MacroAssembler::fast_lock_impl(Register obj, Register hdr, Register thread,
88108810
movl(Address(thread, JavaThread::lock_stack_top_offset()), tmp);
88118811
}
88128812

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

‎src/hotspot/cpu/x86/macroAssembler_x86.hpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -1925,8 +1925,8 @@ class MacroAssembler: public Assembler {
19251925

19261926
void vallones(XMMRegister dst, int vector_len);
19271927

1928-
void fast_lock_impl(Register obj, Register hdr, Register thread, Register tmp, Label& slow);
1929-
void fast_unlock_impl(Register obj, Register hdr, Register tmp, Label& slow);
1928+
void lightweight_lock(Register obj, Register hdr, Register thread, Register tmp, Label& slow);
1929+
void lightweight_unlock(Register obj, Register hdr, Register tmp, Label& slow);
19301930
};
19311931

19321932
/**

‎src/hotspot/cpu/x86/sharedRuntime_x86_32.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -1864,7 +1864,7 @@ nmethod* SharedRuntime::generate_native_wrapper(MacroAssembler* masm,
18641864
assert(LockingMode == LM_LIGHTWEIGHT, "must be");
18651865
// Load object header
18661866
__ movptr(swap_reg, Address(obj_reg, oopDesc::mark_offset_in_bytes()));
1867-
__ fast_lock_impl(obj_reg, swap_reg, thread, lock_reg, slow_path_lock);
1867+
__ lightweight_lock(obj_reg, swap_reg, thread, lock_reg, slow_path_lock);
18681868
}
18691869
// Slow path will re-enter here
18701870
__ bind(lock_done);
@@ -2036,7 +2036,7 @@ nmethod* SharedRuntime::generate_native_wrapper(MacroAssembler* masm,
20362036
assert(LockingMode == LM_LIGHTWEIGHT, "must be");
20372037
__ movptr(swap_reg, Address(obj_reg, oopDesc::mark_offset_in_bytes()));
20382038
__ andptr(swap_reg, ~(int32_t)markWord::lock_mask_in_place);
2039-
__ fast_unlock_impl(obj_reg, swap_reg, lock_reg, slow_path_unlock);
2039+
__ lightweight_unlock(obj_reg, swap_reg, lock_reg, slow_path_unlock);
20402040
}
20412041

20422042
// slow path re-enters here

‎src/hotspot/cpu/x86/sharedRuntime_x86_64.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -2113,7 +2113,7 @@ nmethod* SharedRuntime::generate_native_wrapper(MacroAssembler* masm,
21132113
assert(LockingMode == LM_LIGHTWEIGHT, "must be");
21142114
// Load object header
21152115
__ movptr(swap_reg, Address(obj_reg, oopDesc::mark_offset_in_bytes()));
2116-
__ fast_lock_impl(obj_reg, swap_reg, r15_thread, rscratch1, slow_path_lock);
2116+
__ lightweight_lock(obj_reg, swap_reg, r15_thread, rscratch1, slow_path_lock);
21172117
}
21182118

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

22732273
// slow path re-enters here

0 commit comments

Comments
 (0)
Please sign in to comment.