Reviewers: Søren Gjesse,
Description:
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]
Please review this at http://codereview.chromium.org/5328001/
SVN Base: https://v8.googlecode.com/svn/branches/bleeding_edge
Affected files:
M src/profile-generator-inl.h
M src/profile-generator.h
M src/profile-generator.cc
Index: src/profile-generator-inl.h
diff --git a/src/profile-generator-inl.h b/src/profile-generator-inl.h
index
3577219c1dd155825b3d3728b2801c49b015ebfc..8b5c1e21cb6a69c679cad070ab84b09ed5476357
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<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: src/profile-generator.cc
diff --git a/src/profile-generator.cc b/src/profile-generator.cc
index
8e9f13712ea82ada2a54dcc3a5e5c39f7bb5c538..e0b63f950ceebd604386914d2f16a2e1dbb923ed
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<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: src/profile-generator.h
diff --git a/src/profile-generator.h b/src/profile-generator.h
index
9f956e115a508c2b00075517dfad68a3c9261946..30d70a2c7495643e922edf251e3fe635bee4e9ef
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.
--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev