JDK-6373383 : Revert AtomicReference.compareAndSet to tiger version
  • Type: Bug
  • Component: core-libs
  • Sub-Component: java.util.concurrent
  • Affected Version: 6
  • Priority: P3
  • Status: Resolved
  • Resolution: Fixed
  • OS: generic
  • CPU: generic
  • Submitted: 2006-01-17
  • Updated: 2010-04-02
  • Resolved: 2006-02-04
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
JDK 6
6 b71Fixed
Related Reports
Relates :  
Description
The tricky "optimization" of AtomicReference.compareAndSet
made as part of the fix for
6322334: Atomics should use Unsafe lazy field set methods
is confusing, unnecessary and when measured, slightly hurts performance.
It should be reverted.

Comments
SUGGESTED FIX --- /tmp/geta24813 2006-01-17 11:51:24.824856200 -0800 +++ AtomicReference.java 2006-01-17 11:51:20.898910000 -0800 @@ -79,29 +79,27 @@ * if the current value <tt>==</tt> the expected value. * @param expect the expected value * @param update the new value * @return true if successful. False return indicates that * the actual value was not equal to the expected value. */ public final boolean compareAndSet(V expect, V update) { - return value == expect && - unsafe.compareAndSwapObject(this, valueOffset, expect, update); + return unsafe.compareAndSwapObject(this, valueOffset, expect, update); } /** * Atomically sets the value to the given updated value * if the current value <tt>==</tt> the expected value. * May fail spuriously. * @param expect the expected value * @param update the new value * @return true if successful. */ public final boolean weakCompareAndSet(V expect, V update) { - return value == expect && - unsafe.compareAndSwapObject(this, valueOffset, expect, update); + return unsafe.compareAndSwapObject(this, valueOffset, expect, update); } /** * Atomically sets to the given value and returns the old value. * * @param newValue the new value * @return the previous value
17-01-2006

EVALUATION Fix provided by Doug Lea.
17-01-2006