RFR: 8186476: Generalize Atomic::add with templates

Andrew Haley aph at redhat.com
Tue Aug 22 08:52:01 UTC 2017


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.

> The 32-bit add was using intptr_t as the rv type.  Probably a harmless
> copy-paste mistake.  Now using template parameter type.
> 
> 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.

  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