Commit 64a96f5a authored by rickyz's avatar rickyz Committed by Commit bot

Use 16 instead of 4 for determining member offsets.

This avoids UBSan warnings about unaligned memory access.

BUG=

Review URL: https://codereview.chromium.org/734873002

Cr-Commit-Position: refs/heads/master@{#25396}
parent c2c0d4ae
......@@ -20,9 +20,9 @@
// corresponds to 'offsetof' (in stddef.h), except that it doesn't
// use 0 or NULL, which causes a problem with the compiler warnings
// we have enabled (which is also why 'offsetof' doesn't seem to work).
// Here we simply use the non-zero value 4, which seems to work.
#define OFFSET_OF(type, field) \
(reinterpret_cast<intptr_t>(&(reinterpret_cast<type*>(4)->field)) - 4)
// Here we simply use the aligned, non-zero value 16.
#define OFFSET_OF(type, field) \
(reinterpret_cast<intptr_t>(&(reinterpret_cast<type*>(16)->field)) - 16)
#if V8_OS_NACL
......
......@@ -587,7 +587,7 @@ bool Heap::CollectGarbage(AllocationSpace space, const char* gc_reason,
Isolate* Heap::isolate() {
return reinterpret_cast<Isolate*>(
reinterpret_cast<intptr_t>(this) -
reinterpret_cast<size_t>(reinterpret_cast<Isolate*>(4)->heap()) + 4);
reinterpret_cast<size_t>(reinterpret_cast<Isolate*>(16)->heap()) + 16);
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment