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

Unified Diff: src/serialize.cc

Issue 115080: X64: Serialization fixed to use intptr_t/Address where needed. (Closed)
Patch Set: Created 11 years, 7 months 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 | « src/serialize.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/serialize.cc
diff --git a/src/serialize.cc b/src/serialize.cc
index e15c00383505f574daeee0fe80b7f9e6c51688b6..c1ec81d29d7f4cf6825855be4fb0184b93a0df47 100644
--- a/src/serialize.cc
+++ b/src/serialize.cc
@@ -78,8 +78,8 @@ const int kPageAndOffsetMask = (1 << kPageAndOffsetBits) - 1;
static inline AllocationSpace GetSpace(Address addr) {
- const int encoded = reinterpret_cast<int>(addr);
- int space_number = ((encoded >> kSpaceShift) & kSpaceMask);
+ const intptr_t encoded = reinterpret_cast<intptr_t>(addr);
+ int space_number = (static_cast<int>(encoded >> kSpaceShift) & kSpaceMask);
if (space_number == kLOSpaceExecutable) space_number = LO_SPACE;
else if (space_number == kLOSpacePointer) space_number = LO_SPACE;
return static_cast<AllocationSpace>(space_number);
@@ -87,43 +87,45 @@ static inline AllocationSpace GetSpace(Address addr) {
static inline bool IsLargeExecutableObject(Address addr) {
- const int encoded = reinterpret_cast<int>(addr);
- const int space_number = ((encoded >> kSpaceShift) & kSpaceMask);
- if (space_number == kLOSpaceExecutable) return true;
- return false;
+ const intptr_t encoded = reinterpret_cast<intptr_t>(addr);
+ const int space_number =
+ (static_cast<int>(encoded >> kSpaceShift) & kSpaceMask);
+ return (space_number == kLOSpaceExecutable);
}
static inline bool IsLargeFixedArray(Address addr) {
- const int encoded = reinterpret_cast<int>(addr);
- const int space_number = ((encoded >> kSpaceShift) & kSpaceMask);
- if (space_number == kLOSpacePointer) return true;
- return false;
+ const intptr_t encoded = reinterpret_cast<intptr_t>(addr);
+ const int space_number =
+ (static_cast<int>(encoded >> kSpaceShift) & kSpaceMask);
+ return (space_number == kLOSpacePointer);
}
static inline int PageIndex(Address addr) {
- const int encoded = reinterpret_cast<int>(addr);
- return (encoded >> kPageShift) & kPageMask;
+ const intptr_t encoded = reinterpret_cast<intptr_t>(addr);
+ return static_cast<int>(encoded >> kPageShift) & kPageMask;
}
static inline int PageOffset(Address addr) {
- const int encoded = reinterpret_cast<int>(addr);
- return ((encoded >> kOffsetShift) & kOffsetMask) << kObjectAlignmentBits;
+ const intptr_t encoded = reinterpret_cast<intptr_t>(addr);
+ const int offset = static_cast<int>(encoded >> kOffsetShift) & kOffsetMask;
+ return offset << kObjectAlignmentBits;
}
static inline int NewSpaceOffset(Address addr) {
- const int encoded = reinterpret_cast<int>(addr);
- return ((encoded >> kPageAndOffsetShift) & kPageAndOffsetMask) <<
- kObjectAlignmentBits;
+ const intptr_t encoded = reinterpret_cast<intptr_t>(addr);
+ const int page_offset =
+ static_cast<int>(encoded >> kPageAndOffsetShift) & kPageAndOffsetMask;
+ return page_offset << kObjectAlignmentBits;
}
static inline int LargeObjectIndex(Address addr) {
- const int encoded = reinterpret_cast<int>(addr);
- return (encoded >> kPageAndOffsetShift) & kPageAndOffsetMask;
+ const intptr_t encoded = reinterpret_cast<intptr_t>(addr);
+ return static_cast<int>(encoded >> kPageAndOffsetShift) & kPageAndOffsetMask;
}
@@ -728,7 +730,8 @@ int ExternalReferenceEncoder::IndexOf(Address key) const {
if (key == NULL) return -1;
HashMap::Entry* entry =
const_cast<HashMap &>(encodings_).Lookup(key, Hash(key), false);
- return entry == NULL ? -1 : reinterpret_cast<int>(entry->value);
+ return entry == NULL ? -1 :
Kasper Lund 2009/05/07 11:48:54 I would put ? and : on separate lines like this:
+ static_cast<int>(reinterpret_cast<intptr_t>(entry->value));
}
@@ -794,6 +797,10 @@ class SnapshotWriter {
InsertInt(i, len_);
}
+ void PutAddress(Address p) {
+ PutBytes(reinterpret_cast<byte*>(&p), sizeof(p));
+ }
+
void PutBytes(const byte* a, int size) {
InsertBytes(a, len_, size);
}
@@ -914,7 +921,8 @@ class ReferenceUpdater: public ObjectVisitor {
// Helper functions for a map of encoded heap object addresses.
static uint32_t HeapObjectHash(HeapObject* key) {
- return reinterpret_cast<uint32_t>(key) >> 2;
+ uint32_t low32bits = static_cast<uint32_t>(reinterpret_cast<uintptr_t>(key));
+ return low32bits >> 2;
}
@@ -1153,7 +1161,7 @@ void Serializer::PutContextStack() {
void Serializer::PutEncodedAddress(Address addr) {
writer_->PutC('P');
- writer_->PutInt(reinterpret_cast<int>(addr));
+ writer_->PutAddress(addr);
}
@@ -1336,7 +1344,7 @@ void Deserializer::VisitPointers(Object** start, Object** end) {
*p = GetObject(); // embedded object
} else {
ASSERT(c == 'P'); // pointer to previously serialized object
- *p = Resolve(reinterpret_cast<Address>(reader_.GetInt()));
+ *p = Resolve(reader_.GetAddress());
}
} else {
// A pointer internal to a HeapObject that we've already
@@ -1350,7 +1358,7 @@ void Deserializer::VisitPointers(Object** start, Object** end) {
void Deserializer::VisitExternalReferences(Address* start, Address* end) {
for (Address* p = start; p < end; ++p) {
- uint32_t code = reinterpret_cast<uint32_t>(*p);
+ uint32_t code = static_cast<uint32_t>(reinterpret_cast<uintptr_t>(*p));
*p = reference_decoder_->Decode(code);
}
}
@@ -1476,7 +1484,7 @@ void Deserializer::GetContextStack() {
Address Deserializer::GetEncodedAddress() {
reader_.ExpectC('P');
- return reinterpret_cast<Address>(reader_.GetInt());
+ return reader_.GetAddress();
}
« no previous file with comments | « src/serialize.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698