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

Unified Diff: src/base/atomic-utils.h

Issue 2353553003: [heap] Make slot set state and operations atomic. (Closed)
Patch Set: comments Created 4 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | src/heap/slot-set.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/base/atomic-utils.h
diff --git a/src/base/atomic-utils.h b/src/base/atomic-utils.h
index e19385dcb15742909517cb208f048d10dfee9ea7..31db603bf94345bb84ce9ef7b135c513f8f9da3a 100644
--- a/src/base/atomic-utils.h
+++ b/src/base/atomic-utils.h
@@ -72,6 +72,22 @@ class AtomicValue {
cast_helper<T>::to_storage_type(old_value);
}
+ V8_INLINE void SetBits(T bits, T mask) {
+ DCHECK_EQ(bits & ~mask, 0);
+ T old_value;
+ T new_value;
+ do {
+ old_value = Value();
+ new_value = (old_value & ~mask) | bits;
+ } while (!TrySetValue(old_value, new_value));
+ }
+
+ V8_INLINE void SetBit(int bit) {
+ SetBits(static_cast<T>(1) << bit, static_cast<T>(1) << bit);
+ }
+
+ V8_INLINE void ClearBit(int bit) { SetBits(0, 1 << bit); }
+
V8_INLINE void SetValue(T new_value) {
base::Release_Store(&value_, cast_helper<T>::to_storage_type(new_value));
}
« no previous file with comments | « no previous file | src/heap/slot-set.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698