< prev index next >

src/os_cpu/windows_x86/vm/atomic_windows_x86.hpp

Print this page
rev 13452 : imported patch Atomic_cmpxchg
rev 13453 : imported patch Atomic_add
rev 13454 : [mq]: Atomic_add_v2

*** 55,78 **** inline void Atomic::store_ptr(intptr_t store_value, volatile intptr_t* dest) { *dest = store_value; } inline void Atomic::store_ptr(void* store_value, volatile void* dest) { *(void* volatile *)dest = store_value; } #ifdef AMD64 inline void Atomic::store (jlong store_value, jlong* dest) { *dest = store_value; } inline void Atomic::store (jlong store_value, volatile jlong* dest) { *dest = store_value; } ! inline jint Atomic::add (jint add_value, volatile jint* dest) { ! return (jint)(*os::atomic_add_func)(add_value, dest); ! } ! ! inline intptr_t Atomic::add_ptr(intptr_t add_value, volatile intptr_t* dest) { ! return (intptr_t)(*os::atomic_add_ptr_func)(add_value, dest); } ! inline void* Atomic::add_ptr(intptr_t add_value, volatile void* dest) { ! return (void*)(*os::atomic_add_ptr_func)(add_value, (volatile intptr_t*)dest); } inline void Atomic::inc (volatile jint* dest) { (void)add (1, dest); } --- 55,89 ---- inline void Atomic::store_ptr(intptr_t store_value, volatile intptr_t* dest) { *dest = store_value; } inline void Atomic::store_ptr(void* store_value, volatile void* dest) { *(void* volatile *)dest = store_value; } + template<size_t byte_size> + struct Atomic::PlatformAdd + : Atomic::AddAndFetch<Atomic::PlatformAdd<byte_size> > + { + template<typename I, typename D> + D add_and_fetch(I add_value, D volatile* dest) const; + }; + + template<> + struct Atomic::PlatformAdd<2>: Atomic::AddShortUsingInt {}; + #ifdef AMD64 inline void Atomic::store (jlong store_value, jlong* dest) { *dest = store_value; } inline void Atomic::store (jlong store_value, volatile jlong* dest) { *dest = store_value; } ! template<> ! template<typename I, typename D> ! inline D Atomic::PlatformAdd<4>::add_and_fetch(I add_value, D volatile* dest) const { ! return add_using_helper<jint>(os::atomic_add_func, add_value, dest); } ! template<> ! template<typename I, typename D> ! inline D Atomic::PlatformAdd<8>::add_and_fetch(I add_value, D volatile* dest) const { ! return add_using_helper<intptr_t>(os::atomic_add_ptr_func, add_value, dest); } inline void Atomic::inc (volatile jint* dest) { (void)add (1, dest); }
*** 128,155 **** inline jlong Atomic::load(const volatile jlong* src) { return *src; } #else // !AMD64 ! inline jint Atomic::add (jint add_value, volatile jint* dest) { __asm { mov edx, dest; mov eax, add_value; mov ecx, eax; lock xadd dword ptr [edx], eax; add eax, ecx; } } - inline intptr_t Atomic::add_ptr(intptr_t add_value, volatile intptr_t* dest) { - return (intptr_t)add((jint)add_value, (volatile jint*)dest); - } - - inline void* Atomic::add_ptr(intptr_t add_value, volatile void* dest) { - return (void*)add((jint)add_value, (volatile jint*)dest); - } - inline void Atomic::inc (volatile jint* dest) { // alternative for InterlockedIncrement __asm { mov edx, dest; lock add dword ptr [edx], 1; --- 139,162 ---- inline jlong Atomic::load(const volatile jlong* src) { return *src; } #else // !AMD64 ! template<> ! template<typename I, typename D> ! inline D Atomic::PlatformAdd<4>::add_and_fetch(I add_value, D volatile* dest) const { ! STATIC_ASSERT(4 == sizeof(I)); ! STATIC_ASSERT(4 == sizeof(D)); __asm { mov edx, dest; mov eax, add_value; mov ecx, eax; lock xadd dword ptr [edx], eax; add eax, ecx; } } inline void Atomic::inc (volatile jint* dest) { // alternative for InterlockedIncrement __asm { mov edx, dest; lock add dword ptr [edx], 1;
< prev index next >