Revision: 5872
Author: [email protected]
Date: Tue Nov 23 01:52:52 2010
Log: 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!

[email protected]

Review URL: http://codereview.chromium.org/5328001
http://code.google.com/p/v8/source/detail?r=5872

Modified:
 /branches/bleeding_edge/src/profile-generator-inl.h
 /branches/bleeding_edge/src/profile-generator.cc
 /branches/bleeding_edge/src/profile-generator.h

=======================================
--- /branches/bleeding_edge/src/profile-generator-inl.h Mon Nov 22 08:09:14 2010 +++ /branches/bleeding_edge/src/profile-generator-inl.h Tue Nov 23 01:52:52 2010
@@ -122,15 +122,13 @@
 }


-#ifdef WIN32
 inline uint64_t HeapEntry::id() {
-  return *(reinterpret_cast<uint64_t*>(&id_));
-}
-#else
-inline uint64_t HeapEntry::id() {
-  return id_;
-}
-#endif
+  union {
+    Id stored_id;
+    uint64_t returned_id;
+  } id_adaptor = {id_};
+  return id_adaptor.returned_id;
+}


 template<class Visitor>
=======================================
--- /branches/bleeding_edge/src/profile-generator.cc Mon Nov 22 08:09:14 2010 +++ /branches/bleeding_edge/src/profile-generator.cc Tue Nov 23 01:52:52 2010
@@ -870,16 +870,17 @@
   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;
 }


=======================================
--- /branches/bleeding_edge/src/profile-generator.h     Mon Nov 22 08:09:14 2010
+++ /branches/bleeding_edge/src/profile-generator.h     Tue Nov 23 01:52:52 2010
@@ -615,14 +615,10 @@
   };
   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.

--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev

Reply via email to