RFR 8157152: Atomic add for VarHandle byte[]/ByteBuffer views is incorrect for endian conversion
Hi, Please review: http://cr.openjdk.java.net/~psandoz/jdk9/JDK-8157152-vh-array-views-atomic-a... <http://cr.openjdk.java.net/~psandoz/jdk9/JDK-8157152-vh-array-views-atomic-add-endianness/webrev/> The implementation for the atomic add methods for array and byte buffer views were incorrect when the native endianness differs from the requested endianness (an embarrassing oversight). The tests did not catch this due to values used for addition, since there was no carrying over of bits from a byte to it's subsequent higher-order byte. If there is a mismatch in endianness then a weak+volatile CAS loop is used. Credit goes to Frank (Yaun) for finding this and verifying. Paul.
On 05/18/2016 02:24 PM, Paul Sandoz wrote:
http://cr.openjdk.java.net/~psandoz/jdk9/JDK-8157152-vh-array-views-atomic-a...
Looks horrible (as many other endianness fixes), but correct. Reviewed. Thanks, -Aleksey
On 18 May 2016, at 13:44, Aleksey Shipilev <aleksey.shipilev@oracle.com> wrote:
On 05/18/2016 02:24 PM, Paul Sandoz wrote:
http://cr.openjdk.java.net/~psandoz/jdk9/JDK-8157152-vh-array-views-atomic-a...
Looks horrible (as many other endianness fixes), but correct. Reviewed.
John would say there is a byte odor about this code: https://twitter.com/JohnRose00/status/725453000844541952 <https://twitter.com/JohnRose00/status/725453000844541952> Paul.
Looks good. Best regards, Vladimir Ivanov On 5/18/16 2:24 PM, Paul Sandoz wrote:
Hi,
Please review:
http://cr.openjdk.java.net/~psandoz/jdk9/JDK-8157152-vh-array-views-atomic-a... <http://cr.openjdk.java.net/~psandoz/jdk9/JDK-8157152-vh-array-views-atomic-add-endianness/webrev/>
The implementation for the atomic add methods for array and byte buffer views were incorrect when the native endianness differs from the requested endianness (an embarrassing oversight).
The tests did not catch this due to values used for addition, since there was no carrying over of bits from a byte to it's subsequent higher-order byte.
If there is a mismatch in endianness then a weak+volatile CAS loop is used.
Credit goes to Frank (Yaun) for finding this and verifying.
Paul.
participants (3)
-
Aleksey Shipilev
-
Paul Sandoz
-
Vladimir Ivanov