Skip to content

Commit a272696

Browse files
committed
8365190: Remove LockingMode related code from share
Reviewed-by: aboldtch, dholmes, ayang, coleenp, lmesnik, rcastanedalo
1 parent 5e423e0 commit a272696

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

50 files changed

+140
-1269
lines changed

src/hotspot/cpu/zero/zeroInterpreter_zero.cpp

Lines changed: 4 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -331,26 +331,9 @@ int ZeroInterpreter::native_entry(Method* method, intptr_t UNUSED, TRAPS) {
331331
monitor = nullptr;
332332
if (method->is_synchronized()) {
333333
monitor = (BasicObjectLock*) istate->stack_base();
334-
oop lockee = monitor->obj();
335-
bool success = false;
336-
if (LockingMode == LM_LEGACY) {
337-
markWord disp = lockee->mark().set_unlocked();
338-
monitor->lock()->set_displaced_header(disp);
339-
success = true;
340-
if (lockee->cas_set_mark(markWord::from_pointer(monitor), disp) != disp) {
341-
// Is it simple recursive case?
342-
if (thread->is_lock_owned((address) disp.clear_lock_bits().to_pointer())) {
343-
monitor->lock()->set_displaced_header(markWord::from_pointer(nullptr));
344-
} else {
345-
success = false;
346-
}
347-
}
348-
}
349-
if (!success) {
350-
CALL_VM_NOCHECK(InterpreterRuntime::monitorenter(thread, monitor));
351-
if (HAS_PENDING_EXCEPTION)
352-
goto unwind_and_return;
353-
}
334+
CALL_VM_NOCHECK(InterpreterRuntime::monitorenter(thread, monitor));
335+
if (HAS_PENDING_EXCEPTION)
336+
goto unwind_and_return;
354337
}
355338

356339
// Get the signature handler
@@ -481,24 +464,7 @@ int ZeroInterpreter::native_entry(Method* method, intptr_t UNUSED, TRAPS) {
481464

482465
// Unlock if necessary
483466
if (monitor) {
484-
bool success = false;
485-
if (LockingMode == LM_LEGACY) {
486-
BasicLock* lock = monitor->lock();
487-
oop rcvr = monitor->obj();
488-
monitor->set_obj(nullptr);
489-
success = true;
490-
markWord header = lock->displaced_header();
491-
if (header.to_pointer() != nullptr) { // Check for recursive lock
492-
markWord old_header = markWord::encode(lock);
493-
if (rcvr->cas_set_mark(header, old_header) != old_header) {
494-
monitor->set_obj(rcvr);
495-
success = false;
496-
}
497-
}
498-
}
499-
if (!success) {
500-
InterpreterRuntime::monitorexit(monitor);
501-
}
467+
InterpreterRuntime::monitorexit(monitor);
502468
}
503469

504470
unwind_and_return:

src/hotspot/share/c1/c1_LIRGenerator.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -635,7 +635,7 @@ void LIRGenerator::monitor_exit(LIR_Opr object, LIR_Opr lock, LIR_Opr new_hdr, L
635635
// setup registers
636636
LIR_Opr hdr = lock;
637637
lock = new_hdr;
638-
CodeStub* slow_path = new MonitorExitStub(lock, LockingMode != LM_MONITOR, monitor_no);
638+
CodeStub* slow_path = new MonitorExitStub(lock, true, monitor_no);
639639
__ load_stack_address_monitor(monitor_no, lock);
640640
__ unlock_object(hdr, object, lock, scratch, slow_path);
641641
}

src/hotspot/share/c1/c1_Runtime1.cpp

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -778,9 +778,6 @@ JRT_BLOCK_ENTRY(void, Runtime1::monitorenter(JavaThread* current, oopDesc* obj,
778778
_monitorenter_slowcase_cnt++;
779779
}
780780
#endif
781-
if (LockingMode == LM_MONITOR) {
782-
lock->set_obj(obj);
783-
}
784781
assert(obj == lock->obj(), "must match");
785782
SharedRuntime::monitor_enter_helper(obj, lock->lock(), current);
786783
JRT_END

src/hotspot/share/gc/g1/g1BarrierSet.inline.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2016, 2024, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2016, 2025, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -37,7 +37,7 @@
3737

3838
inline void G1BarrierSet::enqueue_preloaded(oop pre_val) {
3939
// Nulls should have been already filtered.
40-
assert(oopDesc::is_oop(pre_val, true), "Error");
40+
assert(oopDesc::is_oop(pre_val), "Error");
4141

4242
G1SATBMarkQueueSet& queue_set = G1BarrierSet::satb_mark_queue_set();
4343
if (!queue_set.is_active()) return;

src/hotspot/share/gc/g1/g1BarrierSetRuntime.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ void G1BarrierSetRuntime::write_ref_array_post_entry(HeapWord* dst, size_t lengt
4747
JRT_LEAF(void, G1BarrierSetRuntime::write_ref_field_pre_entry(oopDesc* orig, JavaThread* thread))
4848
assert(thread == JavaThread::current(), "pre-condition");
4949
assert(orig != nullptr, "should be optimized out");
50-
assert(oopDesc::is_oop(orig, true /* ignore mark word */), "Error");
50+
assert(oopDesc::is_oop(orig), "Error");
5151
// store the original value that was in the field reference
5252
SATBMarkQueue& queue = G1ThreadLocalData::satb_mark_queue(thread);
5353
G1BarrierSet::satb_mark_queue_set().enqueue_known_active(queue, orig);

src/hotspot/share/gc/g1/g1HeapRegion.inline.hpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2001, 2024, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2001, 2025, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -350,7 +350,7 @@ inline HeapWord* G1HeapRegion::oops_on_memregion_iterate_in_unparsable(MemRegion
350350
assert(bitmap->is_marked(cur), "inv");
351351

352352
oop obj = cast_to_oop(cur);
353-
assert(oopDesc::is_oop(obj, true), "Not an oop at " PTR_FORMAT, p2i(cur));
353+
assert(oopDesc::is_oop(obj), "Not an oop at " PTR_FORMAT, p2i(cur));
354354

355355
cur += obj->size();
356356
bool is_precise;
@@ -418,7 +418,7 @@ inline HeapWord* G1HeapRegion::oops_on_memregion_iterate(MemRegion mr, Closure*
418418
// All objects >= pb are parsable. So we can just take object sizes directly.
419419
while (true) {
420420
oop obj = cast_to_oop(cur);
421-
assert(oopDesc::is_oop(obj, true), "Not an oop at " PTR_FORMAT, p2i(cur));
421+
assert(oopDesc::is_oop(obj), "Not an oop at " PTR_FORMAT, p2i(cur));
422422

423423
bool is_precise = false;
424424

src/hotspot/share/gc/g1/g1SATBMarkQueueSet.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ static inline bool requires_marking(const void* entry, G1CollectedHeap* g1h) {
8989
return false;
9090
}
9191

92-
assert(oopDesc::is_oop(cast_to_oop(entry), true /* ignore mark word */),
92+
assert(oopDesc::is_oop(cast_to_oop(entry)),
9393
"Invalid oop in SATB buffer: " PTR_FORMAT, p2i(entry));
9494

9595
return true;

src/hotspot/share/gc/shared/cardTableBarrierSet.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,7 @@ void CardTableBarrierSet::flush_deferred_card_mark_barrier(JavaThread* thread) {
162162
DEBUG_ONLY(oop old_obj = cast_to_oop(deferred.start());)
163163
assert(!_card_table->is_in_young(old_obj),
164164
"Else should have been filtered in on_slowpath_allocation_exit()");
165-
assert(oopDesc::is_oop(old_obj, true), "Not an oop");
165+
assert(oopDesc::is_oop(old_obj), "Not an oop");
166166
assert(deferred.word_size() == old_obj->size(),
167167
"Mismatch: multiple objects?");
168168
}

src/hotspot/share/gc/shenandoah/shenandoahHeap.inline.hpp

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -312,11 +312,6 @@ void ShenandoahHeap::increase_object_age(oop obj, uint additional_age) {
312312
// For all these reasons, we take the conservative approach and not attempt
313313
// to increase the age when the header is displaced.
314314
markWord w = obj->mark();
315-
// The mark-word has been copied from the original object. It can not be
316-
// inflating, because inflation can not be interrupted by a safepoint,
317-
// and after a safepoint, a Java thread would first have to successfully
318-
// evacuate the object before it could inflate the monitor.
319-
assert(!w.is_being_inflated() || LockingMode == LM_LIGHTWEIGHT, "must not inflate monitor before evacuation of object succeeds");
320315
// It is possible that we have copied the object after another thread has
321316
// already successfully completed evacuation. While harmless (we would never
322317
// publish our copy), don't even attempt to modify the age when that
@@ -334,7 +329,6 @@ uint ShenandoahHeap::get_object_age(oop obj) {
334329
markWord w = obj->mark();
335330
assert(!w.is_marked(), "must not be forwarded");
336331
if (UseObjectMonitorTable) {
337-
assert(LockingMode == LM_LIGHTWEIGHT, "Must use LW locking, too");
338332
assert(w.age() <= markWord::max_age, "Impossible!");
339333
return w.age();
340334
}

src/hotspot/share/interpreter/zero/bytecodeInterpreter.cpp

Lines changed: 6 additions & 121 deletions
Original file line numberDiff line numberDiff line change
@@ -624,26 +624,7 @@ void BytecodeInterpreter::run(interpreterState istate) {
624624
// The initial monitor is ours for the taking.
625625
BasicObjectLock* mon = &istate->monitor_base()[-1];
626626
mon->set_obj(rcvr);
627-
628-
bool success = false;
629-
if (LockingMode == LM_LEGACY) {
630-
// Traditional fast locking.
631-
markWord displaced = rcvr->mark().set_unlocked();
632-
mon->lock()->set_displaced_header(displaced);
633-
success = true;
634-
if (rcvr->cas_set_mark(markWord::from_pointer(mon), displaced) != displaced) {
635-
// Is it simple recursive case?
636-
if (THREAD->is_lock_owned((address) displaced.clear_lock_bits().to_pointer())) {
637-
mon->lock()->set_displaced_header(markWord::from_pointer(nullptr));
638-
} else {
639-
success = false;
640-
}
641-
}
642-
}
643-
if (!success) {
644-
CALL_VM(InterpreterRuntime::monitorenter(THREAD, mon), handle_exception);
645-
}
646-
627+
CALL_VM(InterpreterRuntime::monitorenter(THREAD, mon), handle_exception);
647628
}
648629
THREAD->set_do_not_unlock_if_synchronized(false);
649630

@@ -725,26 +706,7 @@ void BytecodeInterpreter::run(interpreterState istate) {
725706
BasicObjectLock* entry = (BasicObjectLock*) istate->stack_base();
726707
assert(entry->obj() == nullptr, "Frame manager didn't allocate the monitor");
727708
entry->set_obj(lockee);
728-
729-
bool success = false;
730-
if (LockingMode == LM_LEGACY) {
731-
// Traditional fast locking.
732-
markWord displaced = lockee->mark().set_unlocked();
733-
entry->lock()->set_displaced_header(displaced);
734-
success = true;
735-
if (lockee->cas_set_mark(markWord::from_pointer(entry), displaced) != displaced) {
736-
// Is it simple recursive case?
737-
if (THREAD->is_lock_owned((address) displaced.clear_lock_bits().to_pointer())) {
738-
entry->lock()->set_displaced_header(markWord::from_pointer(nullptr));
739-
} else {
740-
success = false;
741-
}
742-
}
743-
}
744-
if (!success) {
745-
CALL_VM(InterpreterRuntime::monitorenter(THREAD, entry), handle_exception);
746-
}
747-
709+
CALL_VM(InterpreterRuntime::monitorenter(THREAD, entry), handle_exception);
748710
UPDATE_PC_AND_TOS(1, -1);
749711
goto run;
750712
}
@@ -1657,26 +1619,7 @@ void BytecodeInterpreter::run(interpreterState istate) {
16571619
}
16581620
if (entry != nullptr) {
16591621
entry->set_obj(lockee);
1660-
1661-
bool success = false;
1662-
if (LockingMode == LM_LEGACY) {
1663-
// Traditional fast locking.
1664-
markWord displaced = lockee->mark().set_unlocked();
1665-
entry->lock()->set_displaced_header(displaced);
1666-
success = true;
1667-
if (lockee->cas_set_mark(markWord::from_pointer(entry), displaced) != displaced) {
1668-
// Is it simple recursive case?
1669-
if (THREAD->is_lock_owned((address) displaced.clear_lock_bits().to_pointer())) {
1670-
entry->lock()->set_displaced_header(markWord::from_pointer(nullptr));
1671-
} else {
1672-
success = false;
1673-
}
1674-
}
1675-
}
1676-
if (!success) {
1677-
CALL_VM(InterpreterRuntime::monitorenter(THREAD, entry), handle_exception);
1678-
}
1679-
1622+
CALL_VM(InterpreterRuntime::monitorenter(THREAD, entry), handle_exception);
16801623
UPDATE_PC_AND_TOS_AND_CONTINUE(1, -1);
16811624
} else {
16821625
istate->set_msg(more_monitors);
@@ -1694,25 +1637,7 @@ void BytecodeInterpreter::run(interpreterState istate) {
16941637
while (most_recent != limit ) {
16951638
if ((most_recent)->obj() == lockee) {
16961639
BasicLock* lock = most_recent->lock();
1697-
1698-
bool success = false;
1699-
if (LockingMode == LM_LEGACY) {
1700-
// If it isn't recursive we either must swap old header or call the runtime
1701-
most_recent->set_obj(nullptr);
1702-
success = true;
1703-
markWord header = lock->displaced_header();
1704-
if (header.to_pointer() != nullptr) {
1705-
markWord old_header = markWord::encode(lock);
1706-
if (lockee->cas_set_mark(header, old_header) != old_header) {
1707-
// restore object for the slow case
1708-
most_recent->set_obj(lockee);
1709-
success = false;
1710-
}
1711-
}
1712-
}
1713-
if (!success) {
1714-
InterpreterRuntime::monitorexit(most_recent);
1715-
}
1640+
InterpreterRuntime::monitorexit(most_recent);
17161641
UPDATE_PC_AND_TOS_AND_CONTINUE(1, -1);
17171642
}
17181643
most_recent++;
@@ -3137,27 +3062,7 @@ void BytecodeInterpreter::run(interpreterState istate) {
31373062
while (end < base) {
31383063
oop lockee = end->obj();
31393064
if (lockee != nullptr) {
3140-
BasicLock* lock = end->lock();
3141-
3142-
bool success = false;
3143-
if (LockingMode == LM_LEGACY) {
3144-
markWord header = lock->displaced_header();
3145-
end->set_obj(nullptr);
3146-
3147-
// If it isn't recursive we either must swap old header or call the runtime
3148-
success = true;
3149-
if (header.to_pointer() != nullptr) {
3150-
markWord old_header = markWord::encode(lock);
3151-
if (lockee->cas_set_mark(header, old_header) != old_header) {
3152-
// restore object for the slow case
3153-
end->set_obj(lockee);
3154-
success = false;
3155-
}
3156-
}
3157-
}
3158-
if (!success) {
3159-
InterpreterRuntime::monitorexit(end);
3160-
}
3065+
InterpreterRuntime::monitorexit(end);
31613066

31623067
// One error is plenty
31633068
if (illegal_state_oop() == nullptr && !suppress_error) {
@@ -3204,32 +3109,12 @@ void BytecodeInterpreter::run(interpreterState istate) {
32043109
illegal_state_oop = Handle(THREAD, THREAD->pending_exception());
32053110
THREAD->clear_pending_exception();
32063111
}
3207-
} else if (LockingMode != LM_LEGACY) {
3112+
} else {
32083113
InterpreterRuntime::monitorexit(base);
32093114
if (THREAD->has_pending_exception()) {
32103115
if (!suppress_error) illegal_state_oop = Handle(THREAD, THREAD->pending_exception());
32113116
THREAD->clear_pending_exception();
32123117
}
3213-
} else {
3214-
BasicLock* lock = base->lock();
3215-
markWord header = lock->displaced_header();
3216-
base->set_obj(nullptr);
3217-
3218-
// If it isn't recursive we either must swap old header or call the runtime
3219-
bool dec_monitor_count = true;
3220-
if (header.to_pointer() != nullptr) {
3221-
markWord old_header = markWord::encode(lock);
3222-
if (rcvr->cas_set_mark(header, old_header) != old_header) {
3223-
// restore object for the slow case
3224-
base->set_obj(rcvr);
3225-
dec_monitor_count = false;
3226-
InterpreterRuntime::monitorexit(base);
3227-
if (THREAD->has_pending_exception()) {
3228-
if (!suppress_error) illegal_state_oop = Handle(THREAD, THREAD->pending_exception());
3229-
THREAD->clear_pending_exception();
3230-
}
3231-
}
3232-
}
32333118
}
32343119
}
32353120
}

0 commit comments

Comments
 (0)