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

Unified Diff: vm/raw_object.h

Issue 8728016: - Add support for marking bits in the object header. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/runtime/
Patch Set: Created 9 years, 1 month 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 | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: vm/raw_object.h
===================================================================
--- vm/raw_object.h (revision 1880)
+++ vm/raw_object.h (working copy)
@@ -148,6 +148,24 @@
return (addr & kNewObjectAlignmentOffset) == kOldObjectAlignmentOffset;
}
+ // Support for GC marking bit.
+ bool IsMarked() const {
+ uword header_bits = reinterpret_cast<uword>(ptr()->class_);
+ uword mark_bits = header_bits & kMarkingMask;
+ ASSERT((mark_bits == kNotMarked) || (mark_bits == kMarked));
+ return mark_bits == kMarked;
+ }
+ void SetMarkBit() {
+ ASSERT(!IsMarked());
+ uword header_bits = reinterpret_cast<uword>(ptr()->class_);
+ ptr()->class_ = reinterpret_cast<RawClass*>(header_bits | kMarked);
+ }
+ void ClearMarkBit() {
+ ASSERT(IsMarked());
+ uword header_bits = reinterpret_cast<uword>(ptr()->class_);
+ ptr()->class_ = reinterpret_cast<RawClass*>(header_bits ^ kMarked);
+ }
+
void Validate() const;
intptr_t Size() const;
intptr_t VisitPointers(ObjectPointerVisitor* visitor);
@@ -166,6 +184,12 @@
RawClass* class_;
private:
+ enum {
+ kMarkingMask = 3,
+ kNotMarked = 1, // Tagged pointer.
+ kMarked = 3, // Tagged pointer and forwarding bit set.
+ };
+
RawObject* ptr() const {
ASSERT(IsHeapObject());
return reinterpret_cast<RawObject*>(
@@ -176,6 +200,7 @@
friend class Array;
friend class SnapshotWriter;
friend class SnapshotReader;
+ friend class MarkingVisitor;
DISALLOW_ALLOCATION();
DISALLOW_IMPLICIT_CONSTRUCTORS(RawObject);
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698