RFR: 8186476: Generalize Atomic::add with templates

Kim Barrett kim.barrett at oracle.com
Tue Sep 12 13:08:53 UTC 2017


Catching up from vacation.

> On Aug 22, 2017, at 10:52 AM, Andrew Haley <aph at redhat.com> wrote:
> 
> On 20/08/17 07:16, Kim Barrett wrote:
>> - atomic_linux_sparc.hpp
>> 
>> Neither add variant has "cc" in the clobbers list, even though the
>> condition codes are modified.  That seems like a pre-existing bug.
> 
> Some targets always clobber the flags.  I can't remember whether SPARC
> is one of them.

I’ve no idea, but that seems peculiar since SPARC has various instruction
pairs for affecting or not the condition codes.

>> Uses hard-coded machine registers and assumes the inline-asm
>> processing assigns the values to the corresponding machine registers,
>> even though the given constraints are just generic register requests.
>> I don't understand how this can work.
> 
> Looks right to me.

Argh!  You are correct, and I misread it.

>  69   __asm__ volatile(
>  70     "1: \n\t"
>  71     " ld     [%2], %%o2\n\t"
>  72     " add    %1, %%o2, %%o3\n\t"
>  73     " cas    [%2], %%o2, %%o3\n\t"
>  74     " cmp    %%o2, %%o3\n\t"
>  75     " bne    1b\n\t"
>  76     "  nop\n\t"
>  77     " add    %1, %%o2, %0\n\t"
>  78     : "=r" (rv)
>  79     : "r" (add_value), "r" (dest)
>  80     : "memory", "o2", "o3");
>  81   return rv;
>  82 }
> 
> o2 and o3 are temps.
> 
> -- 
> 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