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

Unified Diff: src/api.cc

Issue 1119513003: Version 4.3.61.15 (cherry-pick) (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@4.3
Patch Set: 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-version.h ('k') | test/cctest/cctest.gyp » ('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 64f387a2ff95fe38532f8f8d12ca05cd42c6908e..8a84dd39d4a88b40fd1b21bc58cde89ae89fee31 100644
--- a/src/api.cc
+++ b/src/api.cc
@@ -6433,6 +6433,39 @@ 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());
+ size_t bytes_to_copy =
+ i::Min(byte_length, i::NumberToSize(isolate, obj->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());
+ }
+ }
+ memcpy(dest, source + byte_offset, bytes_to_copy);
+ }
+ return bytes_to_copy;
+}
+
+
size_t v8::ArrayBufferView::ByteOffset() {
i::Handle<i::JSArrayBufferView> obj = Utils::OpenHandle(this);
return static_cast<size_t>(obj->byte_offset()->Number());
« no previous file with comments | « include/v8-version.h ('k') | test/cctest/cctest.gyp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698