< prev index next >

src/hotspot/share/runtime/atomic.hpp

Print this page
rev 47399 : [mq]: add_ptr
rev 47400 : [mq]: cmpxchg_ptr
rev 47401 : [mq]: cmpxchg_if_null
rev 47402 : [mq]: xchg_ptr
rev 47403 : imported patch store_ptr

@@ -68,18 +68,10 @@
   // to D, an integral/enum type equal to D, or a type equal to D that
   // is primitive convertible using PrimitiveConversions.
   template<typename T, typename D>
   inline static void store(T store_value, volatile D* dest);
 
-  inline static void store_ptr(intptr_t store_value, volatile intptr_t* dest) {
-    Atomic::store(store_value, dest);
-  }
-
-  inline static void store_ptr(void*    store_value, volatile void*     dest) {
-    Atomic::store(store_value, reinterpret_cast<void* volatile*>(dest));
-  }
-
   // Atomically load from a location
   // The type T must be either a pointer type, an integral/enum type,
   // or a type that is primitive convertible using PrimitiveConversions.
   template<typename T>
   inline static T load(const volatile T* dest);

@@ -88,17 +80,12 @@
   // <fence> add-value-to-dest <membar StoreLoad|StoreStore>
 
   template<typename I, typename D>
   inline static D add(I add_value, D volatile* dest);
 
-  inline static intptr_t add_ptr(intptr_t add_value, volatile intptr_t* dest) {
-    return add(add_value, dest);
-  }
-
-  inline static void* add_ptr(intptr_t add_value, volatile void* dest) {
-    return add(add_value, reinterpret_cast<char* volatile*>(dest));
-  }
+  template<typename I, typename D>
+  inline static D sub(I sub_value, D volatile* dest);
 
   // Atomically increment location. inc() provide:
   // <fence> increment-dest <membar StoreLoad|StoreStore>
   // The type D may be either a pointer type, or an integral
   // type. If it is a pointer type, then the increment is

@@ -121,18 +108,10 @@
   // to D, an integral/enum type equal to D, or a type equal to D that
   // is primitive convertible using PrimitiveConversions.
   template<typename T, typename D>
   inline static D xchg(T exchange_value, volatile D* dest);
 
-  inline static intptr_t xchg_ptr(intptr_t exchange_value, volatile intptr_t* dest) {
-    return xchg(exchange_value, dest);
-  }
-
-  inline static void*    xchg_ptr(void*    exchange_value, volatile void*     dest) {
-    return xchg(exchange_value, reinterpret_cast<void* volatile*>(dest));
-  }
-
   // Performs atomic compare of *dest and compare_value, and exchanges
   // *dest with exchange_value if the comparison succeeded. Returns prior
   // value of *dest. cmpxchg*() provide:
   // <fence> compare-and-exchange <membar StoreLoad|StoreStore>
 

@@ -146,30 +125,13 @@
   // with exchange_value if the comparison succeeded.  Returns true if
   // the comparison succeeded and the exchange occurred.  This is
   // often used as part of lazy initialization, as a lock-free
   // alternative to the Double-Checked Locking Pattern.
   template<typename T, typename D>
-  inline static bool replace_if_null(T* value, D* volatile* dest,
+  inline static bool cmpxchg_if_null(T* value, D* volatile* dest,
                                      cmpxchg_memory_order order = memory_order_conservative);
 
-  inline static intptr_t cmpxchg_ptr(intptr_t exchange_value,
-                                     volatile intptr_t* dest,
-                                     intptr_t compare_value,
-                                     cmpxchg_memory_order order = memory_order_conservative) {
-    return cmpxchg(exchange_value, dest, compare_value, order);
-  }
-
-  inline static void* cmpxchg_ptr(void* exchange_value,
-                                  volatile void* dest,
-                                  void* compare_value,
-                                  cmpxchg_memory_order order = memory_order_conservative) {
-    return cmpxchg(exchange_value,
-                   reinterpret_cast<void* volatile*>(dest),
-                   compare_value,
-                   order);
-  }
-
 private:
   // Test whether From is implicitly convertible to To.
   // From and To must be pointer types.
   // Note: Provides the limited subset of C++11 std::is_convertible
   // that is needed here.

@@ -553,10 +515,18 @@
   // Assumes two's complement integer representation.
   #pragma warning(suppress: 4146)
   Atomic::add(I(-1), dest);
 }
 
+template<typename I, typename D>
+inline D Atomic::sub(I sub_value, D volatile* dest) {
+  STATIC_ASSERT(IsPointer<D>::value || IsIntegral<D>::value);
+  // Assumes two's complement integer representation.
+  #pragma warning(suppress: 4146)
+  return Atomic::add(-sub_value, dest);
+}
+
 // Define the class before including platform file, which may specialize
 // the operator definition.  No generic definition of specializations
 // of the operator template are provided, nor are there any generic
 // specializations of the class.  The platform file is responsible for
 // providing those.

@@ -709,11 +679,11 @@
                          cmpxchg_memory_order order) {
   return CmpxchgImpl<T, D, U>()(exchange_value, dest, compare_value, order);
 }
 
 template<typename T, typename D>
-inline bool Atomic::replace_if_null(T* value, D* volatile* dest,
+inline bool Atomic::cmpxchg_if_null(T* value, D* volatile* dest,
                                     cmpxchg_memory_order order) {
   // Presently using a trivial implementation in terms of cmpxchg.
   // Consider adding platform support, to permit the use of compiler
   // intrinsics like gcc's __sync_bool_compare_and_swap.
   D* expected_null = NULL;
< prev index next >