From: mikhail.naganov@gmail.com Date: Tue, 23 Nov 2010 09:52:52 +0000 (+0000) Subject: Fix again HeapEntry size problem, now platform-independent way. X-Git-Tag: upstream/4.7.83~20917 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=372087a5bcff23809be6c6d348c5ca5d0d9673f0;p=platform%2Fupstream%2Fv8.git 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 --- diff --git a/src/profile-generator-inl.h b/src/profile-generator-inl.h index 3577219..8b5c1e2 100644 --- a/src/profile-generator-inl.h +++ b/src/profile-generator-inl.h @@ -122,15 +122,13 @@ CodeEntry* ProfileGenerator::EntryForVMState(StateTag tag) { } -#ifdef WIN32 inline uint64_t HeapEntry::id() { - return *(reinterpret_cast(&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 diff --git a/src/profile-generator.cc b/src/profile-generator.cc index 8e9f137..e0b63f9 100644 --- a/src/profile-generator.cc +++ b/src/profile-generator.cc @@ -870,16 +870,17 @@ void HeapEntry::Init(HeapSnapshot* snapshot, type_ = type; painted_ = kUnpainted; name_ = name; -#ifdef WIN32 - *(reinterpret_cast(&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; } diff --git a/src/profile-generator.h b/src/profile-generator.h index 9f956e1..30d70a2 100644 --- a/src/profile-generator.h +++ b/src/profile-generator.h @@ -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.