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

Unified Diff: runtime/vm/raw_object.h

Issue 804673003: Update tag bits atomically (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 6 years 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 | « runtime/vm/object.cc ('k') | runtime/vm/scavenger.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/vm/raw_object.h
===================================================================
--- runtime/vm/raw_object.h (revision 42376)
+++ runtime/vm/raw_object.h (working copy)
@@ -319,26 +319,29 @@
}
void SetMarkBit() {
ASSERT(!IsMarked());
+ UpdateTagBit<MarkBit>(true);
+ }
+ void SetMarkBitUnsynchronized() {
+ ASSERT(!IsMarked());
uword tags = ptr()->tags_;
ptr()->tags_ = MarkBit::update(true, tags);
}
void ClearMarkBit() {
ASSERT(IsMarked());
- uword tags = ptr()->tags_;
- ptr()->tags_ = MarkBit::update(false, tags);
+ UpdateTagBit<MarkBit>(false);
}
// Support for GC watched bit.
+ // TODO(iposva): Get rid of this.
bool IsWatched() const {
return WatchedBit::decode(ptr()->tags_);
}
- void SetWatchedBit() {
+ void SetWatchedBitUnsynchronized() {
ASSERT(!IsWatched());
uword tags = ptr()->tags_;
ptr()->tags_ = WatchedBit::update(true, tags);
}
- void ClearWatchedBit() {
- ASSERT(IsWatched());
+ void ClearWatchedBitUnsynchronized() {
uword tags = ptr()->tags_;
ptr()->tags_ = WatchedBit::update(false, tags);
}
@@ -348,27 +351,13 @@
return CanonicalObjectTag::decode(ptr()->tags_);
}
void SetCanonical() {
- uword tags = ptr()->tags_;
- uword old_tags;
- do {
- old_tags = tags;
- uword new_tags = CanonicalObjectTag::update(true, old_tags);
- tags = AtomicOperations::CompareAndSwapWord(
- &ptr()->tags_, old_tags, new_tags);
- } while (tags != old_tags);
+ UpdateTagBit<CanonicalObjectTag>(true);
}
bool IsCreatedFromSnapshot() const {
return CreatedFromSnapshotTag::decode(ptr()->tags_);
}
void SetCreatedFromSnapshot() {
- uword tags = ptr()->tags_;
- uword old_tags;
- do {
- old_tags = tags;
- uword new_tags = CreatedFromSnapshotTag::update(true, old_tags);
- tags = AtomicOperations::CompareAndSwapWord(
- &ptr()->tags_, old_tags, new_tags);
- } while (tags != old_tags);
+ UpdateTagBit<CreatedFromSnapshotTag>(true);
}
// Support for GC remembered bit.
@@ -377,10 +366,17 @@
}
void SetRememberedBit() {
ASSERT(!IsRemembered());
+ UpdateTagBit<RememberedBit>(true);
+ }
+ void SetRememberedBitUnsynchronized() {
+ ASSERT(!IsRemembered());
uword tags = ptr()->tags_;
ptr()->tags_ = RememberedBit::update(true, tags);
}
void ClearRememberedBit() {
+ UpdateTagBit<RememberedBit>(false);
+ }
+ void ClearRememberedBitUnsynchronized() {
uword tags = ptr()->tags_;
ptr()->tags_ = RememberedBit::update(false, tags);
}
@@ -480,6 +476,18 @@
return ClassIdTag::decode(tags);
}
+ template<class TagBitField>
+ void UpdateTagBit(bool value) {
+ uword tags = ptr()->tags_;
+ uword old_tags;
+ do {
+ old_tags = tags;
+ uword new_tags = TagBitField::update(value, old_tags);
+ tags = AtomicOperations::CompareAndSwapWord(
+ &ptr()->tags_, old_tags, new_tags);
+ } while (tags != old_tags);
+ }
+
// All writes to heap objects should ultimately pass through one of the
// methods below or their counterparts in Object, to ensure that the
// write barrier is correctly applied.
« no previous file with comments | « runtime/vm/object.cc ('k') | runtime/vm/scavenger.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698