< prev index next >

src/hotspot/os_cpu/solaris_sparc/atomic_solaris_sparc.hpp

Print this page
rev 47321 : [mq]: Atomic_loadstore


  10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  12  * version 2 for more details (a copy is included in the LICENSE file that
  13  * accompanied this code).
  14  *
  15  * You should have received a copy of the GNU General Public License version
  16  * 2 along with this work; if not, write to the Free Software Foundation,
  17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  18  *
  19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  *
  23  */
  24 
  25 #ifndef OS_CPU_SOLARIS_SPARC_VM_ATOMIC_SOLARIS_SPARC_HPP
  26 #define OS_CPU_SOLARIS_SPARC_VM_ATOMIC_SOLARIS_SPARC_HPP
  27 
  28 // Implementation of class atomic
  29 
  30 inline void Atomic::store    (jbyte    store_value, jbyte*    dest) { *dest = store_value; }
  31 inline void Atomic::store    (jshort   store_value, jshort*   dest) { *dest = store_value; }
  32 inline void Atomic::store    (jint     store_value, jint*     dest) { *dest = store_value; }
  33 inline void Atomic::store_ptr(intptr_t store_value, intptr_t* dest) { *dest = store_value; }
  34 inline void Atomic::store_ptr(void*    store_value, void*     dest) { *(void**)dest = store_value; }
  35 
  36 inline void Atomic::store    (jbyte    store_value, volatile jbyte*    dest) { *dest = store_value; }
  37 inline void Atomic::store    (jshort   store_value, volatile jshort*   dest) { *dest = store_value; }
  38 inline void Atomic::store    (jint     store_value, volatile jint*     dest) { *dest = store_value; }
  39 inline void Atomic::store_ptr(intptr_t store_value, volatile intptr_t* dest) { *dest = store_value; }
  40 inline void Atomic::store_ptr(void*    store_value, volatile void*     dest) { *(void* volatile *)dest = store_value; }
  41 
  42 inline void Atomic::store(jlong store_value, jlong* dest) { *dest = store_value; }
  43 inline void Atomic::store(jlong store_value, volatile jlong* dest) { *dest = store_value; }
  44 inline jlong Atomic::load(const volatile jlong* src) { return *src; }
  45 
  46 // Implement ADD using a CAS loop.
  47 template<size_t byte_size>
  48 struct Atomic::PlatformAdd VALUE_OBJ_CLASS_SPEC {
  49   template<typename I, typename D>
  50   inline D operator()(I add_value, D volatile* dest) const {
  51     D old_value = *dest;
  52     while (true) {
  53       D new_value = old_value + add_value;
  54       D result = cmpxchg(new_value, dest, old_value);
  55       if (result == old_value) break;
  56       old_value = result;
  57     }
  58     return old_value + add_value;
  59   }
  60 };
  61 
  62 template<>
  63 template<typename T>
  64 inline T Atomic::PlatformXchg<4>::operator()(T exchange_value,
  65                                              T volatile* dest) const {




  10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  12  * version 2 for more details (a copy is included in the LICENSE file that
  13  * accompanied this code).
  14  *
  15  * You should have received a copy of the GNU General Public License version
  16  * 2 along with this work; if not, write to the Free Software Foundation,
  17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  18  *
  19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  *
  23  */
  24 
  25 #ifndef OS_CPU_SOLARIS_SPARC_VM_ATOMIC_SOLARIS_SPARC_HPP
  26 #define OS_CPU_SOLARIS_SPARC_VM_ATOMIC_SOLARIS_SPARC_HPP
  27 
  28 // Implementation of class atomic
  29 
















  30 // Implement ADD using a CAS loop.
  31 template<size_t byte_size>
  32 struct Atomic::PlatformAdd VALUE_OBJ_CLASS_SPEC {
  33   template<typename I, typename D>
  34   inline D operator()(I add_value, D volatile* dest) const {
  35     D old_value = *dest;
  36     while (true) {
  37       D new_value = old_value + add_value;
  38       D result = cmpxchg(new_value, dest, old_value);
  39       if (result == old_value) break;
  40       old_value = result;
  41     }
  42     return old_value + add_value;
  43   }
  44 };
  45 
  46 template<>
  47 template<typename T>
  48 inline T Atomic::PlatformXchg<4>::operator()(T exchange_value,
  49                                              T volatile* dest) const {


< prev index next >