Skip to content

Commit 13353fd

Browse files
committed
Remove ObjectMonitor::set_owner_from_BasicLock()
1 parent 03ba6df commit 13353fd

File tree

4 files changed

+5
-40
lines changed

4 files changed

+5
-40
lines changed

src/hotspot/share/runtime/objectMonitor.cpp

Lines changed: 3 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1536,23 +1536,12 @@ void ObjectMonitor::ExitEpilog(JavaThread* current, ObjectWaiter* Wakee) {
15361536
OM_PERFDATA_OP(Parks, inc());
15371537
}
15381538

1539-
// complete_exit exits a lock returning recursion count
1540-
// complete_exit requires an inflated monitor
1541-
// The _owner field is not always the Thread addr even with an
1542-
// inflated monitor, e.g. the monitor can be inflated by a non-owning
1543-
// thread due to contention.
1539+
// Exits the monitor returning recursion count. _owner should
1540+
// be set to current's tid, i.e. no ANONYMOUS_OWNER allowed.
15441541
intx ObjectMonitor::complete_exit(JavaThread* current) {
15451542
assert(InitDone, "Unexpectedly not initialized");
1546-
1547-
if (!has_owner(current)) {
1548-
if (LockingMode == LM_LEGACY && has_stack_locker(current)) {
1549-
assert(_recursions == 0, "internal state error");
1550-
set_owner_from_BasicLock(current); // Convert from BasicLock* to Thread*.
1551-
_recursions = 0;
1552-
}
1553-
}
1554-
15551543
guarantee(has_owner(current), "complete_exit not owner");
1544+
15561545
intx save = _recursions; // record the old recursion count
15571546
_recursions = 0; // set the recursion level to be 0
15581547
exit(current); // exit the monitor

src/hotspot/share/runtime/objectMonitor.hpp

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -298,8 +298,6 @@ class ObjectMonitor : public CHeapObj<mtObjectMonitor> {
298298
void set_owner_from_raw(int64_t old_value, int64_t new_value);
299299
// Same as above but uses tid of current as new value.
300300
void set_owner_from(int64_t old_value, JavaThread* current);
301-
// Set _owner field to tid of current thread; current value must be ANONYMOUS_OWNER.
302-
void set_owner_from_BasicLock(JavaThread* current);
303301
// Try to set _owner field to new_value if the current value matches
304302
// old_value, using Atomic::cmpxchg(). Otherwise, does not change the
305303
// _owner field. Returns the prior value of the _owner field.
@@ -330,9 +328,6 @@ class ObjectMonitor : public CHeapObj<mtObjectMonitor> {
330328
set_owner_from(ANONYMOUS_OWNER, owner);
331329
}
332330

333-
// Returns true if BasicLock* stored in _stack_locker
334-
// points to current's stack, false otherwise.
335-
bool has_stack_locker(JavaThread* current);
336331
// Get and set _stack_locker.
337332
BasicLock* stack_locker() const;
338333
void set_stack_locker(BasicLock* locker);

src/hotspot/share/runtime/objectMonitor.inline.hpp

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -125,10 +125,6 @@ inline void ObjectMonitor::set_stack_locker(BasicLock* locker) {
125125
Atomic::store(&_stack_locker, locker);
126126
}
127127

128-
inline bool ObjectMonitor::has_stack_locker(JavaThread* current) {
129-
return has_owner_anonymous() && current->is_lock_owned((address)stack_locker());
130-
}
131-
132128
// Returns true if owner field == DEFLATER_MARKER and false otherwise.
133129
// This accessor is called when we really need to know if the owner
134130
// field == DEFLATER_MARKER and any non-null value won't do the trick.
@@ -191,22 +187,6 @@ inline void ObjectMonitor::set_owner_from(int64_t old_value, JavaThread* current
191187
set_owner_from_raw(old_value, owner_from(current));
192188
}
193189

194-
// Simply set _owner to the tid of current. Current owner must be anonymous.
195-
inline void ObjectMonitor::set_owner_from_BasicLock(JavaThread* current) {
196-
BasicLock* basic_lock_p = stack_locker();
197-
198-
set_stack_locker(nullptr); // first
199-
assert(has_owner_anonymous(), "");
200-
201-
// Non-null owner field to non-null owner field is safe without
202-
// cmpxchg() as long as all readers can tolerate either flavor.
203-
Atomic::store(&_owner, owner_from(current));
204-
log_trace(monitorinflation, owner)("set_owner_from_BasicLock(): mid="
205-
INTPTR_FORMAT ", basic_lock_p="
206-
INTPTR_FORMAT ", new_value=" INT64_FORMAT,
207-
p2i(this), p2i(basic_lock_p), owner_from(current));
208-
}
209-
210190
// Try to set _owner field to new_value if the current value matches
211191
// old_value. Otherwise, does not change the _owner field. Returns
212192
// the prior value of the _owner field.

src/hotspot/share/runtime/synchronizer.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1467,7 +1467,8 @@ ObjectMonitor* ObjectSynchronizer::inflate_impl(JavaThread* inflating_thread, oo
14671467
if (inf->has_owner_anonymous() && inflating_thread != nullptr) {
14681468
assert(LockingMode == LM_LEGACY, "invariant");
14691469
if (inflating_thread->is_lock_owned((address)inf->stack_locker())) {
1470-
inf->set_owner_from_BasicLock(inflating_thread);
1470+
inf->set_stack_locker(nullptr);
1471+
inf->set_owner_from_anonymous(inflating_thread);
14711472
}
14721473
}
14731474
return inf;

0 commit comments

Comments
 (0)