RFR: 8187227: __m68k_cmpxchg() is not being used correctly

Andrew Haley aph at redhat.com
Tue Nov 21 10:37:14 UTC 2017


On 21/11/17 10:34, John Paul Adrian Glaubitz wrote:
> Hi Andrew!
> 
> On 11/20/2017 12:13 PM, Andrew Haley wrote:
>> For avoidance of doubt, this is what GCC does:
>>
>>
>> int m68k_sync_compare_and_swap(int newval,
>>                            volatile int *ptr,
>>                            int oldval) {
>>   return __sync_val_compare_and_swap (ptr, oldval, newval);
>> }
>>
>> m68k_sync_compare_and_swap:
>> 	move.l 4(%sp),%d1
>> 	move.l 8(%sp),%a0
>> 	move.l 12(%sp),%d0
>> 	cas.l %d0,%d1,(%a0)
>> 	seq %d1
>> 	rts
>>
>> You could do many things worse than simply using __sync_val_compare_and_swap
>> for Zero on 68k.
> 
> This sounds like a good idea. I'll look into using that. Might make the
> code also more readable. Although I would be a bit worried that this
> introduces too many layers of indirection, wouldn't it?

It's a a compiler builtin, so it should be (at least) as good as inline
assembly.  It's GCC-specific, but that shouldn't matter.

-- 
Andrew Haley
Java Platform Lead Engineer
Red Hat UK Ltd. <https://www.redhat.com>
EAC8 43EB D3EF DB98 CC77 2FAD A5CD 6035 332F A671


More information about the hotspot-dev mailing list