Fix again HeapEntry size problem, now platform-independent way.
authormikhail.naganov@gmail.com <mikhail.naganov@gmail.com@ce2b1a6d-e550-0410-aec6-3dcde31c8c00>
Tue, 23 Nov 2010 09:52:52 +0000 (09:52 +0000)
committermikhail.naganov@gmail.com <mikhail.naganov@gmail.com@ce2b1a6d-e550-0410-aec6-3dcde31c8c00>
Tue, 23 Nov 2010 09:52:52 +0000 (09:52 +0000)
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

src/profile-generator-inl.h
src/profile-generator.cc
src/profile-generator.h

index 3577219..8b5c1e2 100644 (file)
@@ -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>
index 8e9f137..e0b63f9 100644 (file)
@@ -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;
 }
 
 
index 9f956e1..30d70a2 100644 (file)
@@ -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.