src/hotspot/share/oops/accessBackend.inline.hpp
changeset 59252 623722a6aeb9
parent 59251 4cbfa5077d68
child 59290 97d13893ec3c
equal deleted inserted replaced
59251:4cbfa5077d68 59252:623722a6aeb9
    83   return oop_load<T>(field_addr(base, offset));
    83   return oop_load<T>(field_addr(base, offset));
    84 }
    84 }
    85 
    85 
    86 template <DecoratorSet decorators>
    86 template <DecoratorSet decorators>
    87 template <typename T>
    87 template <typename T>
    88 inline T RawAccessBarrier<decorators>::oop_atomic_cmpxchg(T new_value, void* addr, T compare_value) {
    88 inline T RawAccessBarrier<decorators>::oop_atomic_cmpxchg(void* addr, T compare_value, T new_value) {
    89   typedef typename AccessInternal::EncodedType<decorators, T>::type Encoded;
    89   typedef typename AccessInternal::EncodedType<decorators, T>::type Encoded;
    90   Encoded encoded_new = encode(new_value);
    90   Encoded encoded_new = encode(new_value);
    91   Encoded encoded_compare = encode(compare_value);
    91   Encoded encoded_compare = encode(compare_value);
    92   Encoded encoded_result = atomic_cmpxchg(encoded_new,
    92   Encoded encoded_result = atomic_cmpxchg(reinterpret_cast<Encoded*>(addr),
    93                                           reinterpret_cast<Encoded*>(addr),
    93                                           encoded_compare,
    94                                           encoded_compare);
    94                                           encoded_new);
    95   return decode<T>(encoded_result);
    95   return decode<T>(encoded_result);
    96 }
    96 }
    97 
    97 
    98 template <DecoratorSet decorators>
    98 template <DecoratorSet decorators>
    99 template <typename T>
    99 template <typename T>
   100 inline T RawAccessBarrier<decorators>::oop_atomic_cmpxchg_at(T new_value, oop base, ptrdiff_t offset, T compare_value) {
   100 inline T RawAccessBarrier<decorators>::oop_atomic_cmpxchg_at(oop base, ptrdiff_t offset, T compare_value, T new_value) {
   101   return oop_atomic_cmpxchg(new_value, field_addr(base, offset), compare_value);
   101   return oop_atomic_cmpxchg(field_addr(base, offset), compare_value, new_value);
   102 }
   102 }
   103 
   103 
   104 template <DecoratorSet decorators>
   104 template <DecoratorSet decorators>
   105 template <typename T>
   105 template <typename T>
   106 inline T RawAccessBarrier<decorators>::oop_atomic_xchg(void* addr, T new_value) {
   106 inline T RawAccessBarrier<decorators>::oop_atomic_xchg(void* addr, T new_value) {
   179 
   179 
   180 template <DecoratorSet decorators>
   180 template <DecoratorSet decorators>
   181 template <DecoratorSet ds, typename T>
   181 template <DecoratorSet ds, typename T>
   182 inline typename EnableIf<
   182 inline typename EnableIf<
   183   HasDecorator<ds, MO_RELAXED>::value, T>::type
   183   HasDecorator<ds, MO_RELAXED>::value, T>::type
   184 RawAccessBarrier<decorators>::atomic_cmpxchg_internal(T new_value, void* addr, T compare_value) {
   184 RawAccessBarrier<decorators>::atomic_cmpxchg_internal(void* addr, T compare_value, T new_value) {
   185   return Atomic::cmpxchg(new_value,
   185   return Atomic::cmpxchg(reinterpret_cast<volatile T*>(addr),
   186                          reinterpret_cast<volatile T*>(addr),
       
   187                          compare_value,
   186                          compare_value,
       
   187                          new_value,
   188                          memory_order_relaxed);
   188                          memory_order_relaxed);
   189 }
   189 }
   190 
   190 
   191 template <DecoratorSet decorators>
   191 template <DecoratorSet decorators>
   192 template <DecoratorSet ds, typename T>
   192 template <DecoratorSet ds, typename T>
   193 inline typename EnableIf<
   193 inline typename EnableIf<
   194   HasDecorator<ds, MO_SEQ_CST>::value, T>::type
   194   HasDecorator<ds, MO_SEQ_CST>::value, T>::type
   195 RawAccessBarrier<decorators>::atomic_cmpxchg_internal(T new_value, void* addr, T compare_value) {
   195 RawAccessBarrier<decorators>::atomic_cmpxchg_internal(void* addr, T compare_value, T new_value) {
   196   return Atomic::cmpxchg(new_value,
   196   return Atomic::cmpxchg(reinterpret_cast<volatile T*>(addr),
   197                          reinterpret_cast<volatile T*>(addr),
       
   198                          compare_value,
   197                          compare_value,
       
   198                          new_value,
   199                          memory_order_conservative);
   199                          memory_order_conservative);
   200 }
   200 }
   201 
   201 
   202 template <DecoratorSet decorators>
   202 template <DecoratorSet decorators>
   203 template <DecoratorSet ds, typename T>
   203 template <DecoratorSet ds, typename T>
   230 
   230 
   231 template <DecoratorSet ds>
   231 template <DecoratorSet ds>
   232 template <DecoratorSet decorators, typename T>
   232 template <DecoratorSet decorators, typename T>
   233 inline typename EnableIf<
   233 inline typename EnableIf<
   234   AccessInternal::PossiblyLockedAccess<T>::value, T>::type
   234   AccessInternal::PossiblyLockedAccess<T>::value, T>::type
   235 RawAccessBarrier<ds>::atomic_cmpxchg_maybe_locked(T new_value, void* addr, T compare_value) {
   235 RawAccessBarrier<ds>::atomic_cmpxchg_maybe_locked(void* addr, T compare_value, T new_value) {
   236   if (!AccessInternal::wide_atomic_needs_locking()) {
   236   if (!AccessInternal::wide_atomic_needs_locking()) {
   237     return atomic_cmpxchg_internal<ds>(new_value, addr, compare_value);
   237     return atomic_cmpxchg_internal<ds>(addr, compare_value, new_value);
   238   } else {
   238   } else {
   239     AccessInternal::AccessLocker access_lock;
   239     AccessInternal::AccessLocker access_lock;
   240     volatile T* p = reinterpret_cast<volatile T*>(addr);
   240     volatile T* p = reinterpret_cast<volatile T*>(addr);
   241     T old_val = RawAccess<>::load(p);
   241     T old_val = RawAccess<>::load(p);
   242     if (old_val == compare_value) {
   242     if (old_val == compare_value) {