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

Unified Diff: vm/raw_object.h

Issue 8879063: Changes to set up the object tag bits (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/runtime/
Patch Set: '' Created 9 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
« vm/object.cc ('K') | « vm/object.cc ('k') | vm/raw_object_snapshot.cc » ('j') | 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 2393)
+++ vm/raw_object.h (working copy)
@@ -101,6 +101,24 @@
kSmiTagShift = 1,
};
+
+/*
+ * The tags field which is a part of the object header uses the following
+ * bit fields for storing tags.
+ *
+ * bit 0 - SmiTag
+ * bit 1 - Mark bit.
+ * bit 2 - Canonical object.
+ * bit 3 - Created from a full snapshot.
+ */
+class CanonicalObjectTag : public BitField<bool, 2, 1> {
+};
+
+
+class CreatedFromSnapshotTag : public BitField<bool, 3, 1> {
+};
+
+
#define SNAPSHOT_WRITER_SUPPORT() \
void WriteTo( \
SnapshotWriter* writer, intptr_t object_id, Snapshot::Kind kind); \
@@ -166,6 +184,22 @@
ptr()->class_ = reinterpret_cast<RawClass*>(header_bits ^ kMarked);
}
+ // Support for object tags.
+ bool IsCanonical() const {
+ return CanonicalObjectTag::decode(ptr()->tags_);
+ }
+ void SetCanonical() {
+ intptr_t tags = ptr()->tags_;
+ ptr()->tags_ = CanonicalObjectTag::update(true, tags);
+ }
+ bool IsCreatedFromSnapshot() {
+ return CreatedFromSnapshotTag::decode(ptr()->tags_);
+ }
+ void SetCreatedFromSnapshot() {
+ intptr_t tags = ptr()->tags_;
+ ptr()->tags_ = CreatedFromSnapshotTag::update(true, tags);
+ }
+
void Validate() const;
intptr_t Size() const;
intptr_t VisitPointers(ObjectPointerVisitor* visitor);
@@ -180,8 +214,17 @@
return reinterpret_cast<uword>(raw_obj->ptr());
}
+ static bool IsCreatedFromSnapshot(intptr_t value) {
+ return CreatedFromSnapshotTag::decode(value);
+ }
+
+ static bool IsCanonical(intptr_t value) {
+ return CanonicalObjectTag::decode(value);
+ }
+
protected:
RawClass* class_;
+ intptr_t tags_; // Various object tags (bits).
private:
enum {
@@ -196,8 +239,6 @@
reinterpret_cast<uword>(this) - kHeapObjectTag);
}
- intptr_t tags_; // Various object tags (bits).
-
friend class Object;
friend class Array;
friend class SnapshotWriter;
@@ -343,7 +384,6 @@
RawObject** from() {
return reinterpret_cast<RawObject**>(&ptr()->length_);
}
- bool is_canonical_;
RawSmi* length_;
// Variable length data follows here.
« vm/object.cc ('K') | « vm/object.cc ('k') | vm/raw_object_snapshot.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698