Revision: 11303
Author: [email protected]
Date: Fri Apr 13 02:00:02 2012
Log: 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
http://code.google.com/p/v8/source/detail?r=11303
Modified:
/branches/bleeding_edge/src/d8.cc
=======================================
--- /branches/bleeding_edge/src/d8.cc Tue Mar 27 05:46:44 2012
+++ /branches/bleeding_edge/src/d8.cc Fri Apr 13 02:00:02 2012
@@ -318,6 +318,7 @@
const char kArrayBufferReferencePropName[] = "_is_array_buffer_";
const char kArrayBufferMarkerPropName[] = "_array_buffer_ref_";
+static const int kExternalArrayAllocationHeaderSize = 2;
Handle<Value> Shell::CreateExternalArray(const Arguments& args,
ExternalArrayType type,
@@ -433,13 +434,14 @@
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<size_t*>(data) = total_size;
- data = reinterpret_cast<size_t*>(data) + 1;
+ data = reinterpret_cast<size_t*>(data) +
kExternalArrayAllocationHeaderSize;
memset(data, 0, length * element_size);
V8::AdjustAmountOfExternalAllocatedMemory(total_size);
}
@@ -463,7 +465,7 @@
Handle<Object> converted_object = object->ToObject();
Local<Value> prop_value = converted_object->Get(prop_name);
if (data != NULL && !prop_value->IsObject()) {
- data = reinterpret_cast<size_t*>(data) - 1;
+ data = reinterpret_cast<size_t*>(data) -
kExternalArrayAllocationHeaderSize;
V8::AdjustAmountOfExternalAllocatedMemory(
-static_cast<int>(*reinterpret_cast<size_t*>(data)));
free(data);
--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev