From 3925045f70fd81877350e85639c3e5958affaef2 Mon Sep 17 00:00:00 2001 From: "sgjesse@chromium.org" Date: Fri, 25 Mar 2011 13:26:55 +0000 Subject: [PATCH] Don't rely on C++ object padding across platforms The use of sizeof on FrameDescription to get to the additional allocated memory for the frame content relies on the padding of the FrameDescription. On IA32 Linux the FrameDescription is not padded but on ARM Linux it is padded to become 8 byte aligned. With a snapshot generated with the ARM simulator on IA32 Linux that contains one or more of the deoptimization tables the deoptimization did not work as the access to the frame content was one off between the C++ code and the generated code. R=ager@chromium.org Review URL: http://codereview.chromium.org/6744004 git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@7369 ce2b1a6d-e550-0410-aec6-3dcde31c8c00 --- src/deoptimizer.h | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/deoptimizer.h b/src/deoptimizer.h index ccd5e48954..a53de3da98 100644 --- a/src/deoptimizer.h +++ b/src/deoptimizer.h @@ -326,7 +326,9 @@ class FrameDescription { JSFunction* function); void* operator new(size_t size, uint32_t frame_size) { - return malloc(size + frame_size); + // Subtracts kPointerSize, as the member frame_content_ already supplies + // the first element of the area to store the frame. + return malloc(size + frame_size - kPointerSize); } void operator delete(void* description) { @@ -410,7 +412,7 @@ class FrameDescription { } static int frame_content_offset() { - return sizeof(FrameDescription); + return OFFSET_OF(FrameDescription, frame_content_); } private: @@ -429,6 +431,10 @@ class FrameDescription { // deoptimizing. intptr_t continuation_; + // This must be at the end of the object as the object is allocated larger + // than it's definition indicate to extend this array. + intptr_t frame_content_[1]; + intptr_t* GetFrameSlotPointer(unsigned offset) { ASSERT(offset < frame_size_); return reinterpret_cast(