src/hotspot/os_cpu/windows_x86/atomic_windows_x86.hpp
changeset 59252 623722a6aeb9
parent 59251 4cbfa5077d68
equal deleted inserted replaced
59251:4cbfa5077d68 59252:623722a6aeb9
    89 DEFINE_STUB_XCHG(4, int32_t, os::atomic_xchg_func)
    89 DEFINE_STUB_XCHG(4, int32_t, os::atomic_xchg_func)
    90 DEFINE_STUB_XCHG(8, int64_t, os::atomic_xchg_long_func)
    90 DEFINE_STUB_XCHG(8, int64_t, os::atomic_xchg_long_func)
    91 
    91 
    92 #undef DEFINE_STUB_XCHG
    92 #undef DEFINE_STUB_XCHG
    93 
    93 
    94 #define DEFINE_STUB_CMPXCHG(ByteSize, StubType, StubName)               \
    94 #define DEFINE_STUB_CMPXCHG(ByteSize, StubType, StubName)                  \
    95   template<>                                                            \
    95   template<>                                                               \
    96   template<typename T>                                                  \
    96   template<typename T>                                                     \
    97   inline T Atomic::PlatformCmpxchg<ByteSize>::operator()(T exchange_value, \
    97   inline T Atomic::PlatformCmpxchg<ByteSize>::operator()(T volatile* dest, \
    98                                                          T volatile* dest, \
    98                                                          T compare_value,  \
    99                                                          T compare_value, \
    99                                                          T exchange_value, \
   100                                                          atomic_memory_order order) const { \
   100                                                          atomic_memory_order order) const { \
   101     STATIC_ASSERT(ByteSize == sizeof(T));                               \
   101     STATIC_ASSERT(ByteSize == sizeof(T));                                  \
   102     return cmpxchg_using_helper<StubType>(StubName, exchange_value, dest, compare_value); \
   102     return cmpxchg_using_helper<StubType>(StubName, dest, compare_value, exchange_value); \
   103   }
   103   }
   104 
   104 
   105 DEFINE_STUB_CMPXCHG(1, int8_t,  os::atomic_cmpxchg_byte_func)
   105 DEFINE_STUB_CMPXCHG(1, int8_t,  os::atomic_cmpxchg_byte_func)
   106 DEFINE_STUB_CMPXCHG(4, int32_t, os::atomic_cmpxchg_func)
   106 DEFINE_STUB_CMPXCHG(4, int32_t, os::atomic_cmpxchg_func)
   107 DEFINE_STUB_CMPXCHG(8, int64_t, os::atomic_cmpxchg_long_func)
   107 DEFINE_STUB_CMPXCHG(8, int64_t, os::atomic_cmpxchg_long_func)
   139   }
   139   }
   140 }
   140 }
   141 
   141 
   142 template<>
   142 template<>
   143 template<typename T>
   143 template<typename T>
   144 inline T Atomic::PlatformCmpxchg<1>::operator()(T exchange_value,
   144 inline T Atomic::PlatformCmpxchg<1>::operator()(T volatile* dest,
   145                                                 T volatile* dest,
       
   146                                                 T compare_value,
   145                                                 T compare_value,
       
   146                                                 T exchange_value,
   147                                                 atomic_memory_order order) const {
   147                                                 atomic_memory_order order) const {
   148   STATIC_ASSERT(1 == sizeof(T));
   148   STATIC_ASSERT(1 == sizeof(T));
   149   // alternative for InterlockedCompareExchange
   149   // alternative for InterlockedCompareExchange
   150   __asm {
   150   __asm {
   151     mov edx, dest
   151     mov edx, dest
   155   }
   155   }
   156 }
   156 }
   157 
   157 
   158 template<>
   158 template<>
   159 template<typename T>
   159 template<typename T>
   160 inline T Atomic::PlatformCmpxchg<4>::operator()(T exchange_value,
   160 inline T Atomic::PlatformCmpxchg<4>::operator()(T volatile* dest,
   161                                                 T volatile* dest,
       
   162                                                 T compare_value,
   161                                                 T compare_value,
       
   162                                                 T exchange_value,
   163                                                 atomic_memory_order order) const {
   163                                                 atomic_memory_order order) const {
   164   STATIC_ASSERT(4 == sizeof(T));
   164   STATIC_ASSERT(4 == sizeof(T));
   165   // alternative for InterlockedCompareExchange
   165   // alternative for InterlockedCompareExchange
   166   __asm {
   166   __asm {
   167     mov edx, dest
   167     mov edx, dest
   171   }
   171   }
   172 }
   172 }
   173 
   173 
   174 template<>
   174 template<>
   175 template<typename T>
   175 template<typename T>
   176 inline T Atomic::PlatformCmpxchg<8>::operator()(T exchange_value,
   176 inline T Atomic::PlatformCmpxchg<8>::operator()(T volatile* dest,
   177                                                 T volatile* dest,
       
   178                                                 T compare_value,
   177                                                 T compare_value,
       
   178                                                 T exchange_value,
   179                                                 atomic_memory_order order) const {
   179                                                 atomic_memory_order order) const {
   180   STATIC_ASSERT(8 == sizeof(T));
   180   STATIC_ASSERT(8 == sizeof(T));
   181   int32_t ex_lo  = (int32_t)exchange_value;
   181   int32_t ex_lo  = (int32_t)exchange_value;
   182   int32_t ex_hi  = *( ((int32_t*)&exchange_value) + 1 );
   182   int32_t ex_hi  = *( ((int32_t*)&exchange_value) + 1 );
   183   int32_t cmp_lo = (int32_t)compare_value;
   183   int32_t cmp_lo = (int32_t)compare_value;