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

Unified Diff: src/heap/marking.h

Issue 2863953002: Revert of [heap] Reland "Make non-atomic markbit operations consistent with atomic ones." (Closed)
Patch Set: Created 3 years, 7 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 | « src/heap/mark-compact-inl.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/heap/marking.h
diff --git a/src/heap/marking.h b/src/heap/marking.h
index ab98a124bc4c77c63f4815b93453a088aad8fae6..b20a4d86f149bb7012d648563e47b90613c9fd5b 100644
--- a/src/heap/marking.h
+++ b/src/heap/marking.h
@@ -38,16 +38,12 @@
}
}
- // The function returns true if it succeeded to
- // transition the bit from 0 to 1.
template <AccessMode mode = NON_ATOMIC>
inline bool Set();
template <AccessMode mode = NON_ATOMIC>
inline bool Get();
- // The function returns true if it succeeded to
- // transition the bit from 1 to 0.
template <AccessMode mode = NON_ATOMIC>
inline bool Clear();
@@ -61,9 +57,8 @@
template <>
inline bool MarkBit::Set<MarkBit::NON_ATOMIC>() {
- base::Atomic32 old_value = *cell_;
- *cell_ = old_value | mask_;
- return (old_value & mask_) == 0;
+ *cell_ |= mask_;
+ return true;
}
template <>
@@ -91,9 +86,8 @@
template <>
inline bool MarkBit::Clear<MarkBit::NON_ATOMIC>() {
- base::Atomic32 old_value = *cell_;
- *cell_ = old_value & ~mask_;
- return (old_value & mask_) == mask_;
+ *cell_ &= ~mask_;
+ return true;
}
template <>
@@ -418,17 +412,24 @@
template <MarkBit::AccessMode mode = MarkBit::NON_ATOMIC>
INLINE(static bool WhiteToGrey(MarkBit markbit)) {
+ DCHECK(mode == MarkBit::ATOMIC || IsWhite(markbit));
return markbit.Set<mode>();
}
- template <MarkBit::AccessMode mode = MarkBit::NON_ATOMIC>
- INLINE(static bool WhiteToBlack(MarkBit markbit)) {
- return markbit.Set<mode>() && markbit.Next().Set<mode>();
+ // Warning: this method is not safe in general in concurrent scenarios.
+ // If you know that nobody else will change the bits on the given location
+ // then you may use it.
+ template <MarkBit::AccessMode mode = MarkBit::NON_ATOMIC>
+ INLINE(static void WhiteToBlack(MarkBit markbit)) {
+ DCHECK(mode == MarkBit::ATOMIC || IsWhite(markbit));
+ markbit.Set<mode>();
+ markbit.Next().Set<mode>();
}
template <MarkBit::AccessMode mode = MarkBit::NON_ATOMIC>
INLINE(static bool GreyToBlack(MarkBit markbit)) {
- return markbit.Get<mode>() && markbit.Next().Set<mode>();
+ DCHECK(mode == MarkBit::ATOMIC || IsGrey(markbit));
+ return markbit.Next().Set<mode>();
}
enum ObjectColor {
« no previous file with comments | « src/heap/mark-compact-inl.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698