RFR: 8186166: Generalize Atomic::cmpxchg with templates

David Holmes david.holmes at oracle.com
Tue Aug 22 01:28:44 UTC 2017


On 19/08/2017 4:45 AM, Kim Barrett wrote:
>> On Aug 18, 2017, at 9:23 AM, Andrew Haley <aph at redhat.com> wrote:
>>
>> This hunk was missing the parameter declaration of order.  Fixed thusly:
>>
>> diff -r 214a94e9366c src/os_cpu/linux_aarch64/vm/atomic_linux_aarch64.hpp
>> --- a/src/os_cpu/linux_aarch64/vm/atomic_linux_aarch64.hpp	Mon Jul 17 12:11:32 2017 +0000
>> +++ b/src/os_cpu/linux_aarch64/vm/atomic_linux_aarch64.hpp	Fri Aug 18 14:22:19 2017 +0100
>> @@ -85,9 +85,12 @@
>>                             (volatile intptr_t*) dest);
>> }
>>
>> -template <typename T> T generic_cmpxchg(T exchange_value, volatile T* dest,
>> -                                        T compare_value, cmpxchg_memory_order order)
>> -{
>> +template<size_t byte_size>
>> +template<typename T>
>> +inline T Atomic::PlatformCmpxchg<byte_size>::operator()(T exchange_value,
>> +                                                        T volatile* dest,
>> +                                                        T compare_value,
>> +                                                        cmpxchg_memory_order order) const {
>>    if (order == memory_order_relaxed) {
>>      T value = compare_value;
>>      __atomic_compare_exchange(dest, &value, &exchange_value, /*weak*/false,
>> @@ -98,17 +101,6 @@
>>    }
>> }
> 
> 
> Drat.  Thanks for finding this.
> 
> It's a nuisance having to send out for review code that I've not been
> able to test at all.  And yes, I know non-Oracle folks trying to deal
> with jprt have it *much* worse.
> 
> Some new webrevs:
> 
> Rename IntegerTypes to PrimitiveConversions.  This is the change I
> said I was going to leave until the end.  Looks like I could have done
> it earlier; webrev did a fine job with the moved file.
> full: http://cr.openjdk.java.net/~kbarrett/8186166/hotspot.03/
> incr: http://cr.openjdk.java.net/~kbarrett/8186166/hotspot.03.inc/

Looks okay justAPityItisSuchALongname :)

> linux_aarch fix, rename test_integerTypes.cpp to test_primitiveConversions.cpp.
> full: http://cr.openjdk.java.net/~kbarrett/8186166/hotspot.04/
> incr: http://cr.openjdk.java.net/~kbarrett/8186166/hotspot.04.inc/
> 
> I'm hoping hotspot.04 will be the final version that I'll be handing
> off to Erik, as he returns from vacation and I start mine.
> 
> I'm working on a change in a similar style for Atomic::add, and hope
> to send out an RFR later today.  I'll be handing that off to Erik as
> well.

No further comments on this from me.

Thanks,
David



More information about the hotspot-dev mailing list