8300098: java/util/concurrent/ConcurrentHashMap/ConcurrentAssociateTest.java fails with internal timeout when executed with TieredCompilation1/3

Co-authored-by: Doug Lea <dl@openjdk.org>
Reviewed-by: jpai, alanb
This commit is contained in:
Viktor Klang 2023-02-06 15:26:32 +00:00 committed by Alan Bateman
parent 7ae447f4eb
commit ecf8842cd2

View file

@ -2862,22 +2862,20 @@ public class ConcurrentHashMap<K,V> extends AbstractMap<K,V>
* Possibly blocks awaiting root lock. * Possibly blocks awaiting root lock.
*/ */
private final void contendedLock() { private final void contendedLock() {
boolean waiting = false; Thread current = Thread.currentThread(), w;
for (int s;;) { for (int s;;) {
if (((s = lockState) & ~WAITER) == 0) { if (((s = lockState) & ~WAITER) == 0) {
if (U.compareAndSetInt(this, LOCKSTATE, s, WRITER)) { if (U.compareAndSetInt(this, LOCKSTATE, s, WRITER)) {
if (waiting) if (waiter == current)
waiter = null; U.compareAndSetReference(this, WAITERTHREAD, current, null);
return; return;
} }
} }
else if ((s & WAITER) == 0) { else if ((s & WAITER) == 0)
if (U.compareAndSetInt(this, LOCKSTATE, s, s | WAITER)) { U.compareAndSetInt(this, LOCKSTATE, s, s | WAITER);
waiting = true; else if ((w = waiter) == null)
waiter = Thread.currentThread(); U.compareAndSetReference(this, WAITERTHREAD, null, current);
} else if (w == current)
}
else if (waiting)
LockSupport.park(this); LockSupport.park(this);
} }
} }
@ -3296,6 +3294,8 @@ public class ConcurrentHashMap<K,V> extends AbstractMap<K,V>
private static final long LOCKSTATE private static final long LOCKSTATE
= U.objectFieldOffset(TreeBin.class, "lockState"); = U.objectFieldOffset(TreeBin.class, "lockState");
private static final long WAITERTHREAD
= U.objectFieldOffset(TreeBin.class, "waiter");
} }
/* ----------------Table Traversal -------------- */ /* ----------------Table Traversal -------------- */