Reviewers: Michael Starzinger,
Description:
Fix -Wstrict-aliasing warnings.
Please review this at https://codereview.chromium.org/11590005/
Affected files:
M src/heap.h
M src/hydrogen.cc
M src/serialize.cc
Index: src/heap.h
diff --git a/src/heap.h b/src/heap.h
index
068c44e713f5569515606e2b582caee994ea17f1..d8d37970daa513c3d312a6d1961f19752e571da8
100644
--- a/src/heap.h
+++ b/src/heap.h
@@ -1293,7 +1293,13 @@ class Heap {
Object** roots_array_start() { return roots_; }
Address* store_buffer_top_address() {
- return reinterpret_cast<Address*>(&roots_[kStoreBufferTopRootIndex]);
+ // Avoid type-punning compiler warnings.
+ union {
+ Object** in;
+ Address* out;
+ } u;
+ u.in = &roots_[kStoreBufferTopRootIndex];
+ return u.out;
}
// Get address of native contexts list for serialization support.
Index: src/hydrogen.cc
diff --git a/src/hydrogen.cc b/src/hydrogen.cc
index
97306a165963da9aff7824321404240b0bb2b5b2..2342c44e8a8ec95d3da5da0fd505b6281a74edd4
100644
--- a/src/hydrogen.cc
+++ b/src/hydrogen.cc
@@ -3594,8 +3594,13 @@ static bool BoundsCheckKeyMatch(void* key1, void*
key2) {
class BoundsCheckTable : private ZoneHashMap {
public:
BoundsCheckBbData** LookupOrInsert(BoundsCheckKey* key, Zone* zone) {
- return reinterpret_cast<BoundsCheckBbData**>(
- &(Lookup(key, key->Hash(), true,
ZoneAllocationPolicy(zone))->value));
+ // Avoid type-punning compiler warnings.
+ union {
+ void** in;
+ BoundsCheckBbData** out;
+ } u;
+ u.in = &(Lookup(key, key->Hash(), true,
ZoneAllocationPolicy(zone))->value);
+ return u.out;
}
void Insert(BoundsCheckKey* key, BoundsCheckBbData* data, Zone* zone) {
Index: src/serialize.cc
diff --git a/src/serialize.cc b/src/serialize.cc
index
dfc55740a36c412f710570e0a59bd73bb726f429..13c95c659adb840b8812113b554919a4f3808df8
100644
--- a/src/serialize.cc
+++ b/src/serialize.cc
@@ -1154,7 +1154,15 @@ int
PartialSerializer::PartialSnapshotCacheIndex(HeapObject* heap_object) {
// and we can refer to it from the partial snapshot.
int length = isolate->serialize_partial_snapshot_cache_length();
isolate->PushToPartialSnapshotCache(heap_object);
-
startup_serializer_->VisitPointer(reinterpret_cast<Object**>(&heap_object));
+
+ // Avoid type-punning compiler warnings.
+ union {
+ HeapObject** in;
+ Object** out;
+ } u;
+ u.in = &heap_object;
+ startup_serializer_->VisitPointer(u.out);
+
// We don't recurse from the startup snapshot generator into the partial
// snapshot generator.
ASSERT(length == isolate->serialize_partial_snapshot_cache_length() - 1);
--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev