From: jkummerow@chromium.org Date: Fri, 13 Apr 2012 09:00:02 +0000 (+0000) Subject: MIPS: Increase external array allocation header size to 8 bytes. X-Git-Tag: upstream/4.7.83~16913 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=18a24a58823e89904b8390d8612c3cae29d4a890;p=platform%2Fupstream%2Fv8.git MIPS: Increase external array allocation header size to 8 bytes. This fixes alignment issues on MIPS HW, found for example in mjsunit external-array. The issue originates from r11144 (86563c3e21) which adds a 4-byte header to these arrays. This causes problems on MIPS, where certain pointers need to be 8-byte aligned. BUG= TEST=mjsunit/external-array Review URL: https://chromiumcodereview.appspot.com/9956049 git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@11303 ce2b1a6d-e550-0410-aec6-3dcde31c8c00 --- diff --git a/src/d8.cc b/src/d8.cc index 1e8b4c8..26d0bc1 100644 --- a/src/d8.cc +++ b/src/d8.cc @@ -318,6 +318,7 @@ static size_t convertToUint(Local value_in, TryCatch* try_catch) { const char kArrayBufferReferencePropName[] = "_is_array_buffer_"; const char kArrayBufferMarkerPropName[] = "_array_buffer_ref_"; +static const int kExternalArrayAllocationHeaderSize = 2; Handle Shell::CreateExternalArray(const Arguments& args, ExternalArrayType type, @@ -433,13 +434,14 @@ Handle Shell::CreateExternalArray(const Arguments& args, return ThrowException(String::New("Array exceeds maximum size (2G)")); } // Prepend the size of the allocated chunk to the data itself. - int total_size = length * element_size + sizeof(size_t); + int total_size = length * element_size + + kExternalArrayAllocationHeaderSize * sizeof(size_t); data = malloc(total_size); if (data == NULL) { return ThrowException(String::New("Memory allocation failed.")); } *reinterpret_cast(data) = total_size; - data = reinterpret_cast(data) + 1; + data = reinterpret_cast(data) + kExternalArrayAllocationHeaderSize; memset(data, 0, length * element_size); V8::AdjustAmountOfExternalAllocatedMemory(total_size); } @@ -463,7 +465,7 @@ void Shell::ExternalArrayWeakCallback(Persistent object, void* data) { Handle converted_object = object->ToObject(); Local prop_value = converted_object->Get(prop_name); if (data != NULL && !prop_value->IsObject()) { - data = reinterpret_cast(data) - 1; + data = reinterpret_cast(data) - kExternalArrayAllocationHeaderSize; V8::AdjustAmountOfExternalAllocatedMemory( -static_cast(*reinterpret_cast(data))); free(data);