Skip to content

Commit a319e9a

Browse files
Yadong WangRealFYang
Yadong Wang
authored andcommitted
8277431: riscv: Intrinsify recursive ObjectMonitor locking for C2
Reviewed-by: fyang
1 parent 7cf6b9d commit a319e9a

File tree

1 file changed

+20
-1
lines changed

1 file changed

+20
-1
lines changed

src/hotspot/cpu/riscv/riscv.ad

+20-1
Original file line numberDiff line numberDiff line change
@@ -2359,6 +2359,16 @@ encode %{
23592359
__ mv(tmp, (address)markWord::unused_mark().value());
23602360
__ sd(tmp, Address(box, BasicLock::displaced_header_offset_in_bytes()));
23612361

2362+
__ beqz(flag, cont); // CAS success means locking succeeded
2363+
2364+
__ bne(flag, xthread, cont); // Check for recursive locking
2365+
2366+
// Recursive lock case
2367+
__ mv(flag, zr);
2368+
__ ld(tmp, Address(disp_hdr, ObjectMonitor::recursions_offset_in_bytes() - markWord::monitor_value));
2369+
__ add(tmp, tmp, 1u);
2370+
__ sd(tmp, Address(disp_hdr, ObjectMonitor::recursions_offset_in_bytes() - markWord::monitor_value));
2371+
23622372
__ bind(cont);
23632373
%}
23642374

@@ -2404,10 +2414,19 @@ encode %{
24042414
__ add(tmp, tmp, -(int)markWord::monitor_value); // monitor
24052415
__ ld(flag, Address(tmp, ObjectMonitor::owner_offset_in_bytes()));
24062416
__ ld(disp_hdr, Address(tmp, ObjectMonitor::recursions_offset_in_bytes()));
2417+
2418+
Label notRecursive;
24072419
__ xorr(flag, flag, xthread); // Will be 0 if we are the owner.
2408-
__ orr(flag, flag, disp_hdr); // Will be 0 if there are 0 recursions
24092420
__ bnez(flag, cont);
24102421

2422+
__ beqz(disp_hdr, notRecursive); // Will be 0 if not recursive.
2423+
2424+
// Recursive lock
2425+
__ addi(disp_hdr, disp_hdr, -1);
2426+
__ sd(disp_hdr, Address(tmp, ObjectMonitor::recursions_offset_in_bytes()));
2427+
__ j(cont);
2428+
2429+
__ bind(notRecursive);
24112430
__ ld(flag, Address(tmp, ObjectMonitor::EntryList_offset_in_bytes()));
24122431
__ ld(disp_hdr, Address(tmp, ObjectMonitor::cxq_offset_in_bytes()));
24132432
__ orr(flag, flag, disp_hdr); // Will be 0 if both are 0.

0 commit comments

Comments
 (0)