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

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

Issue 1340323002: Revert of [heap] Concurrency support for heap book-keeping info (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 5 years, 3 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/heap/spaces.h » ('j') | no next file with comments »
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 12 matching lines...) Expand all
23 base::NoBarrier_AtomicIncrement(&value_, 23 base::NoBarrier_AtomicIncrement(&value_,
24 static_cast<base::AtomicWord>(increment)); 24 static_cast<base::AtomicWord>(increment));
25 } 25 }
26 26
27 V8_INLINE T Value() { return static_cast<T>(base::NoBarrier_Load(&value_)); } 27 V8_INLINE T Value() { return static_cast<T>(base::NoBarrier_Load(&value_)); }
28 28
29 V8_INLINE void SetValue(T new_value) { 29 V8_INLINE void SetValue(T new_value) {
30 base::NoBarrier_Store(&value_, static_cast<base::AtomicWord>(new_value)); 30 base::NoBarrier_Store(&value_, static_cast<base::AtomicWord>(new_value));
31 } 31 }
32 32
33 V8_INLINE T operator=(T value) {
34 SetValue(value);
35 return value;
36 }
37
38 private: 33 private:
39 STATIC_ASSERT(sizeof(T) <= sizeof(base::AtomicWord)); 34 STATIC_ASSERT(sizeof(T) <= sizeof(base::AtomicWord));
40 35
41 base::AtomicWord value_; 36 base::AtomicWord value_;
42 }; 37 };
43 38
44 39
45 // Flag using T atomically. Also accepts void* as T. 40 // Flag using T atomically. Also accepts void* as T.
46 template <typename T> 41 template <typename T>
47 class AtomicValue { 42 class AtomicValue {
48 public: 43 public:
49 AtomicValue() : value_(0) {}
50
51 explicit AtomicValue(T initial) 44 explicit AtomicValue(T initial)
52 : value_(cast_helper<T>::to_storage_type(initial)) {} 45 : value_(cast_helper<T>::to_storage_type(initial)) {}
53 46
54 V8_INLINE T Value() { 47 V8_INLINE T Value() {
55 return cast_helper<T>::to_return_type(base::NoBarrier_Load(&value_)); 48 return cast_helper<T>::to_return_type(base::NoBarrier_Load(&value_));
56 } 49 }
57 50
58 V8_INLINE bool TrySetValue(T old_value, T new_value) { 51 V8_INLINE bool TrySetValue(T old_value, T new_value) {
59 return base::NoBarrier_CompareAndSwap( 52 return base::NoBarrier_CompareAndSwap(
60 &value_, cast_helper<T>::to_storage_type(old_value), 53 &value_, cast_helper<T>::to_storage_type(old_value),
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after
167 return static_cast<base::AtomicWord>(1) << element; 160 return static_cast<base::AtomicWord>(1) << element;
168 } 161 }
169 162
170 base::AtomicWord bits_; 163 base::AtomicWord bits_;
171 }; 164 };
172 165
173 } // namespace internal 166 } // namespace internal
174 } // namespace v8 167 } // namespace v8
175 168
176 #endif // #define V8_ATOMIC_UTILS_H_ 169 #endif // #define V8_ATOMIC_UTILS_H_
OLDNEW
« no previous file with comments | « no previous file | src/heap/spaces.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698