src/hotspot/os_cpu/linux_sparc/atomic_linux_sparc.hpp
changeset 50029 ea0a16ba6ac0
parent 47593 2d56326b98f0
child 53244 9807daeb47c4
equal deleted inserted replaced
50028:28eaf7a99a8c 50029:ea0a16ba6ac0
     1 /*
     1 /*
     2  * Copyright (c) 1999, 2017, Oracle and/or its affiliates. All rights reserved.
     2  * Copyright (c) 1999, 2018, Oracle and/or its affiliates. All rights reserved.
     3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     4  *
     4  *
     5  * This code is free software; you can redistribute it and/or modify it
     5  * This code is free software; you can redistribute it and/or modify it
     6  * under the terms of the GNU General Public License version 2 only, as
     6  * under the terms of the GNU General Public License version 2 only, as
     7  * published by the Free Software Foundation.
     7  * published by the Free Software Foundation.
    30 template<size_t byte_size>
    30 template<size_t byte_size>
    31 struct Atomic::PlatformAdd
    31 struct Atomic::PlatformAdd
    32   : Atomic::AddAndFetch<Atomic::PlatformAdd<byte_size> >
    32   : Atomic::AddAndFetch<Atomic::PlatformAdd<byte_size> >
    33 {
    33 {
    34   template<typename I, typename D>
    34   template<typename I, typename D>
    35   D add_and_fetch(I add_value, D volatile* dest) const;
    35   D add_and_fetch(I add_value, D volatile* dest, atomic_memory_order order) const;
    36 };
    36 };
    37 
    37 
    38 template<>
    38 template<>
    39 template<typename I, typename D>
    39 template<typename I, typename D>
    40 inline D Atomic::PlatformAdd<4>::add_and_fetch(I add_value, D volatile* dest) const {
    40 inline D Atomic::PlatformAdd<4>::add_and_fetch(I add_value, D volatile* dest,
       
    41                                                atomic_memory_order order) const {
    41   STATIC_ASSERT(4 == sizeof(I));
    42   STATIC_ASSERT(4 == sizeof(I));
    42   STATIC_ASSERT(4 == sizeof(D));
    43   STATIC_ASSERT(4 == sizeof(D));
    43 
    44 
    44   D rv;
    45   D rv;
    45   __asm__ volatile(
    46   __asm__ volatile(
    57   return rv;
    58   return rv;
    58 }
    59 }
    59 
    60 
    60 template<>
    61 template<>
    61 template<typename I, typename D>
    62 template<typename I, typename D>
    62 inline D Atomic::PlatformAdd<8>::add_and_fetch(I add_value, D volatile* dest) const {
    63 inline D Atomic::PlatformAdd<8>::add_and_fetch(I add_value, D volatile* dest,
       
    64                                                atomic_memory_order order) const {
    63   STATIC_ASSERT(8 == sizeof(I));
    65   STATIC_ASSERT(8 == sizeof(I));
    64   STATIC_ASSERT(8 == sizeof(D));
    66   STATIC_ASSERT(8 == sizeof(D));
    65 
    67 
    66   D rv;
    68   D rv;
    67   __asm__ volatile(
    69   __asm__ volatile(
    80 }
    82 }
    81 
    83 
    82 template<>
    84 template<>
    83 template<typename T>
    85 template<typename T>
    84 inline T Atomic::PlatformXchg<4>::operator()(T exchange_value,
    86 inline T Atomic::PlatformXchg<4>::operator()(T exchange_value,
    85                                              T volatile* dest) const {
    87                                              T volatile* dest,
       
    88                                              atomic_memory_order order) const {
    86   STATIC_ASSERT(4 == sizeof(T));
    89   STATIC_ASSERT(4 == sizeof(T));
    87   T rv = exchange_value;
    90   T rv = exchange_value;
    88   __asm__ volatile(
    91   __asm__ volatile(
    89     " swap   [%2],%1\n\t"
    92     " swap   [%2],%1\n\t"
    90     : "=r" (rv)
    93     : "=r" (rv)
    94 }
    97 }
    95 
    98 
    96 template<>
    99 template<>
    97 template<typename T>
   100 template<typename T>
    98 inline T Atomic::PlatformXchg<8>::operator()(T exchange_value,
   101 inline T Atomic::PlatformXchg<8>::operator()(T exchange_value,
    99                                              T volatile* dest) const {
   102                                              T volatile* dest,
       
   103                                              atomic_memory_order order) const {
   100   STATIC_ASSERT(8 == sizeof(T));
   104   STATIC_ASSERT(8 == sizeof(T));
   101   T rv = exchange_value;
   105   T rv = exchange_value;
   102   __asm__ volatile(
   106   __asm__ volatile(
   103     "1:\n\t"
   107     "1:\n\t"
   104     " mov    %1, %%o3\n\t"
   108     " mov    %1, %%o3\n\t"
   121 template<>
   125 template<>
   122 template<typename T>
   126 template<typename T>
   123 inline T Atomic::PlatformCmpxchg<4>::operator()(T exchange_value,
   127 inline T Atomic::PlatformCmpxchg<4>::operator()(T exchange_value,
   124                                                 T volatile* dest,
   128                                                 T volatile* dest,
   125                                                 T compare_value,
   129                                                 T compare_value,
   126                                                 cmpxchg_memory_order order) const {
   130                                                 atomic_memory_order order) const {
   127   STATIC_ASSERT(4 == sizeof(T));
   131   STATIC_ASSERT(4 == sizeof(T));
   128   T rv;
   132   T rv;
   129   __asm__ volatile(
   133   __asm__ volatile(
   130     " cas    [%2], %3, %0"
   134     " cas    [%2], %3, %0"
   131     : "=r" (rv)
   135     : "=r" (rv)
   137 template<>
   141 template<>
   138 template<typename T>
   142 template<typename T>
   139 inline T Atomic::PlatformCmpxchg<8>::operator()(T exchange_value,
   143 inline T Atomic::PlatformCmpxchg<8>::operator()(T exchange_value,
   140                                                 T volatile* dest,
   144                                                 T volatile* dest,
   141                                                 T compare_value,
   145                                                 T compare_value,
   142                                                 cmpxchg_memory_order order) const {
   146                                                 atomic_memory_order order) const {
   143   STATIC_ASSERT(8 == sizeof(T));
   147   STATIC_ASSERT(8 == sizeof(T));
   144   T rv;
   148   T rv;
   145   __asm__ volatile(
   149   __asm__ volatile(
   146     " casx   [%2], %3, %0"
   150     " casx   [%2], %3, %0"
   147     : "=r" (rv)
   151     : "=r" (rv)