< prev index next >

src/os_cpu/aix_ppc/vm/atomic_aix_ppc.hpp

Print this page
rev 13526 : 8186855: Multiple platforms broken after 8186476: Generalize Atomic::add with templates


  89 #define strasm_sync                       "\n  sync    \n"
  90 #define strasm_lwsync                     "\n  lwsync  \n"
  91 #define strasm_isync                      "\n  isync   \n"
  92 #define strasm_release                    strasm_lwsync
  93 #define strasm_acquire                    strasm_lwsync
  94 #define strasm_fence                      strasm_sync
  95 #define strasm_nobarrier                  ""
  96 #define strasm_nobarrier_clobber_memory   ""
  97 
  98 template<size_t byte_size>
  99 struct Atomic::PlatformAdd
 100   : Atomic::AddAndFetch<Atomic::PlatformAdd<byte_size> >
 101 {
 102   template<typename I, typename D>
 103   D add_and_fetch(I add_value, D volatile* dest) const;
 104 };
 105 
 106 template<>
 107 template<typename I, typename D>
 108 inline D Atomic::PlatformAdd<4>::add_and_fetch(I add_value, D volatile* dest) const {
 109   STATIC_CAST(4 == sizeof(I));
 110   STATIC_CAST(4 == sizeof(D));
 111 
 112   D result;
 113 
 114   __asm__ __volatile__ (
 115     strasm_lwsync
 116     "1: lwarx   %0,  0, %2    \n"
 117     "   add     %0, %0, %1    \n"
 118     "   stwcx.  %0,  0, %2    \n"
 119     "   bne-    1b            \n"
 120     strasm_isync
 121     : /*%0*/"=&r" (result)
 122     : /*%1*/"r" (add_value), /*%2*/"r" (dest)
 123     : "cc", "memory" );
 124 
 125   return result;
 126 }
 127 
 128 
 129 template<>
 130 template<typename I, typename D>
 131 inline D Atomic::PlatformAdd<8>::add_and_fetch(I add_value, D volatile* dest) const {
 132   STATIC_CAST(8 == sizeof(I));
 133   STATIC_CAST(8 == sizeof(D));
 134 
 135   D result;
 136 
 137   __asm__ __volatile__ (
 138     strasm_lwsync
 139     "1: ldarx   %0,  0, %2    \n"
 140     "   add     %0, %0, %1    \n"
 141     "   stdcx.  %0,  0, %2    \n"
 142     "   bne-    1b            \n"
 143     strasm_isync
 144     : /*%0*/"=&r" (result)
 145     : /*%1*/"r" (add_value), /*%2*/"r" (dest)
 146     : "cc", "memory" );
 147 
 148   return result;
 149 }
 150 
 151 
 152 inline void Atomic::inc    (volatile jint*     dest) {
 153 




  89 #define strasm_sync                       "\n  sync    \n"
  90 #define strasm_lwsync                     "\n  lwsync  \n"
  91 #define strasm_isync                      "\n  isync   \n"
  92 #define strasm_release                    strasm_lwsync
  93 #define strasm_acquire                    strasm_lwsync
  94 #define strasm_fence                      strasm_sync
  95 #define strasm_nobarrier                  ""
  96 #define strasm_nobarrier_clobber_memory   ""
  97 
  98 template<size_t byte_size>
  99 struct Atomic::PlatformAdd
 100   : Atomic::AddAndFetch<Atomic::PlatformAdd<byte_size> >
 101 {
 102   template<typename I, typename D>
 103   D add_and_fetch(I add_value, D volatile* dest) const;
 104 };
 105 
 106 template<>
 107 template<typename I, typename D>
 108 inline D Atomic::PlatformAdd<4>::add_and_fetch(I add_value, D volatile* dest) const {
 109   STATIC_ASSERT(4 == sizeof(I));
 110   STATIC_ASSERT(4 == sizeof(D));
 111 
 112   D result;
 113 
 114   __asm__ __volatile__ (
 115     strasm_lwsync
 116     "1: lwarx   %0,  0, %2    \n"
 117     "   add     %0, %0, %1    \n"
 118     "   stwcx.  %0,  0, %2    \n"
 119     "   bne-    1b            \n"
 120     strasm_isync
 121     : /*%0*/"=&r" (result)
 122     : /*%1*/"r" (add_value), /*%2*/"r" (dest)
 123     : "cc", "memory" );
 124 
 125   return result;
 126 }
 127 
 128 
 129 template<>
 130 template<typename I, typename D>
 131 inline D Atomic::PlatformAdd<8>::add_and_fetch(I add_value, D volatile* dest) const {
 132   STATIC_ASSERT(8 == sizeof(I));
 133   STATIC_ASSERT(8 == sizeof(D));
 134 
 135   D result;
 136 
 137   __asm__ __volatile__ (
 138     strasm_lwsync
 139     "1: ldarx   %0,  0, %2    \n"
 140     "   add     %0, %0, %1    \n"
 141     "   stdcx.  %0,  0, %2    \n"
 142     "   bne-    1b            \n"
 143     strasm_isync
 144     : /*%0*/"=&r" (result)
 145     : /*%1*/"r" (add_value), /*%2*/"r" (dest)
 146     : "cc", "memory" );
 147 
 148   return result;
 149 }
 150 
 151 
 152 inline void Atomic::inc    (volatile jint*     dest) {
 153 


< prev index next >