Skip to content

Commit 19340a0

Browse files
committed
review v5
1 parent ec91413 commit 19340a0

File tree

3 files changed

+10
-35
lines changed

3 files changed

+10
-35
lines changed

src/hotspot/share/runtime/lightweightSynchronizer.cpp

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1029,9 +1029,6 @@ ObjectMonitor* LightweightSynchronizer::inflate_and_enter(oop object, BasicLock*
10291029
}
10301030

10311031
if (monitor->try_enter(locking_thread)) {
1032-
if (monitor->has_successor(current)) {
1033-
monitor->clear_successor();
1034-
}
10351032
return monitor;
10361033
}
10371034

@@ -1147,7 +1144,6 @@ ObjectMonitor* LightweightSynchronizer::inflate_and_enter(oop object, BasicLock*
11471144

11481145
if (current == locking_thread) {
11491146
monitor->enter_with_contention_mark(locking_thread, contention_mark);
1150-
assert(!monitor->has_successor(current), "what?");
11511147
} else {
11521148
monitor->enter_for_with_contention_mark(locking_thread, contention_mark);
11531149
}

src/hotspot/share/runtime/objectMonitor.cpp

Lines changed: 10 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -461,9 +461,6 @@ bool ObjectMonitor::spin_enter(JavaThread* current) {
461461

462462
// Check for recursion.
463463
if (try_enter(current)) {
464-
if (has_successor(current)) {
465-
clear_successor();
466-
}
467464
return true;
468465
}
469466

@@ -478,9 +475,6 @@ bool ObjectMonitor::spin_enter(JavaThread* current) {
478475
// Note that if we acquire the monitor from an initial spin
479476
// we forgo posting JVMTI events and firing DTRACE probes.
480477
if (try_spin(current)) {
481-
if (has_successor(current)) {
482-
clear_successor();
483-
}
484478
assert(has_owner(current), "must be current: owner=" INT64_FORMAT, owner_raw());
485479
assert(_recursions == 0, "must be 0: recursions=%zd", _recursions);
486480
assert_mark_word_consistency();
@@ -498,6 +492,7 @@ bool ObjectMonitor::enter(JavaThread* current) {
498492
}
499493

500494
assert(!has_owner(current), "invariant");
495+
assert(!has_successor(current), "invariant");
501496
assert(!SafepointSynchronize::is_at_safepoint(), "invariant");
502497
assert(current->thread_state() != _thread_blocked, "invariant");
503498

@@ -556,12 +551,6 @@ void ObjectMonitor::enter_with_contention_mark(JavaThread* current, ObjectMonito
556551
notify_contended_enter(current);
557552
result = Continuation::try_preempt(current, ce->cont_oop(current));
558553
if (result == freeze_ok) {
559-
if (has_successor(current)) {
560-
clear_successor();
561-
// Invariant: after setting succ=null a contending thread
562-
// must recheck-retry _owner before parking. (Done in vthread_monitor_enter)
563-
OrderAccess::fence();
564-
}
565554
bool acquired = vthread_monitor_enter(current);
566555
if (acquired) {
567556
// We actually acquired the monitor while trying to add the vthread to the
@@ -938,9 +927,7 @@ void ObjectMonitor::enter_internal(JavaThread* current) {
938927

939928
// Try the lock - TATAS
940929
if (try_lock(current) == TryLockResult::Success) {
941-
if (has_successor(current)) {
942-
clear_successor();
943-
}
930+
assert(!has_successor(current), "invariant");
944931
assert(has_owner(current), "invariant");
945932
return;
946933
}
@@ -954,7 +941,7 @@ void ObjectMonitor::enter_internal(JavaThread* current) {
954941
// to the owner. This has subtle but beneficial affinity
955942
// effects.
956943

957-
if (final_try_spin(current)) {
944+
if (try_spin(current)) {
958945
assert(has_owner(current), "invariant");
959946
assert(!has_successor(current), "invariant");
960947
return;
@@ -1119,7 +1106,7 @@ void ObjectMonitor::reenter_internal(JavaThread* current, ObjectWaiter* currentN
11191106

11201107
// If that fails, spin again. Note that spin count may be zero so the above TryLock
11211108
// is necessary.
1122-
if (final_try_spin(current)) {
1109+
if (try_spin(current)) {
11231110
break;
11241111
}
11251112

@@ -2342,6 +2329,9 @@ bool ObjectMonitor::try_spin(JavaThread* current) {
23422329
// This is in keeping with the "no loitering in runtime" rule.
23432330
// We periodically check to see if there's a safepoint pending.
23442331
if ((ctr & 0xFF) == 0) {
2332+
if (has_successor(current)) {
2333+
clear_successor();
2334+
}
23452335
// Can't call SafepointMechanism::should_process() since that
23462336
// might update the poll values and we could be in a thread_blocked
23472337
// state here which is not allowed so just check the poll.
@@ -2406,22 +2396,12 @@ bool ObjectMonitor::try_spin(JavaThread* current) {
24062396
_SpinDuration = adjust_down(_SpinDuration);
24072397
}
24082398

2409-
return false;
2410-
}
2411-
2412-
bool ObjectMonitor::final_try_spin(JavaThread* current) {
2413-
if (try_spin(current)) {
2414-
if (has_successor(current)) {
2415-
// We are locked, clear the successor.
2416-
clear_successor();
2417-
}
2418-
return true;
2419-
}
2420-
24212399
if (has_successor(current)) {
24222400
clear_successor();
24232401
// Invariant: after setting succ=null a contending thread
2424-
// must recheck-retry _owner before parking.
2402+
// must recheck-retry _owner before parking. This usually happens
2403+
// in the normal usage of try_spin(), but it's safest
2404+
// to make try_spin() as foolproof as possible.
24252405
OrderAccess::fence();
24262406
if (try_lock(current) == TryLockResult::Success) {
24272407
return true;

src/hotspot/share/runtime/objectMonitor.hpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -456,7 +456,6 @@ class ObjectMonitor : public CHeapObj<mtObjectMonitor> {
456456
TryLockResult try_lock(JavaThread* current);
457457

458458
bool try_spin(JavaThread* current);
459-
bool final_try_spin(JavaThread* current);
460459
bool short_fixed_spin(JavaThread* current, int spin_count, bool adapt);
461460
void exit_epilog(JavaThread* current, ObjectWaiter* Wakee);
462461

0 commit comments

Comments
 (0)