< prev index next >

src/hotspot/share/runtime/atomic.hpp

Print this page
rev 47321 : [mq]: Atomic_loadstore
rev 47322 : [mq]: Atomic_loadstore_v2


  47  public:
  48   // Atomic operations on jlong types are not available on all 32-bit
  49   // platforms. If atomic ops on jlongs are defined here they must only
  50   // be used from code that verifies they are available at runtime and
  51   // can provide an alternative action if not - see supports_cx8() for
  52   // a means to test availability.
  53 
  54   // The memory operations that are mentioned with each of the atomic
  55   // function families come from src/share/vm/runtime/orderAccess.hpp,
  56   // e.g., <fence> is described in that file and is implemented by the
  57   // OrderAccess::fence() function. See that file for the gory details
  58   // on the Memory Access Ordering Model.
  59 
  60   // All of the atomic operations that imply a read-modify-write action
  61   // guarantee a two-way memory barrier across that operation. Historically
  62   // these semantics reflect the strength of atomic operations that are
  63   // provided on SPARC/X86. We assume that strength is necessary unless
  64   // we can prove that a weaker form is sufficiently safe.
  65 
  66   // Atomically store to a location
  67   // See comment above about using jlong atomics on 32-bit platforms
  68   // The type T must be either a pointer type convertible to or equal
  69   // to D, an integral/enum type equal to D, or a type equal to D that
  70   // is primitive convertible using PrimitiveConversions.
  71   template<typename T, typename D>
  72   inline static void store(T store_value, volatile D* dest);
  73 
  74   inline static void store_ptr(intptr_t store_value, volatile intptr_t* dest) {
  75     Atomic::store(store_value, dest);
  76   }
  77 
  78   inline static void store_ptr(void*    store_value, volatile void*     dest) {
  79     Atomic::store(store_value, reinterpret_cast<void* volatile*>(dest));
  80   }
  81 
  82   // Atomically load from a location
  83   // See comment above about using jlong atomics on 32-bit platforms
  84   // The type T must be either a pointer type, an integral/enum type,
  85   // or a type that is primitive convertible using PrimitiveConversions.
  86   template<typename T>
  87   inline static T load(const volatile T* dest);
  88 
  89   // Atomically add to a location. Returns updated value. add*() provide:
  90   // <fence> add-value-to-dest <membar StoreLoad|StoreStore>
  91 
  92   template<typename I, typename D>
  93   inline static D add(I add_value, D volatile* dest);
  94 
  95   inline static intptr_t add_ptr(intptr_t add_value, volatile intptr_t* dest) {
  96     return add(add_value, dest);
  97   }
  98 
  99   inline static void* add_ptr(intptr_t add_value, volatile void* dest) {
 100     return add(add_value, reinterpret_cast<char* volatile*>(dest));
 101   }
 102 
 103   // Atomically increment location. inc() provide:




  47  public:
  48   // Atomic operations on jlong types are not available on all 32-bit
  49   // platforms. If atomic ops on jlongs are defined here they must only
  50   // be used from code that verifies they are available at runtime and
  51   // can provide an alternative action if not - see supports_cx8() for
  52   // a means to test availability.
  53 
  54   // The memory operations that are mentioned with each of the atomic
  55   // function families come from src/share/vm/runtime/orderAccess.hpp,
  56   // e.g., <fence> is described in that file and is implemented by the
  57   // OrderAccess::fence() function. See that file for the gory details
  58   // on the Memory Access Ordering Model.
  59 
  60   // All of the atomic operations that imply a read-modify-write action
  61   // guarantee a two-way memory barrier across that operation. Historically
  62   // these semantics reflect the strength of atomic operations that are
  63   // provided on SPARC/X86. We assume that strength is necessary unless
  64   // we can prove that a weaker form is sufficiently safe.
  65 
  66   // Atomically store to a location

  67   // The type T must be either a pointer type convertible to or equal
  68   // to D, an integral/enum type equal to D, or a type equal to D that
  69   // is primitive convertible using PrimitiveConversions.
  70   template<typename T, typename D>
  71   inline static void store(T store_value, volatile D* dest);
  72 
  73   inline static void store_ptr(intptr_t store_value, volatile intptr_t* dest) {
  74     Atomic::store(store_value, dest);
  75   }
  76 
  77   inline static void store_ptr(void*    store_value, volatile void*     dest) {
  78     Atomic::store(store_value, reinterpret_cast<void* volatile*>(dest));
  79   }
  80 
  81   // Atomically load from a location

  82   // The type T must be either a pointer type, an integral/enum type,
  83   // or a type that is primitive convertible using PrimitiveConversions.
  84   template<typename T>
  85   inline static T load(const volatile T* dest);
  86 
  87   // Atomically add to a location. Returns updated value. add*() provide:
  88   // <fence> add-value-to-dest <membar StoreLoad|StoreStore>
  89 
  90   template<typename I, typename D>
  91   inline static D add(I add_value, D volatile* dest);
  92 
  93   inline static intptr_t add_ptr(intptr_t add_value, volatile intptr_t* dest) {
  94     return add(add_value, dest);
  95   }
  96 
  97   inline static void* add_ptr(intptr_t add_value, volatile void* dest) {
  98     return add(add_value, reinterpret_cast<char* volatile*>(dest));
  99   }
 100 
 101   // Atomically increment location. inc() provide:


< prev index next >