Skip to content

Commit c113f82

Browse files
committed
8343957: Rename ObjectMonitor::owner_from() and JavaThread::_lock_id
Reviewed-by: coleenp, dholmes
1 parent ea73e05 commit c113f82

File tree

19 files changed

+81
-83
lines changed

19 files changed

+81
-83
lines changed

src/hotspot/cpu/aarch64/c2_MacroAssembler_aarch64.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -206,8 +206,8 @@ void C2_MacroAssembler::fast_lock(Register objectReg, Register boxReg, Register
206206
// Handle existing monitor.
207207
bind(object_has_monitor);
208208

209-
// Try to CAS owner (no owner => current thread's _lock_id).
210-
ldr(rscratch2, Address(rthread, JavaThread::lock_id_offset()));
209+
// Try to CAS owner (no owner => current thread's _monitor_owner_id).
210+
ldr(rscratch2, Address(rthread, JavaThread::monitor_owner_id_offset()));
211211
add(tmp, disp_hdr, (in_bytes(ObjectMonitor::owner_offset())-markWord::monitor_value));
212212
cmpxchg(tmp, zr, rscratch2, Assembler::xword, /*acquire*/ true,
213213
/*release*/ true, /*weak*/ false, tmp3Reg); // Sets flags for result
@@ -469,8 +469,8 @@ void C2_MacroAssembler::fast_lock_lightweight(Register obj, Register box, Regist
469469
// Compute owner address.
470470
lea(t2_owner_addr, owner_address);
471471

472-
// Try to CAS owner (no owner => current thread's _lock_id).
473-
ldr(rscratch2, Address(rthread, JavaThread::lock_id_offset()));
472+
// Try to CAS owner (no owner => current thread's _monitor_owner_id).
473+
ldr(rscratch2, Address(rthread, JavaThread::monitor_owner_id_offset()));
474474
cmpxchg(t2_owner_addr, zr, rscratch2, Assembler::xword, /*acquire*/ true,
475475
/*release*/ false, /*weak*/ false, t3_owner);
476476
br(Assembler::EQ, monitor_locked);

src/hotspot/cpu/ppc/macroAssembler_ppc.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2664,10 +2664,10 @@ void MacroAssembler::compiler_fast_lock_object(ConditionRegister flag, Register
26642664
// Handle existing monitor.
26652665
bind(object_has_monitor);
26662666

2667-
// Try to CAS owner (no owner => current thread's _lock_id).
2667+
// Try to CAS owner (no owner => current thread's _monitor_owner_id).
26682668
addi(temp, displaced_header, in_bytes(ObjectMonitor::owner_offset()) - markWord::monitor_value);
26692669
Register thread_id = displaced_header;
2670-
ld(thread_id, in_bytes(JavaThread::lock_id_offset()), R16_thread);
2670+
ld(thread_id, in_bytes(JavaThread::monitor_owner_id_offset()), R16_thread);
26712671
cmpxchgd(/*flag=*/flag,
26722672
/*current_value=*/current_header,
26732673
/*compare_value=*/(intptr_t)0,
@@ -2944,9 +2944,9 @@ void MacroAssembler::compiler_fast_lock_lightweight_object(ConditionRegister fla
29442944
addi(owner_addr, monitor, in_bytes(ObjectMonitor::owner_offset()));
29452945
}
29462946

2947-
// Try to CAS owner (no owner => current thread's _lock_id).
2947+
// Try to CAS owner (no owner => current thread's _monitor_owner_id).
29482948
assert_different_registers(thread_id, monitor, owner_addr, box, R0);
2949-
ld(thread_id, in_bytes(JavaThread::lock_id_offset()), R16_thread);
2949+
ld(thread_id, in_bytes(JavaThread::monitor_owner_id_offset()), R16_thread);
29502950
cmpxchgd(/*flag=*/CCR0,
29512951
/*current_value=*/R0,
29522952
/*compare_value=*/(intptr_t)0,

src/hotspot/cpu/riscv/c2_MacroAssembler_riscv.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -116,10 +116,10 @@ void C2_MacroAssembler::fast_lock(Register objectReg, Register boxReg,
116116
// Handle existing monitor.
117117
bind(object_has_monitor);
118118

119-
// Try to CAS owner (no owner => current thread's _lock_id).
119+
// Try to CAS owner (no owner => current thread's _monitor_owner_id).
120120
add(tmp, disp_hdr, (in_bytes(ObjectMonitor::owner_offset()) - markWord::monitor_value));
121121
Register tid = tmp4Reg;
122-
ld(tid, Address(xthread, JavaThread::lock_id_offset()));
122+
ld(tid, Address(xthread, JavaThread::monitor_owner_id_offset()));
123123
cmpxchg(/*memory address*/tmp, /*expected value*/zr, /*new value*/tid, Assembler::int64,
124124
Assembler::aq, Assembler::rl, /*result*/tmp3Reg); // cas succeeds if tmp3Reg == zr(expected)
125125

@@ -400,9 +400,9 @@ void C2_MacroAssembler::fast_lock_lightweight(Register obj, Register box,
400400
// Compute owner address.
401401
la(tmp2_owner_addr, owner_address);
402402

403-
// Try to CAS owner (no owner => current thread's _lock_id).
403+
// Try to CAS owner (no owner => current thread's _monitor_owner_id).
404404
Register tid = tmp4;
405-
ld(tid, Address(xthread, JavaThread::lock_id_offset()));
405+
ld(tid, Address(xthread, JavaThread::monitor_owner_id_offset()));
406406
cmpxchg(/*addr*/ tmp2_owner_addr, /*expected*/ zr, /*new*/ tid, Assembler::int64,
407407
/*acquire*/ Assembler::aq, /*release*/ Assembler::relaxed, /*result*/ tmp3_owner);
408408
beqz(tmp3_owner, monitor_locked);

src/hotspot/cpu/s390/macroAssembler_s390.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3825,11 +3825,11 @@ void MacroAssembler::compiler_fast_lock_object(Register oop, Register box, Regis
38253825
Register zero = temp;
38263826
Register monitor_tagged = displacedHeader; // Tagged with markWord::monitor_value.
38273827

3828-
// Try to CAS owner (no owner => current thread's _lock_id).
3828+
// Try to CAS owner (no owner => current thread's _monitor_owner_id).
38293829
// If csg succeeds then CR=EQ, otherwise, register zero is filled
38303830
// with the current owner.
38313831
z_lghi(zero, 0);
3832-
z_lg(Z_R0_scratch, Address(Z_thread, JavaThread::lock_id_offset()));
3832+
z_lg(Z_R0_scratch, Address(Z_thread, JavaThread::monitor_owner_id_offset()));
38333833
z_csg(zero, Z_R0_scratch, OM_OFFSET_NO_MONITOR_VALUE_TAG(owner), monitor_tagged);
38343834

38353835
// Store a non-null value into the box.
@@ -3904,7 +3904,7 @@ void MacroAssembler::compiler_fast_unlock_object(Register oop, Register box, Reg
39043904
// Handle existing monitor.
39053905
bind(object_has_monitor);
39063906

3907-
z_lg(Z_R0_scratch, Address(Z_thread, JavaThread::lock_id_offset()));
3907+
z_lg(Z_R0_scratch, Address(Z_thread, JavaThread::monitor_owner_id_offset()));
39083908
z_cg(Z_R0_scratch, Address(currentHeader, OM_OFFSET_NO_MONITOR_VALUE_TAG(owner)));
39093909
z_brne(done);
39103910

@@ -6608,11 +6608,11 @@ void MacroAssembler::compiler_fast_lock_lightweight_object(Register obj, Registe
66086608
const Address recursions_address(tmp1_monitor, ObjectMonitor::recursions_offset() - monitor_tag);
66096609

66106610

6611-
// Try to CAS owner (no owner => current thread's _lock_id).
6611+
// Try to CAS owner (no owner => current thread's _monitor_owner_id).
66126612
// If csg succeeds then CR=EQ, otherwise, register zero is filled
66136613
// with the current owner.
66146614
z_lghi(zero, 0);
6615-
z_lg(Z_R0_scratch, Address(Z_thread, JavaThread::lock_id_offset()));
6615+
z_lg(Z_R0_scratch, Address(Z_thread, JavaThread::monitor_owner_id_offset()));
66166616
z_csg(zero, Z_R0_scratch, owner_address);
66176617
z_bre(monitor_locked);
66186618

src/hotspot/cpu/x86/c2_MacroAssembler_x86.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -319,7 +319,7 @@ void C2_MacroAssembler::fast_lock(Register objReg, Register boxReg, Register tmp
319319
movptr(Address(boxReg, 0), checked_cast<int32_t>(markWord::unused_mark().value()));
320320

321321
// It's inflated and we use scrReg for ObjectMonitor* in this section.
322-
movptr(boxReg, Address(r15_thread, JavaThread::lock_id_offset()));
322+
movptr(boxReg, Address(r15_thread, JavaThread::monitor_owner_id_offset()));
323323
movq(scrReg, tmpReg);
324324
xorq(tmpReg, tmpReg);
325325
lock();
@@ -625,9 +625,9 @@ void C2_MacroAssembler::fast_lock_lightweight(Register obj, Register box, Regist
625625
movptr(Address(box, BasicLock::object_monitor_cache_offset_in_bytes()), monitor);
626626
}
627627

628-
// Try to CAS owner (no owner => current thread's _lock_id).
628+
// Try to CAS owner (no owner => current thread's _monitor_owner_id).
629629
xorptr(rax_reg, rax_reg);
630-
movptr(box, Address(thread, JavaThread::lock_id_offset()));
630+
movptr(box, Address(thread, JavaThread::monitor_owner_id_offset()));
631631
lock(); cmpxchgptr(box, owner_address);
632632
jccb(Assembler::equal, monitor_locked);
633633

src/hotspot/share/jvmci/vmStructs_jvmci.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -227,7 +227,7 @@
227227
nonstatic_field(JavaThread, _vthread, OopHandle) \
228228
nonstatic_field(JavaThread, _scopedValueCache, OopHandle) \
229229
nonstatic_field(JavaThread, _anchor, JavaFrameAnchor) \
230-
nonstatic_field(JavaThread, _lock_id, int64_t) \
230+
nonstatic_field(JavaThread, _monitor_owner_id, int64_t) \
231231
nonstatic_field(JavaThread, _vm_result, oop) \
232232
nonstatic_field(JavaThread, _stack_overflow_state._stack_overflow_limit, address) \
233233
volatile_nonstatic_field(JavaThread, _exception_oop, oop) \

src/hotspot/share/opto/library_call.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3682,10 +3682,10 @@ bool LibraryCallKit::inline_native_setCurrentThread() {
36823682
const TypePtr *adr_type = _gvn.type(thread_obj_handle)->isa_ptr();
36833683
access_store_at(nullptr, thread_obj_handle, adr_type, arr, _gvn.type(arr), T_OBJECT, IN_NATIVE | MO_UNORDERED);
36843684

3685-
// Change the lock_id of the JavaThread
3685+
// Change the _monitor_owner_id of the JavaThread
36863686
Node* tid = load_field_from_object(arr, "tid", "J");
3687-
Node* thread_id_offset = basic_plus_adr(thread, in_bytes(JavaThread::lock_id_offset()));
3688-
Node* tid_memory = store_to_memory(control(), thread_id_offset, tid, T_LONG, MemNode::unordered, true);
3687+
Node* monitor_owner_id_offset = basic_plus_adr(thread, in_bytes(JavaThread::monitor_owner_id_offset()));
3688+
store_to_memory(control(), monitor_owner_id_offset, tid, T_LONG, MemNode::unordered, true);
36893689

36903690
JFR_ONLY(extend_setCurrentThread(thread, arr);)
36913691
return true;

src/hotspot/share/prims/jvm.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2977,8 +2977,8 @@ JVM_ENTRY(void, JVM_SetCurrentThread(JNIEnv* env, jobject thisThread,
29772977
oop threadObj = JNIHandles::resolve(theThread);
29782978
thread->set_vthread(threadObj);
29792979

2980-
// Set lock id of new current Thread
2981-
thread->set_lock_id(java_lang_Thread::thread_id(threadObj));
2980+
// Set _monitor_owner_id of new current Thread
2981+
thread->set_monitor_owner_id(java_lang_Thread::thread_id(threadObj));
29822982

29832983
JFR_ONLY(Jfr::on_set_current_thread(thread, threadObj);)
29842984
JVM_END

src/hotspot/share/runtime/javaThread.cpp

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -236,8 +236,8 @@ void JavaThread::allocate_threadObj(Handle thread_group, const char* thread_name
236236
// constructor calls Thread.current(), which must be set here.
237237
java_lang_Thread::set_thread(thread_oop(), this);
238238
set_threadOopHandles(thread_oop());
239-
// Set the lock_id to the next thread_id temporarily while initialization runs.
240-
set_lock_id(ThreadIdentifier::next());
239+
// Set the _monitor_owner_id to the next thread_id temporarily while initialization runs.
240+
set_monitor_owner_id(ThreadIdentifier::next());
241241

242242
JavaValue result(T_VOID);
243243
if (thread_name != nullptr) {
@@ -263,8 +263,8 @@ void JavaThread::allocate_threadObj(Handle thread_group, const char* thread_name
263263
Handle(),
264264
CHECK);
265265
}
266-
// Update the lock_id with the tid value.
267-
set_lock_id(java_lang_Thread::thread_id(thread_oop()));
266+
// Update the _monitor_owner_id with the tid value.
267+
set_monitor_owner_id(java_lang_Thread::thread_id(thread_oop()));
268268

269269
os::set_priority(this, NormPriority);
270270

@@ -435,7 +435,7 @@ JavaThread::JavaThread(MemTag mem_tag) :
435435
_current_waiting_monitor(nullptr),
436436
_active_handles(nullptr),
437437
_free_handle_block(nullptr),
438-
_lock_id(0),
438+
_monitor_owner_id(0),
439439

440440
_suspend_flags(0),
441441

@@ -1544,8 +1544,7 @@ void JavaThread::print_on(outputStream *st, bool print_extended_info) const {
15441544
st->print_cr("[" INTPTR_FORMAT "]", (intptr_t)last_Java_sp() & ~right_n_bits(12));
15451545
if (thread_oop != nullptr) {
15461546
if (is_vthread_mounted()) {
1547-
// _lock_id is the thread ID of the mounted virtual thread
1548-
st->print_cr(" Carrying virtual thread #" INT64_FORMAT, lock_id());
1547+
st->print_cr(" Carrying virtual thread #" INT64_FORMAT, java_lang_Thread::thread_id(vthread()));
15491548
} else {
15501549
st->print_cr(" java.lang.Thread.State: %s", java_lang_Thread::thread_status_name(thread_oop));
15511550
}
@@ -1729,7 +1728,7 @@ void JavaThread::prepare(jobject jni_thread, ThreadPriority prio) {
17291728
assert(InstanceKlass::cast(thread_oop->klass())->is_linked(),
17301729
"must be initialized");
17311730
set_threadOopHandles(thread_oop());
1732-
set_lock_id(java_lang_Thread::thread_id(thread_oop()));
1731+
set_monitor_owner_id(java_lang_Thread::thread_id(thread_oop()));
17331732

17341733
if (prio == NoPriority) {
17351734
prio = java_lang_Thread::priority(thread_oop());
@@ -2234,7 +2233,7 @@ void JavaThread::start_internal_daemon(JavaThread* current, JavaThread* target,
22342233

22352234
// Now bind the thread_oop to the target JavaThread.
22362235
target->set_threadOopHandles(thread_oop());
2237-
target->set_lock_id(java_lang_Thread::thread_id(thread_oop()));
2236+
target->set_monitor_owner_id(java_lang_Thread::thread_id(thread_oop()));
22382237

22392238
Threads::add(target); // target is now visible for safepoint/handshake
22402239
// Publish the JavaThread* in java.lang.Thread after the JavaThread* is

src/hotspot/share/runtime/javaThread.hpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -166,14 +166,14 @@ class JavaThread: public Thread {
166166
// ID used as owner for inflated monitors. Same as the j.l.Thread.tid of the
167167
// current _vthread object, except during creation of the primordial and JNI
168168
// attached thread cases where this field can have a temporary value.
169-
int64_t _lock_id;
169+
int64_t _monitor_owner_id;
170170

171171
public:
172-
void set_lock_id(int64_t tid) {
173-
assert(tid >= ThreadIdentifier::initial() && tid < ThreadIdentifier::current(), "invalid tid");
174-
_lock_id = tid;
172+
void set_monitor_owner_id(int64_t id) {
173+
assert(id >= ThreadIdentifier::initial() && id < ThreadIdentifier::current(), "");
174+
_monitor_owner_id = id;
175175
}
176-
int64_t lock_id() const { return _lock_id; }
176+
int64_t monitor_owner_id() const { return _monitor_owner_id; }
177177

178178
// For tracking the heavyweight monitor the thread is pending on.
179179
ObjectMonitor* current_pending_monitor() {
@@ -884,7 +884,7 @@ class JavaThread: public Thread {
884884
static ByteSize doing_unsafe_access_offset() { return byte_offset_of(JavaThread, _doing_unsafe_access); }
885885
NOT_PRODUCT(static ByteSize requires_cross_modify_fence_offset() { return byte_offset_of(JavaThread, _requires_cross_modify_fence); })
886886

887-
static ByteSize lock_id_offset() { return byte_offset_of(JavaThread, _lock_id); }
887+
static ByteSize monitor_owner_id_offset() { return byte_offset_of(JavaThread, _monitor_owner_id); }
888888

889889
static ByteSize cont_entry_offset() { return byte_offset_of(JavaThread, _cont_entry); }
890890
static ByteSize cont_fastpath_offset() { return byte_offset_of(JavaThread, _cont_fastpath); }

0 commit comments

Comments
 (0)