< prev index next >

src/os_cpu/solaris_sparc/vm/atomic_solaris_sparc.hpp

Print this page
rev 13488 : [mq]: add_solaris_sparc


  45 
  46 inline void Atomic::dec    (volatile jint*     dest) { (void)add    (-1, dest); }
  47 inline void Atomic::dec_ptr(volatile intptr_t* dest) { (void)add_ptr(-1, dest); }
  48 inline void Atomic::dec_ptr(volatile void*     dest) { (void)add_ptr(-1, dest); }
  49 
  50 
  51 inline void Atomic::store(jlong store_value, jlong* dest) { *dest = store_value; }
  52 inline void Atomic::store(jlong store_value, volatile jlong* dest) { *dest = store_value; }
  53 inline jlong Atomic::load(const volatile jlong* src) { return *src; }
  54 
  55 
  56 // This is the interface to the atomic instructions in solaris_sparc.il.
  57 // It's very messy because we need to support v8 and these instructions
  58 // are illegal there.  When sparc v8 is dropped, we can drop out lots of
  59 // this code.  Also compiler2 does not support v8 so the conditional code
  60 // omits the instruction set check.
  61 
  62 extern "C" jint     _Atomic_swap32(jint     exchange_value, volatile jint*     dest);
  63 extern "C" intptr_t _Atomic_swap64(intptr_t exchange_value, volatile intptr_t* dest);
  64 
  65 extern "C" jint     _Atomic_add32(jint     inc,       volatile jint*     dest);
  66 extern "C" intptr_t _Atomic_add64(intptr_t add_value, volatile intptr_t* dest);
  67 
  68 
  69 inline jint     Atomic::add     (jint    add_value, volatile jint*     dest) {
  70   return _Atomic_add32(add_value, dest);
  71 }
  72 
  73 inline intptr_t Atomic::add_ptr(intptr_t add_value, volatile intptr_t* dest) {
  74   return _Atomic_add64(add_value, dest);
  75 }
  76 
  77 inline void*    Atomic::add_ptr(intptr_t add_value, volatile void*     dest) {
  78   return (void*)add_ptr((intptr_t)add_value, (volatile intptr_t*)dest);
  79 }
  80 
  81 
  82 inline jint     Atomic::xchg    (jint     exchange_value, volatile jint*     dest) {
  83   return _Atomic_swap32(exchange_value, dest);
  84 }
  85 
  86 inline intptr_t Atomic::xchg_ptr(intptr_t exchange_value, volatile intptr_t* dest) {
  87   return _Atomic_swap64(exchange_value, dest);
  88 }
  89 
  90 inline void*    Atomic::xchg_ptr(void*    exchange_value, volatile void*     dest) {
  91   return (void*)xchg_ptr((intptr_t)exchange_value, (volatile intptr_t*)dest);
  92 }
  93 
  94 // No direct support for cmpxchg of bytes; emulate using int.
  95 template<>
  96 struct Atomic::PlatformCmpxchg<1> : Atomic::CmpxchgByteUsingInt {};
  97 
  98 template<>
  99 template<typename T>
 100 inline T Atomic::PlatformCmpxchg<4>::operator()(T exchange_value,




  45 
  46 inline void Atomic::dec    (volatile jint*     dest) { (void)add    (-1, dest); }
  47 inline void Atomic::dec_ptr(volatile intptr_t* dest) { (void)add_ptr(-1, dest); }
  48 inline void Atomic::dec_ptr(volatile void*     dest) { (void)add_ptr(-1, dest); }
  49 
  50 
  51 inline void Atomic::store(jlong store_value, jlong* dest) { *dest = store_value; }
  52 inline void Atomic::store(jlong store_value, volatile jlong* dest) { *dest = store_value; }
  53 inline jlong Atomic::load(const volatile jlong* src) { return *src; }
  54 
  55 
  56 // This is the interface to the atomic instructions in solaris_sparc.il.
  57 // It's very messy because we need to support v8 and these instructions
  58 // are illegal there.  When sparc v8 is dropped, we can drop out lots of
  59 // this code.  Also compiler2 does not support v8 so the conditional code
  60 // omits the instruction set check.
  61 
  62 extern "C" jint     _Atomic_swap32(jint     exchange_value, volatile jint*     dest);
  63 extern "C" intptr_t _Atomic_swap64(intptr_t exchange_value, volatile intptr_t* dest);
  64 
  65 // Implement ADD using a CAS loop.
  66 template<size_t byte_size>
  67 struct Atomic::PlatformAdd VALUE_OBJ_CLASS_SPEC {
  68   template<typename I, typename D>
  69   inline D operator()(I add_value, D volatile* dest) const {
  70     D old_value = *dest;
  71     while (true) {
  72       D new_value = old_value + add_value;
  73       D result = cmpxchg(new_value, dest, old_value);
  74       if (result == old_value) break;
  75       old_value = result;
  76     }
  77     return old_value + add_value;
  78   }
  79 };

  80 
  81 inline jint     Atomic::xchg    (jint     exchange_value, volatile jint*     dest) {
  82   return _Atomic_swap32(exchange_value, dest);
  83 }
  84 
  85 inline intptr_t Atomic::xchg_ptr(intptr_t exchange_value, volatile intptr_t* dest) {
  86   return _Atomic_swap64(exchange_value, dest);
  87 }
  88 
  89 inline void*    Atomic::xchg_ptr(void*    exchange_value, volatile void*     dest) {
  90   return (void*)xchg_ptr((intptr_t)exchange_value, (volatile intptr_t*)dest);
  91 }
  92 
  93 // No direct support for cmpxchg of bytes; emulate using int.
  94 template<>
  95 struct Atomic::PlatformCmpxchg<1> : Atomic::CmpxchgByteUsingInt {};
  96 
  97 template<>
  98 template<typename T>
  99 inline T Atomic::PlatformCmpxchg<4>::operator()(T exchange_value,


< prev index next >