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

Unified Diff: vm/snapshot.h

Issue 9021042: Make snapshots 32 or 64 bit compliant by using Write<int64_t> and Read<int64_t> for intptr_t type... (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/raw_object_snapshot.cc ('k') | vm/snapshot.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: vm/snapshot.h
===================================================================
--- vm/snapshot.h (revision 2835)
+++ vm/snapshot.h (working copy)
@@ -40,16 +40,21 @@
kInlined = 0x1,
kObjectId = 0x3,
};
+static const int8_t kHeaderTagBits = 2;
+static const int8_t kObjectIdTagBits = (kBitsPerWord - kHeaderTagBits);
+static const intptr_t kMaxObjectId = (kIntptrMax >> kHeaderTagBits);
-
typedef uint8_t* (*ReAlloc)(uint8_t* ptr, intptr_t old_size, intptr_t new_size);
-
-class SerializedHeaderTag : public BitField<enum SerializedHeaderType, 0, 2> {
+class SerializedHeaderTag : public BitField<enum SerializedHeaderType,
+ 0,
+ kHeaderTagBits> {
};
-class SerializedHeaderData : public BitField<intptr_t, 2, 30> {
+class SerializedHeaderData : public BitField<intptr_t,
+ kHeaderTagBits,
+ kObjectIdTagBits> {
};
@@ -291,6 +296,13 @@
return ReadStream::Raw<sizeof(T), T>::Read(&stream_);
}
+ // Reads an intptr_t type value.
+ intptr_t ReadIntptrValue() {
+ int64_t value = Read<int64_t>();
+ ASSERT((value <= kIntptrMax) && (value >= kIntptrMin));
+ return value;
+ }
+
Heap* heap() const { return heap_; }
ObjectStore* object_store() const { return object_store_; }
@@ -341,6 +353,11 @@
WriteStream::Raw<sizeof(T), T>::Write(&stream_, value);
}
+ // Writes an intptr_t type value out.
+ void WriteIntptrValue(intptr_t value) {
+ Write<int64_t>(value);
+ }
+
// Write an object that is serialized as an Id (singleton, object store,
// or an object that was already serialized before).
void WriteIndexedObject(intptr_t object_id) {
@@ -352,15 +369,16 @@
// Write out the class information.
WriteIndexedObject(class_id);
// Write out the tags information.
- Write<intptr_t>(tags);
+ WriteIntptrValue(tags);
}
// Write serialization header information for an object.
void WriteSerializationMarker(SerializedHeaderType type, intptr_t id) {
- uword value = 0;
+ ASSERT(id <= kMaxObjectId);
+ intptr_t value = 0;
value = SerializedHeaderTag::update(type, value);
value = SerializedHeaderData::update(id, value);
- Write<uword>(value);
+ WriteIntptrValue(value);
}
// Finalize the serialized buffer by filling in the header information
« no previous file with comments | « vm/raw_object_snapshot.cc ('k') | vm/snapshot.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698