Index: src/api.cc |
diff --git a/src/api.cc b/src/api.cc |
index f61f190291ecc3365f09e94b60d350a44601adb3..2530ac660e1d7d2e76c6c3f373d816364624b12f 100644 |
--- a/src/api.cc |
+++ b/src/api.cc |
@@ -6018,8 +6018,15 @@ Local<ArrayBuffer> v8::ArrayBuffer::New(Isolate* isolate, void* data, |
Local<ArrayBuffer> v8::ArrayBufferView::Buffer() { |
i::Handle<i::JSArrayBufferView> obj = Utils::OpenHandle(this); |
- ASSERT(obj->buffer()->IsJSArrayBuffer()); |
- i::Handle<i::JSArrayBuffer> buffer(i::JSArrayBuffer::cast(obj->buffer())); |
+ i::Handle<i::JSArrayBuffer> buffer; |
+ if (obj->IsJSDataView()) { |
+ i::Handle<i::JSDataView> data_view(i::JSDataView::cast(*obj)); |
+ ASSERT(data_view->buffer()->IsJSArrayBuffer()); |
+ buffer = i::handle(i::JSArrayBuffer::cast(data_view->buffer())); |
+ } else { |
+ ASSERT(obj->IsJSTypedArray()); |
+ buffer = i::JSTypedArray::cast(*obj)->GetBuffer(); |
+ } |
return Utils::ToLocal(buffer); |
} |
@@ -6090,7 +6097,9 @@ i::Handle<i::JSTypedArray> NewTypedArray( |
isolate->factory()->NewExternalArray( |
static_cast<int>(length), array_type, |
static_cast<uint8_t*>(buffer->backing_store()) + byte_offset); |
- obj->set_elements(*elements); |
+ i::Handle<i::Map> map = |
+ i::JSObject::GetElementsTransitionMap(obj, elements_kind); |
+ obj->set_map_and_elements(*map, *elements); |
return obj; |
} |