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

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

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

Powered by Google App Engine
This is Rietveld 408576698