Commit 5cc1bf6c authored by lrn@chromium.org's avatar lrn@chromium.org

X64: Serialization fixed to use intptr_t/Address where needed.

Review URL: http://codereview.chromium.org/115080


git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@1898 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
parent 3299f63c
......@@ -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,9 @@ 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
: static_cast<int>(reinterpret_cast<intptr_t>(entry->value));
}
......@@ -794,6 +798,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 +922,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 +1162,7 @@ void Serializer::PutContextStack() {
void Serializer::PutEncodedAddress(Address addr) {
writer_->PutC('P');
writer_->PutInt(reinterpret_cast<int>(addr));
writer_->PutAddress(addr);
}
......@@ -1336,7 +1345,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 +1359,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 +1485,7 @@ void Deserializer::GetContextStack() {
Address Deserializer::GetEncodedAddress() {
reader_.ExpectC('P');
return reinterpret_cast<Address>(reader_.GetInt());
return reader_.GetAddress();
}
......
......@@ -231,6 +231,12 @@ class SnapshotReader {
return result;
}
Address GetAddress() {
Address result;
GetBytes(reinterpret_cast<Address>(&result), sizeof(result));
return result;
}
void GetBytes(Address a, int size) {
ASSERT(str_ + size <= end_);
memcpy(a, str_, size);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment