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

Unified Diff: src/api.cc

Issue 1109353003: Unify internal and external typed arrays a bit (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: updates Created 5 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 | « include/v8.h ('k') | src/arm/lithium-codegen-arm.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/api.cc
diff --git a/src/api.cc b/src/api.cc
index c42cab62d55c64735efb722c85f046ab8a2830df..a750c0c168cd099ea0ff516b5ef7ec8468abc90a 100644
--- a/src/api.cc
+++ b/src/api.cc
@@ -6336,31 +6336,21 @@ Local<ArrayBuffer> v8::ArrayBufferView::Buffer() {
size_t v8::ArrayBufferView::CopyContents(void* dest, size_t byte_length) {
- i::Handle<i::JSArrayBufferView> obj = Utils::OpenHandle(this);
- i::Isolate* isolate = obj->GetIsolate();
- size_t byte_offset = i::NumberToSize(isolate, obj->byte_offset());
+ i::Handle<i::JSArrayBufferView> self = Utils::OpenHandle(this);
+ i::Isolate* isolate = self->GetIsolate();
+ size_t byte_offset = i::NumberToSize(isolate, self->byte_offset());
size_t bytes_to_copy =
- i::Min(byte_length, i::NumberToSize(isolate, obj->byte_length()));
+ i::Min(byte_length, i::NumberToSize(isolate, self->byte_length()));
if (bytes_to_copy) {
i::DisallowHeapAllocation no_gc;
- const char* source = nullptr;
- if (obj->IsJSDataView()) {
- i::Handle<i::JSDataView> data_view(i::JSDataView::cast(*obj));
- i::Handle<i::JSArrayBuffer> buffer(
- i::JSArrayBuffer::cast(data_view->buffer()));
- source = reinterpret_cast<char*>(buffer->backing_store());
- } else {
- DCHECK(obj->IsJSTypedArray());
- i::Handle<i::JSTypedArray> typed_array(i::JSTypedArray::cast(*obj));
- if (typed_array->buffer()->IsSmi()) {
- i::Handle<i::FixedTypedArrayBase> fixed_array(
- i::FixedTypedArrayBase::cast(typed_array->elements()));
- source = reinterpret_cast<char*>(fixed_array->DataPtr());
- } else {
- i::Handle<i::JSArrayBuffer> buffer(
- i::JSArrayBuffer::cast(typed_array->buffer()));
- source = reinterpret_cast<char*>(buffer->backing_store());
- }
+ i::Handle<i::JSArrayBuffer> buffer(i::JSArrayBuffer::cast(self->buffer()));
+ const char* source = reinterpret_cast<char*>(buffer->backing_store());
+ if (source == nullptr) {
+ DCHECK(self->IsJSTypedArray());
+ i::Handle<i::JSTypedArray> typed_array(i::JSTypedArray::cast(*self));
+ i::Handle<i::FixedTypedArrayBase> fixed_array(
+ i::FixedTypedArrayBase::cast(typed_array->elements()));
+ source = reinterpret_cast<char*>(fixed_array->DataPtr());
}
memcpy(dest, source + byte_offset, bytes_to_copy);
}
@@ -6369,11 +6359,9 @@ size_t v8::ArrayBufferView::CopyContents(void* dest, size_t byte_length) {
bool v8::ArrayBufferView::HasBuffer() const {
- i::Handle<i::JSArrayBufferView> obj = Utils::OpenHandle(this);
- if (obj->IsJSDataView()) return true;
- DCHECK(obj->IsJSTypedArray());
- i::Handle<i::JSTypedArray> typed_array(i::JSTypedArray::cast(*obj));
- return !typed_array->buffer()->IsSmi();
+ i::Handle<i::JSArrayBufferView> self = Utils::OpenHandle(this);
+ i::Handle<i::JSArrayBuffer> buffer(i::JSArrayBuffer::cast(self->buffer()));
+ return buffer->backing_store() != nullptr;
}
« no previous file with comments | « include/v8.h ('k') | src/arm/lithium-codegen-arm.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698