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);
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;
}
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));
}
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);
}
// 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;
}
void Serializer::PutEncodedAddress(Address addr) {
writer_->PutC('P');
- writer_->PutInt(reinterpret_cast<int>(addr));
+ writer_->PutAddress(addr);
}
*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
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);
}
}
Address Deserializer::GetEncodedAddress() {
reader_.ExpectC('P');
- return reinterpret_cast<Address>(reader_.GetInt());
+ return reader_.GetAddress();
}