Fix again HeapEntry size problem, now platform-independent way.

Rico noticed that V8 ARM builder also fails on HeapEntry size
assertion. As MSVC-specific way of fixing the problem causes
aliasing problems on G++, I re-implemented conversion using
unions. And #ifdefs are gone!

TBR=sgjesse@chromium.org

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

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@5872 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
parent ec6b6c94
......@@ -122,15 +122,13 @@ CodeEntry* ProfileGenerator::EntryForVMState(StateTag tag) {
}
#ifdef WIN32
inline uint64_t HeapEntry::id() {
return *(reinterpret_cast<uint64_t*>(&id_));
union {
Id stored_id;
uint64_t returned_id;
} id_adaptor = {id_};
return id_adaptor.returned_id;
}
#else
inline uint64_t HeapEntry::id() {
return id_;
}
#endif
template<class Visitor>
......
......@@ -870,16 +870,17 @@ void HeapEntry::Init(HeapSnapshot* snapshot,
type_ = type;
painted_ = kUnpainted;
name_ = name;
#ifdef WIN32
*(reinterpret_cast<uint64_t*>(&id_)) = id;
#else
id_ = id;
#endif
self_size_ = self_size;
retained_size_ = 0;
children_count_ = children_count;
retainers_count_ = retainers_count;
dominator_ = NULL;
union {
uint64_t set_id;
Id stored_id;
} id_adaptor = {id};
id_ = id_adaptor.stored_id;
}
......
......@@ -615,14 +615,10 @@ class HeapEntry BASE_EMBEDDED {
};
HeapEntry* dominator_;
HeapSnapshot* snapshot_;
#ifdef WIN32
struct Id {
uint32_t id1_;
uint32_t id2_;
} id_; // This is to avoid extra padding of 64-bit value on MSVC.
#else
uint64_t id_;
#endif
} id_; // This is to avoid extra padding of 64-bit value.
const char* name_;
// Paints used for exact retained sizes calculation.
......
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