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

Side by Side 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, 7 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 unified diff | Download patch
« no previous file with comments | « include/v8-version.h ('k') | test/cctest/cctest.gyp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2012 the V8 project authors. All rights reserved. 1 // Copyright 2012 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "src/api.h" 5 #include "src/api.h"
6 6
7 #include <string.h> // For memcpy, strlen. 7 #include <string.h> // For memcpy, strlen.
8 #ifdef V8_USE_ADDRESS_SANITIZER 8 #ifdef V8_USE_ADDRESS_SANITIZER
9 #include <sanitizer/asan_interface.h> 9 #include <sanitizer/asan_interface.h>
10 #endif // V8_USE_ADDRESS_SANITIZER 10 #endif // V8_USE_ADDRESS_SANITIZER
(...skipping 6415 matching lines...) Expand 10 before | Expand all | Expand 10 after
6426 DCHECK(data_view->buffer()->IsJSArrayBuffer()); 6426 DCHECK(data_view->buffer()->IsJSArrayBuffer());
6427 buffer = i::handle(i::JSArrayBuffer::cast(data_view->buffer())); 6427 buffer = i::handle(i::JSArrayBuffer::cast(data_view->buffer()));
6428 } else { 6428 } else {
6429 DCHECK(obj->IsJSTypedArray()); 6429 DCHECK(obj->IsJSTypedArray());
6430 buffer = i::JSTypedArray::cast(*obj)->GetBuffer(); 6430 buffer = i::JSTypedArray::cast(*obj)->GetBuffer();
6431 } 6431 }
6432 return Utils::ToLocal(buffer); 6432 return Utils::ToLocal(buffer);
6433 } 6433 }
6434 6434
6435 6435
6436 size_t v8::ArrayBufferView::CopyContents(void* dest, size_t byte_length) {
6437 i::Handle<i::JSArrayBufferView> obj = Utils::OpenHandle(this);
6438 i::Isolate* isolate = obj->GetIsolate();
6439 size_t byte_offset = i::NumberToSize(isolate, obj->byte_offset());
6440 size_t bytes_to_copy =
6441 i::Min(byte_length, i::NumberToSize(isolate, obj->byte_length()));
6442 if (bytes_to_copy) {
6443 i::DisallowHeapAllocation no_gc;
6444 const char* source = nullptr;
6445 if (obj->IsJSDataView()) {
6446 i::Handle<i::JSDataView> data_view(i::JSDataView::cast(*obj));
6447 i::Handle<i::JSArrayBuffer> buffer(
6448 i::JSArrayBuffer::cast(data_view->buffer()));
6449 source = reinterpret_cast<char*>(buffer->backing_store());
6450 } else {
6451 DCHECK(obj->IsJSTypedArray());
6452 i::Handle<i::JSTypedArray> typed_array(i::JSTypedArray::cast(*obj));
6453 if (typed_array->buffer()->IsSmi()) {
6454 i::Handle<i::FixedTypedArrayBase> fixed_array(
6455 i::FixedTypedArrayBase::cast(typed_array->elements()));
6456 source = reinterpret_cast<char*>(fixed_array->DataPtr());
6457 } else {
6458 i::Handle<i::JSArrayBuffer> buffer(
6459 i::JSArrayBuffer::cast(typed_array->buffer()));
6460 source = reinterpret_cast<char*>(buffer->backing_store());
6461 }
6462 }
6463 memcpy(dest, source + byte_offset, bytes_to_copy);
6464 }
6465 return bytes_to_copy;
6466 }
6467
6468
6436 size_t v8::ArrayBufferView::ByteOffset() { 6469 size_t v8::ArrayBufferView::ByteOffset() {
6437 i::Handle<i::JSArrayBufferView> obj = Utils::OpenHandle(this); 6470 i::Handle<i::JSArrayBufferView> obj = Utils::OpenHandle(this);
6438 return static_cast<size_t>(obj->byte_offset()->Number()); 6471 return static_cast<size_t>(obj->byte_offset()->Number());
6439 } 6472 }
6440 6473
6441 6474
6442 size_t v8::ArrayBufferView::ByteLength() { 6475 size_t v8::ArrayBufferView::ByteLength() {
6443 i::Handle<i::JSArrayBufferView> obj = Utils::OpenHandle(this); 6476 i::Handle<i::JSArrayBufferView> obj = Utils::OpenHandle(this);
6444 return static_cast<size_t>(obj->byte_length()->Number()); 6477 return static_cast<size_t>(obj->byte_length()->Number());
6445 } 6478 }
(...skipping 1616 matching lines...) Expand 10 before | Expand all | Expand 10 after
8062 Isolate* isolate = reinterpret_cast<Isolate*>(info.GetIsolate()); 8095 Isolate* isolate = reinterpret_cast<Isolate*>(info.GetIsolate());
8063 Address callback_address = 8096 Address callback_address =
8064 reinterpret_cast<Address>(reinterpret_cast<intptr_t>(callback)); 8097 reinterpret_cast<Address>(reinterpret_cast<intptr_t>(callback));
8065 VMState<EXTERNAL> state(isolate); 8098 VMState<EXTERNAL> state(isolate);
8066 ExternalCallbackScope call_scope(isolate, callback_address); 8099 ExternalCallbackScope call_scope(isolate, callback_address);
8067 callback(info); 8100 callback(info);
8068 } 8101 }
8069 8102
8070 8103
8071 } } // namespace v8::internal 8104 } } // namespace v8::internal
OLDNEW
« 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