Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(242)

Side by Side Diff: src/base/atomic-utils.h

Issue 2912773002: Rename "NoBarrier" memory operations to "Relaxed". (Closed)
Patch Set: more Created 3 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | src/base/atomicops.h » ('j') | src/base/atomicops.h » ('J')
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2015 the V8 project authors. All rights reserved. 1 // Copyright 2015 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef V8_ATOMIC_UTILS_H_ 5 #ifndef V8_ATOMIC_UTILS_H_
6 #define V8_ATOMIC_UTILS_H_ 6 #define V8_ATOMIC_UTILS_H_
7 7
8 #include <limits.h> 8 #include <limits.h>
9 9
10 #include "src/base/atomicops.h" 10 #include "src/base/atomicops.h"
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
61 NoBarrierAtomicValue() : value_(0) {} 61 NoBarrierAtomicValue() : value_(0) {}
62 62
63 explicit NoBarrierAtomicValue(T initial) 63 explicit NoBarrierAtomicValue(T initial)
64 : value_(cast_helper<T>::to_storage_type(initial)) {} 64 : value_(cast_helper<T>::to_storage_type(initial)) {}
65 65
66 static NoBarrierAtomicValue* FromAddress(void* address) { 66 static NoBarrierAtomicValue* FromAddress(void* address) {
67 return reinterpret_cast<base::NoBarrierAtomicValue<T>*>(address); 67 return reinterpret_cast<base::NoBarrierAtomicValue<T>*>(address);
68 } 68 }
69 69
70 V8_INLINE bool TrySetValue(T old_value, T new_value) { 70 V8_INLINE bool TrySetValue(T old_value, T new_value) {
71 return base::NoBarrier_CompareAndSwap( 71 return base::Relaxed_CompareAndSwap(
72 &value_, cast_helper<T>::to_storage_type(old_value), 72 &value_, cast_helper<T>::to_storage_type(old_value),
73 cast_helper<T>::to_storage_type(new_value)) == 73 cast_helper<T>::to_storage_type(new_value)) ==
74 cast_helper<T>::to_storage_type(old_value); 74 cast_helper<T>::to_storage_type(old_value);
75 } 75 }
76 76
77 V8_INLINE T Value() const { 77 V8_INLINE T Value() const {
78 return cast_helper<T>::to_return_type(base::NoBarrier_Load(&value_)); 78 return cast_helper<T>::to_return_type(base::Relaxed_Load(&value_));
79 } 79 }
80 80
81 V8_INLINE void SetValue(T new_value) { 81 V8_INLINE void SetValue(T new_value) {
82 base::NoBarrier_Store(&value_, cast_helper<T>::to_storage_type(new_value)); 82 base::Relaxed_Store(&value_, cast_helper<T>::to_storage_type(new_value));
83 } 83 }
84 84
85 private: 85 private:
86 STATIC_ASSERT(sizeof(T) <= sizeof(base::AtomicWord)); 86 STATIC_ASSERT(sizeof(T) <= sizeof(base::AtomicWord));
87 87
88 template <typename S> 88 template <typename S>
89 struct cast_helper { 89 struct cast_helper {
90 static base::AtomicWord to_storage_type(S value) { 90 static base::AtomicWord to_storage_type(S value) {
91 return static_cast<base::AtomicWord>(value); 91 return static_cast<base::AtomicWord>(value);
92 } 92 }
(...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after
247 return static_cast<base::AtomicWord>(1) << element; 247 return static_cast<base::AtomicWord>(1) << element;
248 } 248 }
249 249
250 base::AtomicWord bits_; 250 base::AtomicWord bits_;
251 }; 251 };
252 252
253 } // namespace base 253 } // namespace base
254 } // namespace v8 254 } // namespace v8
255 255
256 #endif // #define V8_ATOMIC_UTILS_H_ 256 #endif // #define V8_ATOMIC_UTILS_H_
OLDNEW
« no previous file with comments | « no previous file | src/base/atomicops.h » ('j') | src/base/atomicops.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698