Commit 40cc4062 authored by rossberg@chromium.org's avatar rossberg@chromium.org

Fix broken change to d8 typed arrays.

R=mstarzinger@chromium.org
BUG=
TEST=

Review URL: https://chromiumcodereview.appspot.com/10441091

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@11680 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
parent 716eac28
......@@ -338,8 +338,8 @@ Handle<Value> Shell::CreateExternalArray(const Arguments& args,
}
bool first_arg_is_array_buffer =
args[0]->IsObject() &&
args[0]->ToObject()->GetHiddenValue(
String::New(kArrayBufferMarkerPropName))->IsTrue();
!args[0]->ToObject()->GetHiddenValue(
String::New(kArrayBufferMarkerPropName)).IsEmpty();
// Currently, only the following constructors are supported:
// ArrayBuffer(unsigned long length)
// TypedArray(unsigned long length)
......@@ -373,6 +373,9 @@ Handle<Value> Shell::CreateExternalArray(const Arguments& args,
} else {
byteOffset = convertToUint(args[1], &try_catch);
if (try_catch.HasCaught()) return try_catch.Exception();
if (byteOffset > byteLength) {
return ThrowException(String::New("byteOffset out of bounds"));
}
if (byteOffset % element_size != 0) {
return ThrowException(
String::New("byteOffset must be multiple of element_size"));
......@@ -391,8 +394,7 @@ Handle<Value> Shell::CreateExternalArray(const Arguments& args,
}
if (byteOffset + length * element_size > byteLength) {
return ThrowException(
String::New("byteOffset or length out of bounds"));
return ThrowException(String::New("length out of bounds"));
}
byteLength = byteOffset + length * element_size;
......@@ -454,7 +456,7 @@ void Shell::ExternalArrayWeakCallback(Persistent<Value> object, void* data) {
Handle<String> prop_name = String::New(kArrayBufferReferencePropName);
Handle<Object> converted_object = object->ToObject();
Local<Value> prop_value = converted_object->GetHiddenValue(prop_name);
if (data != NULL && !prop_value->IsObject()) {
if (data != NULL && prop_value.IsEmpty()) {
data = reinterpret_cast<size_t*>(data) - kExternalArrayAllocationHeaderSize;
V8::AdjustAmountOfExternalAllocatedMemory(
-static_cast<int>(*reinterpret_cast<size_t*>(data)));
......
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