Skip to content

Commit 7a5acb9

Browse files
committed
8343840: Rewrite the ObjectMonitor lists
Reviewed-by: dholmes, coleenp, pchilanomate, yzheng
1 parent 40f150d commit 7a5acb9

File tree

10 files changed

+386
-400
lines changed

10 files changed

+386
-400
lines changed

src/hotspot/cpu/aarch64/c2_MacroAssembler_aarch64.cpp

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -312,10 +312,8 @@ void C2_MacroAssembler::fast_unlock(Register objectReg, Register boxReg, Registe
312312
// StoreLoad achieves this.
313313
membar(StoreLoad);
314314

315-
// Check if the entry lists are empty (EntryList first - by convention).
316-
ldr(rscratch1, Address(tmp, ObjectMonitor::EntryList_offset()));
317-
ldr(tmpReg, Address(tmp, ObjectMonitor::cxq_offset()));
318-
orr(rscratch1, rscratch1, tmpReg);
315+
// Check if the entry_list is empty.
316+
ldr(rscratch1, Address(tmp, ObjectMonitor::entry_list_offset()));
319317
cmp(rscratch1, zr);
320318
br(Assembler::EQ, cont); // If so we are done.
321319

@@ -635,10 +633,8 @@ void C2_MacroAssembler::fast_unlock_lightweight(Register obj, Register box, Regi
635633
// StoreLoad achieves this.
636634
membar(StoreLoad);
637635

638-
// Check if the entry lists are empty (EntryList first - by convention).
639-
ldr(rscratch1, Address(t1_monitor, ObjectMonitor::EntryList_offset()));
640-
ldr(t3_t, Address(t1_monitor, ObjectMonitor::cxq_offset()));
641-
orr(rscratch1, rscratch1, t3_t);
636+
// Check if the entry_list is empty.
637+
ldr(rscratch1, Address(t1_monitor, ObjectMonitor::entry_list_offset()));
642638
cmp(rscratch1, zr);
643639
br(Assembler::EQ, unlocked); // If so we are done.
644640

src/hotspot/cpu/ppc/macroAssembler_ppc.cpp

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2958,10 +2958,8 @@ void MacroAssembler::compiler_fast_unlock_object(ConditionRegister flag, Registe
29582958
// StoreLoad achieves this.
29592959
membar(StoreLoad);
29602960

2961-
// Check if the entry lists are empty (EntryList first - by convention).
2962-
ld(temp, in_bytes(ObjectMonitor::EntryList_offset()), current_header);
2963-
ld(displaced_header, in_bytes(ObjectMonitor::cxq_offset()), current_header);
2964-
orr(temp, temp, displaced_header); // Will be 0 if both are 0.
2961+
// Check if the entry_list is empty.
2962+
ld(temp, in_bytes(ObjectMonitor::entry_list_offset()), current_header);
29652963
cmpdi(flag, temp, 0);
29662964
beq(flag, success); // If so we are done.
29672965

@@ -3299,8 +3297,6 @@ void MacroAssembler::compiler_fast_unlock_lightweight_object(ConditionRegister f
32993297

33003298
bind(not_recursive);
33013299

3302-
const Register t2 = tmp2;
3303-
33043300
// Set owner to null.
33053301
// Release to satisfy the JMM
33063302
release();
@@ -3310,10 +3306,8 @@ void MacroAssembler::compiler_fast_unlock_lightweight_object(ConditionRegister f
33103306
// StoreLoad achieves this.
33113307
membar(StoreLoad);
33123308

3313-
// Check if the entry lists are empty (EntryList first - by convention).
3314-
ld(t, in_bytes(ObjectMonitor::EntryList_offset()), monitor);
3315-
ld(t2, in_bytes(ObjectMonitor::cxq_offset()), monitor);
3316-
orr(t, t, t2);
3309+
// Check if the entry_list is empty.
3310+
ld(t, in_bytes(ObjectMonitor::entry_list_offset()), monitor);
33173311
cmpdi(CR0, t, 0);
33183312
beq(CR0, unlocked); // If so we are done.
33193313

src/hotspot/cpu/riscv/c2_MacroAssembler_riscv.cpp

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -233,10 +233,8 @@ void C2_MacroAssembler::fast_unlock(Register objectReg, Register boxReg,
233233
// StoreLoad achieves this.
234234
membar(StoreLoad);
235235

236-
// Check if the entry lists are empty (EntryList first - by convention).
237-
ld(t0, Address(tmp, ObjectMonitor::EntryList_offset()));
238-
ld(tmp1Reg, Address(tmp, ObjectMonitor::cxq_offset()));
239-
orr(t0, t0, tmp1Reg);
236+
// Check if the entry_list is empty.
237+
ld(t0, Address(tmp, ObjectMonitor::entry_list_offset()));
240238
beqz(t0, unlocked); // If so we are done.
241239

242240
// Check if there is a successor.
@@ -569,10 +567,8 @@ void C2_MacroAssembler::fast_unlock_lightweight(Register obj, Register box,
569567
// StoreLoad achieves this.
570568
membar(StoreLoad);
571569

572-
// Check if the entry lists are empty (EntryList first - by convention).
573-
ld(t0, Address(tmp1_monitor, ObjectMonitor::EntryList_offset()));
574-
ld(tmp3_t, Address(tmp1_monitor, ObjectMonitor::cxq_offset()));
575-
orr(t0, t0, tmp3_t);
570+
// Check if the entry_list is empty.
571+
ld(t0, Address(tmp1_monitor, ObjectMonitor::entry_list_offset()));
576572
beqz(t0, unlocked); // If so we are done.
577573

578574
// Check if there is a successor.

src/hotspot/cpu/s390/macroAssembler_s390.cpp

Lines changed: 7 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -3931,7 +3931,7 @@ void MacroAssembler::compiler_fast_unlock_object(Register oop, Register box, Reg
39313931

39323932
bind(not_recursive);
39333933

3934-
NearLabel check_succ, set_eq_unlocked;
3934+
NearLabel set_eq_unlocked;
39353935

39363936
// Set owner to null.
39373937
// Release to satisfy the JMM
@@ -3941,14 +3941,10 @@ void MacroAssembler::compiler_fast_unlock_object(Register oop, Register box, Reg
39413941
// We need a full fence after clearing owner to avoid stranding.
39423942
z_fence();
39433943

3944-
// Check if the entry lists are empty (EntryList first - by convention).
3945-
load_and_test_long(temp, Address(currentHeader, OM_OFFSET_NO_MONITOR_VALUE_TAG(EntryList)));
3946-
z_brne(check_succ);
3947-
load_and_test_long(temp, Address(currentHeader, OM_OFFSET_NO_MONITOR_VALUE_TAG(cxq)));
3944+
// Check if the entry_list is empty.
3945+
load_and_test_long(temp, Address(currentHeader, OM_OFFSET_NO_MONITOR_VALUE_TAG(entry_list)));
39483946
z_bre(done); // If so we are done.
39493947

3950-
bind(check_succ);
3951-
39523948
// Check if there is a successor.
39533949
load_and_test_long(temp, Address(currentHeader, OM_OFFSET_NO_MONITOR_VALUE_TAG(succ)));
39543950
z_brne(set_eq_unlocked); // If so we are done.
@@ -6794,9 +6790,8 @@ void MacroAssembler::compiler_fast_unlock_lightweight_object(Register obj, Regis
67946790

67956791
const ByteSize monitor_tag = in_ByteSize(UseObjectMonitorTable ? 0 : checked_cast<int>(markWord::monitor_value));
67966792
const Address recursions_address{monitor, ObjectMonitor::recursions_offset() - monitor_tag};
6797-
const Address cxq_address{monitor, ObjectMonitor::cxq_offset() - monitor_tag};
67986793
const Address succ_address{monitor, ObjectMonitor::succ_offset() - monitor_tag};
6799-
const Address EntryList_address{monitor, ObjectMonitor::EntryList_offset() - monitor_tag};
6794+
const Address entry_list_address{monitor, ObjectMonitor::entry_list_offset() - monitor_tag};
68006795
const Address owner_address{monitor, ObjectMonitor::owner_offset() - monitor_tag};
68016796

68026797
NearLabel not_recursive;
@@ -6813,7 +6808,7 @@ void MacroAssembler::compiler_fast_unlock_lightweight_object(Register obj, Regis
68136808

68146809
bind(not_recursive);
68156810

6816-
NearLabel check_succ, set_eq_unlocked;
6811+
NearLabel set_eq_unlocked;
68176812

68186813
// Set owner to null.
68196814
// Release to satisfy the JMM
@@ -6823,14 +6818,10 @@ void MacroAssembler::compiler_fast_unlock_lightweight_object(Register obj, Regis
68236818
// We need a full fence after clearing owner to avoid stranding.
68246819
z_fence();
68256820

6826-
// Check if the entry lists are empty (EntryList first - by convention).
6827-
load_and_test_long(tmp2, EntryList_address);
6828-
z_brne(check_succ);
6829-
load_and_test_long(tmp2, cxq_address);
6821+
// Check if the entry_list is empty.
6822+
load_and_test_long(tmp2, entry_list_address);
68306823
z_bre(unlocked); // If so we are done.
68316824

6832-
bind(check_succ);
6833-
68346825
// Check if there is a successor.
68356826
load_and_test_long(tmp2, succ_address);
68366827
z_brne(set_eq_unlocked); // If so we are done.

src/hotspot/cpu/x86/c2_MacroAssembler_x86.cpp

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -414,8 +414,6 @@ void C2_MacroAssembler::fast_unlock(Register objReg, Register boxReg, Register t
414414
// Despite our balanced locking property we still check that m->_owner == Self
415415
// as java routines or native JNI code called by this thread might
416416
// have released the lock.
417-
// Refer to the comments in synchronizer.cpp for how we might encode extra
418-
// state in _succ so we can avoid fetching EntryList|cxq.
419417
//
420418
// If there's no contention try a 1-0 exit. That is, exit without
421419
// a costly MEMBAR or CAS. See synchronizer.cpp for details on how
@@ -447,9 +445,8 @@ void C2_MacroAssembler::fast_unlock(Register objReg, Register boxReg, Register t
447445
// StoreLoad achieves this.
448446
membar(StoreLoad);
449447

450-
// Check if the entry lists are empty (EntryList first - by convention).
451-
movptr(boxReg, Address(tmpReg, OM_OFFSET_NO_MONITOR_VALUE_TAG(EntryList)));
452-
orptr(boxReg, Address(tmpReg, OM_OFFSET_NO_MONITOR_VALUE_TAG(cxq)));
448+
// Check if the entry_list is empty.
449+
cmpptr(Address(tmpReg, OM_OFFSET_NO_MONITOR_VALUE_TAG(entry_list)), NULL_WORD);
453450
jccb(Assembler::zero, LSuccess); // If so we are done.
454451

455452
// Check if there is a successor.
@@ -767,9 +764,8 @@ void C2_MacroAssembler::fast_unlock_lightweight(Register obj, Register reg_rax,
767764
}
768765
const ByteSize monitor_tag = in_ByteSize(UseObjectMonitorTable ? 0 : checked_cast<int>(markWord::monitor_value));
769766
const Address recursions_address{monitor, ObjectMonitor::recursions_offset() - monitor_tag};
770-
const Address cxq_address{monitor, ObjectMonitor::cxq_offset() - monitor_tag};
771767
const Address succ_address{monitor, ObjectMonitor::succ_offset() - monitor_tag};
772-
const Address EntryList_address{monitor, ObjectMonitor::EntryList_offset() - monitor_tag};
768+
const Address entry_list_address{monitor, ObjectMonitor::entry_list_offset() - monitor_tag};
773769
const Address owner_address{monitor, ObjectMonitor::owner_offset() - monitor_tag};
774770

775771
Label recursive;
@@ -785,9 +781,8 @@ void C2_MacroAssembler::fast_unlock_lightweight(Register obj, Register reg_rax,
785781
// StoreLoad achieves this.
786782
membar(StoreLoad);
787783

788-
// Check if the entry lists are empty (EntryList first - by convention).
789-
movptr(reg_rax, EntryList_address);
790-
orptr(reg_rax, cxq_address);
784+
// Check if the entry_list is empty.
785+
cmpptr(entry_list_address, NULL_WORD);
791786
jccb(Assembler::zero, unlocked); // If so we are done.
792787

793788
// Check if there is a successor.

src/hotspot/share/jvmci/vmStructs_jvmci.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -328,8 +328,7 @@
328328
\
329329
volatile_nonstatic_field(ObjectMonitor, _owner, int64_t) \
330330
volatile_nonstatic_field(ObjectMonitor, _recursions, intptr_t) \
331-
volatile_nonstatic_field(ObjectMonitor, _cxq, ObjectWaiter*) \
332-
volatile_nonstatic_field(ObjectMonitor, _EntryList, ObjectWaiter*) \
331+
volatile_nonstatic_field(ObjectMonitor, _entry_list, ObjectWaiter*) \
333332
volatile_nonstatic_field(ObjectMonitor, _succ, int64_t) \
334333
volatile_nonstatic_field(ObjectMonitor, _stack_locker, BasicLock*) \
335334
\

src/hotspot/share/prims/jvm.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3766,7 +3766,7 @@ JVM_ENTRY(jobject, JVM_TakeVirtualThreadListToUnblock(JNIEnv* env, jclass ignore
37663766
ParkEvent* parkEvent = ObjectMonitor::vthread_unparker_ParkEvent();
37673767
assert(parkEvent != nullptr, "not initialized");
37683768

3769-
OopHandle& list_head = ObjectMonitor::vthread_cxq_head();
3769+
OopHandle& list_head = ObjectMonitor::vthread_list_head();
37703770
oop vthread_head = nullptr;
37713771
while (true) {
37723772
if (list_head.peek() != nullptr) {

0 commit comments

Comments
 (0)