< prev index next >

src/os_cpu/bsd_x86/vm/atomic_bsd_x86.hpp

Print this page
rev 13323 : imported patch Atomic_refactoring
rev 13325 : imported patch Atomic_polishing_v2
rev 13327 : [mq]: SpecializableAtomic

*** 27,215 **** #include "runtime/os.hpp" // Implementation of class atomic ! inline void Atomic::store (jbyte store_value, jbyte* dest) { *dest = store_value; } ! inline void Atomic::store (jshort store_value, jshort* dest) { *dest = store_value; } ! inline void Atomic::store (jint store_value, jint* dest) { *dest = store_value; } ! inline void Atomic::store_ptr(intptr_t store_value, intptr_t* dest) { *dest = store_value; } ! inline void Atomic::store_ptr(void* store_value, void* dest) { *(void**)dest = store_value; } ! ! inline void Atomic::store (jbyte store_value, volatile jbyte* dest) { *dest = store_value; } ! inline void Atomic::store (jshort store_value, volatile jshort* dest) { *dest = store_value; } ! inline void Atomic::store (jint store_value, volatile jint* dest) { *dest = store_value; } ! 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; } ! ! ! inline jint Atomic::add (jint add_value, volatile jint* dest) { ! jint addend = add_value; __asm__ volatile ( "lock xaddl %0,(%2)" : "=r" (addend) : "0" (addend), "r" (dest) : "cc", "memory"); return addend + add_value; } ! inline void Atomic::inc (volatile jint* dest) { __asm__ volatile ( "lock addl $1,(%0)" : : "r" (dest) : "cc", "memory"); } ! inline void Atomic::inc_ptr(volatile void* dest) { ! inc_ptr((volatile intptr_t*)dest); ! } ! ! inline void Atomic::dec (volatile jint* dest) { __asm__ volatile ( "lock subl $1,(%0)" : : "r" (dest) : "cc", "memory"); } ! inline void Atomic::dec_ptr(volatile void* dest) { ! dec_ptr((volatile intptr_t*)dest); ! } ! ! inline jint Atomic::xchg (jint exchange_value, volatile jint* dest) { __asm__ volatile ( "xchgl (%2),%0" : "=r" (exchange_value) : "0" (exchange_value), "r" (dest) : "memory"); return exchange_value; } - inline void* Atomic::xchg_ptr(void* exchange_value, volatile void* dest) { - return (void*)xchg_ptr((intptr_t)exchange_value, (volatile intptr_t*)dest); - } - #define VM_HAS_SPECIALIZED_CMPXCHG_BYTE ! inline jbyte Atomic::cmpxchg (jbyte exchange_value, volatile jbyte* dest, jbyte compare_value, cmpxchg_memory_order order) { ! __asm__ volatile ( "lock cmpxchgb %1,(%3)" : "=a" (exchange_value) : "q" (exchange_value), "a" (compare_value), "r" (dest) : "cc", "memory"); return exchange_value; } ! inline jint Atomic::cmpxchg (jint exchange_value, volatile jint* dest, jint compare_value, cmpxchg_memory_order order) { ! __asm__ volatile ( "lock cmpxchgl %1,(%3)" : "=a" (exchange_value) : "r" (exchange_value), "a" (compare_value), "r" (dest) : "cc", "memory"); return exchange_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 intptr_t Atomic::add_ptr(intptr_t add_value, volatile intptr_t* dest) { ! intptr_t addend = add_value; ! __asm__ __volatile__ ( "lock xaddq %0,(%2)" : "=r" (addend) : "0" (addend), "r" (dest) : "cc", "memory"); return addend + add_value; } ! inline void* Atomic::add_ptr(intptr_t add_value, volatile void* dest) { ! return (void*)add_ptr(add_value, (volatile intptr_t*)dest); ! } ! ! inline void Atomic::inc_ptr(volatile intptr_t* dest) { ! __asm__ __volatile__ ( "lock addq $1,(%0)" : : "r" (dest) : "cc", "memory"); } ! inline void Atomic::dec_ptr(volatile intptr_t* dest) { ! __asm__ __volatile__ ( "lock subq $1,(%0)" : : "r" (dest) : "cc", "memory"); } ! inline intptr_t Atomic::xchg_ptr(intptr_t exchange_value, volatile intptr_t* dest) { __asm__ __volatile__ ("xchgq (%2),%0" : "=r" (exchange_value) : "0" (exchange_value), "r" (dest) : "memory"); return exchange_value; } ! inline jlong Atomic::cmpxchg (jlong exchange_value, volatile jlong* dest, jlong compare_value, cmpxchg_memory_order order) { ! __asm__ __volatile__ ( "lock cmpxchgq %1,(%3)" : "=a" (exchange_value) : "r" (exchange_value), "a" (compare_value), "r" (dest) : "cc", "memory"); return exchange_value; } - inline intptr_t Atomic::cmpxchg_ptr(intptr_t exchange_value, volatile intptr_t* dest, intptr_t compare_value, cmpxchg_memory_order order) { - return (intptr_t)cmpxchg((jlong)exchange_value, (volatile jlong*)dest, (jlong)compare_value, order); - } - - inline void* Atomic::cmpxchg_ptr(void* exchange_value, volatile void* dest, void* compare_value, cmpxchg_memory_order order) { - return (void*)cmpxchg((jlong)exchange_value, (volatile jlong*)dest, (jlong)compare_value, order); - } - - inline jlong Atomic::load(const volatile jlong* src) { return *src; } - #else // !AMD64 - inline intptr_t Atomic::add_ptr(intptr_t add_value, volatile intptr_t* dest) { - return (intptr_t)Atomic::add((jint)add_value, (volatile jint*)dest); - } - - inline void* Atomic::add_ptr(intptr_t add_value, volatile void* dest) { - return (void*)Atomic::add((jint)add_value, (volatile jint*)dest); - } - - - inline void Atomic::inc_ptr(volatile intptr_t* dest) { - inc((volatile jint*)dest); - } - - inline void Atomic::dec_ptr(volatile intptr_t* dest) { - dec((volatile jint*)dest); - } - - inline intptr_t Atomic::xchg_ptr(intptr_t exchange_value, volatile intptr_t* dest) { - return (intptr_t)xchg((jint)exchange_value, (volatile jint*)dest); - } - extern "C" { // defined in bsd_x86.s ! jlong _Atomic_cmpxchg_long(jlong, volatile jlong*, jlong, bool); ! void _Atomic_move_long(const volatile jlong* src, volatile jlong* dst); ! } ! ! inline jlong Atomic::cmpxchg (jlong exchange_value, volatile jlong* dest, jlong compare_value, cmpxchg_memory_order order) { ! return _Atomic_cmpxchg_long(exchange_value, dest, compare_value, os::is_MP()); } ! inline intptr_t Atomic::cmpxchg_ptr(intptr_t exchange_value, volatile intptr_t* dest, intptr_t compare_value, cmpxchg_memory_order order) { ! return (intptr_t)cmpxchg((jint)exchange_value, (volatile jint*)dest, (jint)compare_value, order); } ! inline void* Atomic::cmpxchg_ptr(void* exchange_value, volatile void* dest, void* compare_value, cmpxchg_memory_order order) { ! return (void*)cmpxchg((jint)exchange_value, (volatile jint*)dest, (jint)compare_value, order); ! } ! ! inline jlong Atomic::load(const volatile jlong* src) { ! volatile jlong dest; _Atomic_move_long(src, &dest); return dest; } ! inline void Atomic::store(jlong store_value, jlong* dest) { ! _Atomic_move_long((volatile jlong*)&store_value, (volatile jlong*)dest); ! } ! ! inline void Atomic::store(jlong store_value, volatile jlong* dest) { ! _Atomic_move_long((volatile jlong*)&store_value, dest); } #endif // AMD64 #endif // OS_CPU_BSD_X86_VM_ATOMIC_BSD_X86_HPP --- 27,155 ---- #include "runtime/os.hpp" // Implementation of class atomic ! template <> ! inline int32_t GeneralizedAtomic::specialized_add<int32_t>(int32_t add_value, volatile int32_t* dest) { ! int32_t addend = add_value; __asm__ volatile ( "lock xaddl %0,(%2)" : "=r" (addend) : "0" (addend), "r" (dest) : "cc", "memory"); return addend + add_value; } ! template <> ! inline void GeneralizedAtomic::specialized_inc<int32_t>(volatile int32_t* dest) { __asm__ volatile ( "lock addl $1,(%0)" : : "r" (dest) : "cc", "memory"); } ! template <> ! inline void GeneralizedAtomic::specialized_dec<int32_t>(volatile int32_t* dest) { __asm__ volatile ( "lock subl $1,(%0)" : : "r" (dest) : "cc", "memory"); } ! template <> ! inline int32_t GeneralizedAtomic::specialized_xchg<int32_t>(int32_t exchange_value, volatile int32_t* dest) { __asm__ volatile ( "xchgl (%2),%0" : "=r" (exchange_value) : "0" (exchange_value), "r" (dest) : "memory"); return exchange_value; } #define VM_HAS_SPECIALIZED_CMPXCHG_BYTE ! template <> ! inline int8_t GeneralizedAtomic::specialized_cmpxchg<int8_t>(int8_t exchange_value, volatile int8_t* dest, int8_t compare_value, cmpxchg_memory_order order) { ! __asm__ volatile ("lock cmpxchgb %1,(%3)" : "=a" (exchange_value) : "q" (exchange_value), "a" (compare_value), "r" (dest) : "cc", "memory"); return exchange_value; } ! template <> ! inline int32_t GeneralizedAtomic::specialized_cmpxchg<int32_t>(int32_t exchange_value, volatile int32_t* dest, int32_t compare_value, cmpxchg_memory_order order) { ! __asm__ volatile ("lock cmpxchgl %1,(%3)" : "=a" (exchange_value) : "r" (exchange_value), "a" (compare_value), "r" (dest) : "cc", "memory"); return exchange_value; } #ifdef AMD64 ! template <> ! inline int64_t GeneralizedAtomic::specialized_add<int64_t>(int64_t add_value, volatile int64_t* dest) { ! int64_t addend = add_value; ! __asm__ __volatile__ ("lock xaddq %0,(%2)" : "=r" (addend) : "0" (addend), "r" (dest) : "cc", "memory"); return addend + add_value; } ! template <> ! inline void GeneralizedAtomic::specialized_inc<int64_t>(volatile int64_t* dest) { ! __asm__ __volatile__ ("lock addq $1,(%0)" : : "r" (dest) : "cc", "memory"); } ! template <> ! inline void GeneralizedAtomic::specialized_dec<int64_t>(volatile int64_t* dest) { ! __asm__ __volatile__ ("lock subq $1,(%0)" : : "r" (dest) : "cc", "memory"); } ! template <> ! inline int64_t GeneralizedAtomic::specialized_xchg<int64_t>(int64_t exchange_value, volatile int64_t* dest) { __asm__ __volatile__ ("xchgq (%2),%0" : "=r" (exchange_value) : "0" (exchange_value), "r" (dest) : "memory"); return exchange_value; } ! template <> ! inline int64_t GeneralizedAtomic::specialized_cmpxchg<int64_t>(int64_t exchange_value, volatile int64_t* dest, int64_t compare_value, cmpxchg_memory_order order) { ! __asm__ __volatile__ ("lock cmpxchgq %1,(%3)" : "=a" (exchange_value) : "r" (exchange_value), "a" (compare_value), "r" (dest) : "cc", "memory"); return exchange_value; } #else // !AMD64 extern "C" { // defined in bsd_x86.s ! int64_t _Atomic_cmpxchg_long(int64_t, volatile int64_t*, int64_t); ! void _Atomic_move_long(const volatile int64_t* src, volatile int64_t* dst); } ! template <> ! inline void GeneralizedAtomic::specialized_store<int64_t>(int64_t store_value, volatile int64_t* dest) { ! _Atomic_move_long(&store_value, dest); } ! template <> ! inline int64_t GeneralizedAtomic::specialized_load<int64_t>(const volatile int64_t* src) { ! volatile int64_t dest; _Atomic_move_long(src, &dest); return dest; } ! template <> ! inline int64_t GeneralizedAtomic::specialized_cmpxchg<int64_t>(int64_t exchange_value, volatile int64_t* dest, int64_t compare_value, cmpxchg_memory_order order) { ! return _Atomic_cmpxchg_long(exchange_value, dest, compare_value); } #endif // AMD64 #endif // OS_CPU_BSD_X86_VM_ATOMIC_BSD_X86_HPP
< prev index next >