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

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
« no previous file with comments | « 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 2434)
+++ vm/raw_object.h (working copy)
@@ -132,6 +132,15 @@
// RawObject is the base class of all raw objects, even though it carries the
// class_ field not all raw objects are allocated in the heap and thus cannot
// be dereferenced (e.g. RawSmi).
+//
+// 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 RawObject {
public:
bool IsHeapObject() const {
@@ -166,6 +175,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 +205,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 {
@@ -190,14 +224,18 @@
kMarked = 3, // Tagged pointer and forwarding bit set.
};
+ class CanonicalObjectTag : public BitField<bool, 2, 1> {
+ };
+
+ class CreatedFromSnapshotTag : public BitField<bool, 3, 1> {
+ };
+
RawObject* ptr() const {
ASSERT(IsHeapObject());
return reinterpret_cast<RawObject*>(
reinterpret_cast<uword>(this) - kHeapObjectTag);
}
- intptr_t tags_; // Various object tags (bits).
-
friend class Object;
friend class Array;
friend class SnapshotWriter;
@@ -343,7 +381,6 @@
RawObject** from() {
return reinterpret_cast<RawObject**>(&ptr()->length_);
}
- bool is_canonical_;
RawSmi* length_;
// Variable length data follows here.
« no previous file with comments | « vm/object.cc ('k') | vm/raw_object_snapshot.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698