< prev index next >

src/os_cpu/linux_sparc/vm/atomic_linux_sparc.hpp

Print this page
rev 13452 : imported patch Atomic_cmpxchg
rev 13453 : imported patch Atomic_add
rev 13454 : [mq]: Atomic_add_v2


  86   STATIC_CAST(8 == sizeof(I));
  87   STATIC_CAST(8 == sizeof(D));
  88 
  89   D rv;
  90   __asm__ volatile(
  91     "1: \n\t"
  92     " ldx    [%2], %%o2\n\t"
  93     " add    %1, %%o2, %%o3\n\t"
  94     " casx   [%2], %%o2, %%o3\n\t"
  95     " cmp    %%o2, %%o3\n\t"
  96     " bne    %%xcc, 1b\n\t"
  97     "  nop\n\t"
  98     " add    %1, %%o2, %0\n\t"
  99     : "=r" (rv)
 100     : "r" (add_value), "r" (dest)
 101     : "memory", "o2", "o3");
 102   return rv;
 103 }
 104 
 105 



 106 inline jint     Atomic::xchg    (jint     exchange_value, volatile jint*     dest) {
 107   intptr_t rv = exchange_value;
 108   __asm__ volatile(
 109     " swap   [%2],%1\n\t"
 110     : "=r" (rv)
 111     : "0" (exchange_value) /* we use same register as for return value */, "r" (dest)
 112     : "memory");
 113   return rv;
 114 }
 115 
 116 inline intptr_t Atomic::xchg_ptr(intptr_t exchange_value, volatile intptr_t* dest) {
 117   intptr_t rv = exchange_value;
 118   __asm__ volatile(
 119     "1:\n\t"
 120     " mov    %1, %%o3\n\t"
 121     " ldx    [%2], %%o2\n\t"
 122     " casx   [%2], %%o2, %%o3\n\t"
 123     " cmp    %%o2, %%o3\n\t"
 124     " bne    %%xcc, 1b\n\t"
 125     "  nop\n\t"




  86   STATIC_CAST(8 == sizeof(I));
  87   STATIC_CAST(8 == sizeof(D));
  88 
  89   D rv;
  90   __asm__ volatile(
  91     "1: \n\t"
  92     " ldx    [%2], %%o2\n\t"
  93     " add    %1, %%o2, %%o3\n\t"
  94     " casx   [%2], %%o2, %%o3\n\t"
  95     " cmp    %%o2, %%o3\n\t"
  96     " bne    %%xcc, 1b\n\t"
  97     "  nop\n\t"
  98     " add    %1, %%o2, %0\n\t"
  99     : "=r" (rv)
 100     : "r" (add_value), "r" (dest)
 101     : "memory", "o2", "o3");
 102   return rv;
 103 }
 104 
 105 
 106 template<>
 107 struct Atomic::PlatformAdd<2>: Atomic::AddShortUsingInt {};
 108 
 109 inline jint     Atomic::xchg    (jint     exchange_value, volatile jint*     dest) {
 110   intptr_t rv = exchange_value;
 111   __asm__ volatile(
 112     " swap   [%2],%1\n\t"
 113     : "=r" (rv)
 114     : "0" (exchange_value) /* we use same register as for return value */, "r" (dest)
 115     : "memory");
 116   return rv;
 117 }
 118 
 119 inline intptr_t Atomic::xchg_ptr(intptr_t exchange_value, volatile intptr_t* dest) {
 120   intptr_t rv = exchange_value;
 121   __asm__ volatile(
 122     "1:\n\t"
 123     " mov    %1, %%o3\n\t"
 124     " ldx    [%2], %%o2\n\t"
 125     " casx   [%2], %%o2, %%o3\n\t"
 126     " cmp    %%o2, %%o3\n\t"
 127     " bne    %%xcc, 1b\n\t"
 128     "  nop\n\t"


< prev index next >