Skip to content

Commit e6781fd

Browse files
committed
8367601: Remove held_monitor_count
Reviewed-by: mdoerr, pchilanomate, fyang
1 parent 069c569 commit e6781fd

27 files changed

+17
-401
lines changed

src/hotspot/cpu/aarch64/globalDefinitions_aarch64.hpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,6 @@ const bool CCallingConventionRequiresIntsAsLongs = false;
3535

3636
#define SUPPORTS_NATIVE_CX8
3737

38-
#define SUPPORT_MONITOR_COUNT
39-
4038
// Aarch64 was not originally defined to be multi-copy-atomic, but now
4139
// is. See: "Simplifying ARM Concurrency: Multicopy-atomic Axiomatic
4240
// and Operational Models for ARMv8"

src/hotspot/cpu/aarch64/macroAssembler_aarch64.cpp

Lines changed: 0 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -5630,38 +5630,6 @@ void MacroAssembler::tlab_allocate(Register obj,
56305630
bs->tlab_allocate(this, obj, var_size_in_bytes, con_size_in_bytes, t1, t2, slow_case);
56315631
}
56325632

5633-
void MacroAssembler::inc_held_monitor_count(Register tmp) {
5634-
Address dst(rthread, JavaThread::held_monitor_count_offset());
5635-
#ifdef ASSERT
5636-
ldr(tmp, dst);
5637-
increment(tmp);
5638-
str(tmp, dst);
5639-
Label ok;
5640-
tbz(tmp, 63, ok);
5641-
STOP("assert(held monitor count underflow)");
5642-
should_not_reach_here();
5643-
bind(ok);
5644-
#else
5645-
increment(dst);
5646-
#endif
5647-
}
5648-
5649-
void MacroAssembler::dec_held_monitor_count(Register tmp) {
5650-
Address dst(rthread, JavaThread::held_monitor_count_offset());
5651-
#ifdef ASSERT
5652-
ldr(tmp, dst);
5653-
decrement(tmp);
5654-
str(tmp, dst);
5655-
Label ok;
5656-
tbz(tmp, 63, ok);
5657-
STOP("assert(held monitor count underflow)");
5658-
should_not_reach_here();
5659-
bind(ok);
5660-
#else
5661-
decrement(dst);
5662-
#endif
5663-
}
5664-
56655633
void MacroAssembler::verify_tlab() {
56665634
#ifdef ASSERT
56675635
if (UseTLAB && VerifyOops) {

src/hotspot/cpu/aarch64/macroAssembler_aarch64.hpp

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -983,9 +983,6 @@ class MacroAssembler: public Assembler {
983983
void push_cont_fastpath(Register java_thread = rthread);
984984
void pop_cont_fastpath(Register java_thread = rthread);
985985

986-
void inc_held_monitor_count(Register tmp);
987-
void dec_held_monitor_count(Register tmp);
988-
989986
// Round up to a power of two
990987
void round_to(Register reg, int modulus);
991988

src/hotspot/cpu/aarch64/sharedRuntime_aarch64.cpp

Lines changed: 0 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -985,11 +985,8 @@ static void fill_continuation_entry(MacroAssembler* masm) {
985985

986986
__ ldr(rscratch1, Address(rthread, JavaThread::cont_fastpath_offset()));
987987
__ str(rscratch1, Address(sp, ContinuationEntry::parent_cont_fastpath_offset()));
988-
__ ldr(rscratch1, Address(rthread, JavaThread::held_monitor_count_offset()));
989-
__ str(rscratch1, Address(sp, ContinuationEntry::parent_held_monitor_count_offset()));
990988

991989
__ str(zr, Address(rthread, JavaThread::cont_fastpath_offset()));
992-
__ str(zr, Address(rthread, JavaThread::held_monitor_count_offset()));
993990
}
994991

995992
// on entry, sp points to the ContinuationEntry
@@ -1005,50 +1002,6 @@ static void continuation_enter_cleanup(MacroAssembler* masm) {
10051002
#endif
10061003
__ ldr(rscratch1, Address(sp, ContinuationEntry::parent_cont_fastpath_offset()));
10071004
__ str(rscratch1, Address(rthread, JavaThread::cont_fastpath_offset()));
1008-
1009-
if (CheckJNICalls) {
1010-
// Check if this is a virtual thread continuation
1011-
Label L_skip_vthread_code;
1012-
__ ldrw(rscratch1, Address(sp, ContinuationEntry::flags_offset()));
1013-
__ cbzw(rscratch1, L_skip_vthread_code);
1014-
1015-
// If the held monitor count is > 0 and this vthread is terminating then
1016-
// it failed to release a JNI monitor. So we issue the same log message
1017-
// that JavaThread::exit does.
1018-
__ ldr(rscratch1, Address(rthread, JavaThread::jni_monitor_count_offset()));
1019-
__ cbz(rscratch1, L_skip_vthread_code);
1020-
1021-
// Save return value potentially containing the exception oop in callee-saved R19.
1022-
__ mov(r19, r0);
1023-
__ call_VM_leaf(CAST_FROM_FN_PTR(address, SharedRuntime::log_jni_monitor_still_held));
1024-
// Restore potential return value.
1025-
__ mov(r0, r19);
1026-
1027-
// For vthreads we have to explicitly zero the JNI monitor count of the carrier
1028-
// on termination. The held count is implicitly zeroed below when we restore from
1029-
// the parent held count (which has to be zero).
1030-
__ str(zr, Address(rthread, JavaThread::jni_monitor_count_offset()));
1031-
1032-
__ bind(L_skip_vthread_code);
1033-
}
1034-
#ifdef ASSERT
1035-
else {
1036-
// Check if this is a virtual thread continuation
1037-
Label L_skip_vthread_code;
1038-
__ ldrw(rscratch1, Address(sp, ContinuationEntry::flags_offset()));
1039-
__ cbzw(rscratch1, L_skip_vthread_code);
1040-
1041-
// See comment just above. If not checking JNI calls the JNI count is only
1042-
// needed for assertion checking.
1043-
__ str(zr, Address(rthread, JavaThread::jni_monitor_count_offset()));
1044-
1045-
__ bind(L_skip_vthread_code);
1046-
}
1047-
#endif
1048-
1049-
__ ldr(rscratch1, Address(sp, ContinuationEntry::parent_held_monitor_count_offset()));
1050-
__ str(rscratch1, Address(rthread, JavaThread::held_monitor_count_offset()));
1051-
10521005
__ ldr(rscratch2, Address(sp, ContinuationEntry::parent_offset()));
10531006
__ str(rscratch2, Address(rthread, JavaThread::cont_entry_offset()));
10541007
__ add(rfp, sp, (int)ContinuationEntry::size());

src/hotspot/cpu/ppc/globalDefinitions_ppc.hpp

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 1999, 2024, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 1999, 2025, Oracle and/or its affiliates. All rights reserved.
33
* Copyright (c) 2012, 2016 SAP SE. All rights reserved.
44
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
55
*
@@ -43,8 +43,6 @@ const bool CCallingConventionRequiresIntsAsLongs = true;
4343

4444
#define SUPPORTS_NATIVE_CX8
4545

46-
#define SUPPORT_MONITOR_COUNT
47-
4846
// PPC64 is not specified as multi-copy-atomic
4947
// So we must not #define CPU_MULTI_COPY_ATOMIC
5048

src/hotspot/cpu/ppc/sharedRuntime_ppc.cpp

Lines changed: 2 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -1639,7 +1639,6 @@ static void fill_continuation_entry(MacroAssembler* masm, Register reg_cont_obj,
16391639
assert_different_registers(reg_cont_obj, reg_flags);
16401640
Register zero = R8_ARG6;
16411641
Register tmp2 = R9_ARG7;
1642-
Register tmp3 = R10_ARG8;
16431642

16441643
DEBUG_ONLY(__ block_comment("fill {"));
16451644
#ifdef ASSERT
@@ -1655,12 +1654,9 @@ static void fill_continuation_entry(MacroAssembler* masm, Register reg_cont_obj,
16551654
__ stw(zero, in_bytes(ContinuationEntry::pin_count_offset()), R1_SP);
16561655

16571656
__ ld_ptr(tmp2, JavaThread::cont_fastpath_offset(), R16_thread);
1658-
__ ld(tmp3, in_bytes(JavaThread::held_monitor_count_offset()), R16_thread);
16591657
__ st_ptr(tmp2, ContinuationEntry::parent_cont_fastpath_offset(), R1_SP);
1660-
__ std(tmp3, in_bytes(ContinuationEntry::parent_held_monitor_count_offset()), R1_SP);
16611658

16621659
__ st_ptr(zero, JavaThread::cont_fastpath_offset(), R16_thread);
1663-
__ std(zero, in_bytes(JavaThread::held_monitor_count_offset()), R16_thread);
16641660
DEBUG_ONLY(__ block_comment("} fill"));
16651661
}
16661662

@@ -1681,7 +1677,6 @@ static void fill_continuation_entry(MacroAssembler* masm, Register reg_cont_obj,
16811677
static void continuation_enter_cleanup(MacroAssembler* masm) {
16821678
Register tmp1 = R8_ARG6;
16831679
Register tmp2 = R9_ARG7;
1684-
Register tmp3 = R10_ARG8;
16851680

16861681
#ifdef ASSERT
16871682
__ block_comment("clean {");
@@ -1692,57 +1687,8 @@ static void continuation_enter_cleanup(MacroAssembler* masm) {
16921687

16931688
__ ld_ptr(tmp1, ContinuationEntry::parent_cont_fastpath_offset(), R1_SP);
16941689
__ st_ptr(tmp1, JavaThread::cont_fastpath_offset(), R16_thread);
1695-
1696-
if (CheckJNICalls) {
1697-
// Check if this is a virtual thread continuation
1698-
Label L_skip_vthread_code;
1699-
__ lwz(R0, in_bytes(ContinuationEntry::flags_offset()), R1_SP);
1700-
__ cmpwi(CR0, R0, 0);
1701-
__ beq(CR0, L_skip_vthread_code);
1702-
1703-
// If the held monitor count is > 0 and this vthread is terminating then
1704-
// it failed to release a JNI monitor. So we issue the same log message
1705-
// that JavaThread::exit does.
1706-
__ ld(R0, in_bytes(JavaThread::jni_monitor_count_offset()), R16_thread);
1707-
__ cmpdi(CR0, R0, 0);
1708-
__ beq(CR0, L_skip_vthread_code);
1709-
1710-
// Save return value potentially containing the exception oop
1711-
Register ex_oop = R15_esp; // nonvolatile register
1712-
__ mr(ex_oop, R3_RET);
1713-
__ call_VM_leaf(CAST_FROM_FN_PTR(address, SharedRuntime::log_jni_monitor_still_held));
1714-
// Restore potental return value
1715-
__ mr(R3_RET, ex_oop);
1716-
1717-
// For vthreads we have to explicitly zero the JNI monitor count of the carrier
1718-
// on termination. The held count is implicitly zeroed below when we restore from
1719-
// the parent held count (which has to be zero).
1720-
__ li(tmp1, 0);
1721-
__ std(tmp1, in_bytes(JavaThread::jni_monitor_count_offset()), R16_thread);
1722-
1723-
__ bind(L_skip_vthread_code);
1724-
}
1725-
#ifdef ASSERT
1726-
else {
1727-
// Check if this is a virtual thread continuation
1728-
Label L_skip_vthread_code;
1729-
__ lwz(R0, in_bytes(ContinuationEntry::flags_offset()), R1_SP);
1730-
__ cmpwi(CR0, R0, 0);
1731-
__ beq(CR0, L_skip_vthread_code);
1732-
1733-
// See comment just above. If not checking JNI calls the JNI count is only
1734-
// needed for assertion checking.
1735-
__ li(tmp1, 0);
1736-
__ std(tmp1, in_bytes(JavaThread::jni_monitor_count_offset()), R16_thread);
1737-
1738-
__ bind(L_skip_vthread_code);
1739-
}
1740-
#endif
1741-
1742-
__ ld(tmp2, in_bytes(ContinuationEntry::parent_held_monitor_count_offset()), R1_SP);
1743-
__ ld_ptr(tmp3, ContinuationEntry::parent_offset(), R1_SP);
1744-
__ std(tmp2, in_bytes(JavaThread::held_monitor_count_offset()), R16_thread);
1745-
__ st_ptr(tmp3, JavaThread::cont_entry_offset(), R16_thread);
1690+
__ ld_ptr(tmp2, ContinuationEntry::parent_offset(), R1_SP);
1691+
__ st_ptr(tmp2, JavaThread::cont_entry_offset(), R16_thread);
17461692
DEBUG_ONLY(__ block_comment("} clean"));
17471693
}
17481694

src/hotspot/cpu/riscv/globalDefinitions_riscv.hpp

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 1999, 2024, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 1999, 2025, Oracle and/or its affiliates. All rights reserved.
33
* Copyright (c) 2014, 2015, Red Hat Inc. All rights reserved.
44
* Copyright (c) 2020, 2022, Huawei Technologies Co., Ltd. All rights reserved.
55
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
@@ -44,8 +44,6 @@ const bool CCallingConventionRequiresIntsAsLongs = false;
4444

4545
#define SUPPORTS_NATIVE_CX8
4646

47-
#define SUPPORT_MONITOR_COUNT
48-
4947
#define SUPPORT_RESERVED_STACK_AREA
5048

5149
#define USE_POINTERS_TO_REGISTER_IMPL_ARRAY

src/hotspot/cpu/riscv/macroAssembler_riscv.cpp

Lines changed: 0 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -225,36 +225,6 @@ void MacroAssembler::pop_cont_fastpath(Register java_thread) {
225225
bind(done);
226226
}
227227

228-
void MacroAssembler::inc_held_monitor_count(Register tmp) {
229-
Address dst(xthread, JavaThread::held_monitor_count_offset());
230-
ld(tmp, dst);
231-
addi(tmp, tmp, 1);
232-
sd(tmp, dst);
233-
#ifdef ASSERT
234-
Label ok;
235-
test_bit(tmp, tmp, 63);
236-
beqz(tmp, ok);
237-
STOP("assert(held monitor count overflow)");
238-
should_not_reach_here();
239-
bind(ok);
240-
#endif
241-
}
242-
243-
void MacroAssembler::dec_held_monitor_count(Register tmp) {
244-
Address dst(xthread, JavaThread::held_monitor_count_offset());
245-
ld(tmp, dst);
246-
subi(tmp, tmp, 1);
247-
sd(tmp, dst);
248-
#ifdef ASSERT
249-
Label ok;
250-
test_bit(tmp, tmp, 63);
251-
beqz(tmp, ok);
252-
STOP("assert(held monitor count underflow)");
253-
should_not_reach_here();
254-
bind(ok);
255-
#endif
256-
}
257-
258228
int MacroAssembler::align(int modulus, int extra_offset) {
259229
CompressibleScope scope(this);
260230
intptr_t before = offset();

src/hotspot/cpu/riscv/macroAssembler_riscv.hpp

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 1997, 2024, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 1997, 2025, Oracle and/or its affiliates. All rights reserved.
33
* Copyright (c) 2014, 2020, Red Hat Inc. All rights reserved.
44
* Copyright (c) 2020, 2024, Huawei Technologies Co., Ltd. All rights reserved.
55
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
@@ -849,9 +849,6 @@ class MacroAssembler: public Assembler {
849849
void push_cont_fastpath(Register java_thread = xthread);
850850
void pop_cont_fastpath(Register java_thread = xthread);
851851

852-
void inc_held_monitor_count(Register tmp);
853-
void dec_held_monitor_count(Register tmp);
854-
855852
// if heap base register is used - reinit it with the correct value
856853
void reinit_heapbase();
857854

src/hotspot/cpu/riscv/sharedRuntime_riscv.cpp

Lines changed: 0 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -885,11 +885,8 @@ static void fill_continuation_entry(MacroAssembler* masm) {
885885

886886
__ ld(t0, Address(xthread, JavaThread::cont_fastpath_offset()));
887887
__ sd(t0, Address(sp, ContinuationEntry::parent_cont_fastpath_offset()));
888-
__ ld(t0, Address(xthread, JavaThread::held_monitor_count_offset()));
889-
__ sd(t0, Address(sp, ContinuationEntry::parent_held_monitor_count_offset()));
890888

891889
__ sd(zr, Address(xthread, JavaThread::cont_fastpath_offset()));
892-
__ sd(zr, Address(xthread, JavaThread::held_monitor_count_offset()));
893890
}
894891

895892
// on entry, sp points to the ContinuationEntry
@@ -905,50 +902,6 @@ static void continuation_enter_cleanup(MacroAssembler* masm) {
905902

906903
__ ld(t0, Address(sp, ContinuationEntry::parent_cont_fastpath_offset()));
907904
__ sd(t0, Address(xthread, JavaThread::cont_fastpath_offset()));
908-
909-
if (CheckJNICalls) {
910-
// Check if this is a virtual thread continuation
911-
Label L_skip_vthread_code;
912-
__ lwu(t0, Address(sp, ContinuationEntry::flags_offset()));
913-
__ beqz(t0, L_skip_vthread_code);
914-
915-
// If the held monitor count is > 0 and this vthread is terminating then
916-
// it failed to release a JNI monitor. So we issue the same log message
917-
// that JavaThread::exit does.
918-
__ ld(t0, Address(xthread, JavaThread::jni_monitor_count_offset()));
919-
__ beqz(t0, L_skip_vthread_code);
920-
921-
// Save return value potentially containing the exception oop in callee-saved x9
922-
__ mv(x9, x10);
923-
__ call_VM_leaf(CAST_FROM_FN_PTR(address, SharedRuntime::log_jni_monitor_still_held));
924-
// Restore potential return value
925-
__ mv(x10, x9);
926-
927-
// For vthreads we have to explicitly zero the JNI monitor count of the carrier
928-
// on termination. The held count is implicitly zeroed below when we restore from
929-
// the parent held count (which has to be zero).
930-
__ sd(zr, Address(xthread, JavaThread::jni_monitor_count_offset()));
931-
932-
__ bind(L_skip_vthread_code);
933-
}
934-
#ifdef ASSERT
935-
else {
936-
// Check if this is a virtual thread continuation
937-
Label L_skip_vthread_code;
938-
__ lwu(t0, Address(sp, ContinuationEntry::flags_offset()));
939-
__ beqz(t0, L_skip_vthread_code);
940-
941-
// See comment just above. If not checking JNI calls the JNI count is only
942-
// needed for assertion checking.
943-
__ sd(zr, Address(xthread, JavaThread::jni_monitor_count_offset()));
944-
945-
__ bind(L_skip_vthread_code);
946-
}
947-
#endif
948-
949-
__ ld(t0, Address(sp, ContinuationEntry::parent_held_monitor_count_offset()));
950-
__ sd(t0, Address(xthread, JavaThread::held_monitor_count_offset()));
951-
952905
__ ld(t0, Address(sp, ContinuationEntry::parent_offset()));
953906
__ sd(t0, Address(xthread, JavaThread::cont_entry_offset()));
954907
__ add(fp, sp, (int)ContinuationEntry::size() + 2 * wordSize /* 2 extra words to match up with leave() */);

0 commit comments

Comments
 (0)