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

Unified Diff: src/heap/marking.h

Issue 2857713002: [heap] Make non-atomic markbit operations consistent with atomic ones. (Closed)
Patch Set: remove dcheck Created 3 years, 8 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
« src/heap/mark-compact.cc ('K') | « 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 b20a4d86f149bb7012d648563e47b90613c9fd5b..f09dc71cb2287aa80ee25be327d177e429e8971a 100644
--- a/src/heap/marking.h
+++ b/src/heap/marking.h
@@ -57,8 +57,9 @@ class MarkBit {
template <>
inline bool MarkBit::Set<MarkBit::NON_ATOMIC>() {
- *cell_ |= mask_;
- return true;
+ base::Atomic32 old_value = *cell_;
Michael Lippautz 2017/05/03 07:48:39 Please add a comment on the class indicating that
ulan 2017/05/03 08:51:55 Done.
+ *cell_ = old_value | mask_;
+ return (old_value & mask_) == 0;
Hannes Payer (out of office) 2017/05/03 08:29:05 Why did you change that? The non atomic transition
ulan 2017/05/03 08:51:55 The success means that the bit was 0 and is change
}
template <>
@@ -86,8 +87,9 @@ inline bool MarkBit::Get<MarkBit::ATOMIC>() {
template <>
inline bool MarkBit::Clear<MarkBit::NON_ATOMIC>() {
- *cell_ &= ~mask_;
- return true;
+ base::Atomic32 old_value = *cell_;
+ *cell_ = old_value & ~mask_;
+ return (old_value & mask_) == mask_;
Hannes Payer (out of office) 2017/05/03 08:29:05 Same here, this should always be true.
ulan 2017/05/03 08:51:55 Replied above.
}
template <>
@@ -412,24 +414,17 @@ class Marking : public AllStatic {
template <MarkBit::AccessMode mode = MarkBit::NON_ATOMIC>
INLINE(static bool WhiteToGrey(MarkBit markbit)) {
- DCHECK(mode == MarkBit::ATOMIC || IsWhite(markbit));
return markbit.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>();
+ INLINE(static bool WhiteToBlack(MarkBit markbit)) {
+ return markbit.Set<mode>() && markbit.Next().Set<mode>();
}
template <MarkBit::AccessMode mode = MarkBit::NON_ATOMIC>
INLINE(static bool GreyToBlack(MarkBit markbit)) {
- DCHECK(mode == MarkBit::ATOMIC || IsGrey(markbit));
- return markbit.Next().Set<mode>();
+ return markbit.Get<mode>() && markbit.Next().Set<mode>();
}
enum ObjectColor {
« src/heap/mark-compact.cc ('K') | « src/heap/mark-compact-inl.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698