Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(348)

Unified Diff: src/d8.cc

Issue 9956049: MIPS: Increase external array allocation header size to 8 bytes. (Closed) Base URL: git://github.com/v8/v8.git@bleeding_edge
Patch Set: Rebased on r11256. Created 8 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/d8.cc
diff --git a/src/d8.cc b/src/d8.cc
index 1e8b4c8a2011935672b7ac054b51a34ae932f8a4..26d0bc10e101ad99984c77c9a79ab2f829acc75b 100644
--- a/src/d8.cc
+++ b/src/d8.cc
@@ -318,6 +318,7 @@ static size_t convertToUint(Local<Value> value_in, TryCatch* try_catch) {
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 @@ Handle<Value> 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<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 @@ void Shell::ExternalArrayWeakCallback(Persistent<Value> object, void* data) {
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);
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698