| OLD | NEW |
| 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 6909 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6920 } else { | 6920 } else { |
| 6921 DCHECK(obj->IsJSTypedArray()); | 6921 DCHECK(obj->IsJSTypedArray()); |
| 6922 buffer = i::JSTypedArray::cast(*obj)->GetBuffer(); | 6922 buffer = i::JSTypedArray::cast(*obj)->GetBuffer(); |
| 6923 } | 6923 } |
| 6924 return Utils::ToLocal(buffer); | 6924 return Utils::ToLocal(buffer); |
| 6925 } | 6925 } |
| 6926 | 6926 |
| 6927 | 6927 |
| 6928 size_t v8::ArrayBufferView::CopyContents(void* dest, size_t byte_length) { | 6928 size_t v8::ArrayBufferView::CopyContents(void* dest, size_t byte_length) { |
| 6929 i::Handle<i::JSArrayBufferView> self = Utils::OpenHandle(this); | 6929 i::Handle<i::JSArrayBufferView> self = Utils::OpenHandle(this); |
| 6930 i::Isolate* isolate = self->GetIsolate(); | 6930 size_t byte_offset = i::NumberToSize(self->byte_offset()); |
| 6931 size_t byte_offset = i::NumberToSize(isolate, self->byte_offset()); | |
| 6932 size_t bytes_to_copy = | 6931 size_t bytes_to_copy = |
| 6933 i::Min(byte_length, i::NumberToSize(isolate, self->byte_length())); | 6932 i::Min(byte_length, i::NumberToSize(self->byte_length())); |
| 6934 if (bytes_to_copy) { | 6933 if (bytes_to_copy) { |
| 6935 i::DisallowHeapAllocation no_gc; | 6934 i::DisallowHeapAllocation no_gc; |
| 6936 i::Handle<i::JSArrayBuffer> buffer(i::JSArrayBuffer::cast(self->buffer())); | 6935 i::Handle<i::JSArrayBuffer> buffer(i::JSArrayBuffer::cast(self->buffer())); |
| 6937 const char* source = reinterpret_cast<char*>(buffer->backing_store()); | 6936 const char* source = reinterpret_cast<char*>(buffer->backing_store()); |
| 6938 if (source == nullptr) { | 6937 if (source == nullptr) { |
| 6939 DCHECK(self->IsJSTypedArray()); | 6938 DCHECK(self->IsJSTypedArray()); |
| 6940 i::Handle<i::JSTypedArray> typed_array(i::JSTypedArray::cast(*self)); | 6939 i::Handle<i::JSTypedArray> typed_array(i::JSTypedArray::cast(*self)); |
| 6941 i::Handle<i::FixedTypedArrayBase> fixed_array( | 6940 i::Handle<i::FixedTypedArrayBase> fixed_array( |
| 6942 i::FixedTypedArrayBase::cast(typed_array->elements())); | 6941 i::FixedTypedArrayBase::cast(typed_array->elements())); |
| 6943 source = reinterpret_cast<char*>(fixed_array->DataPtr()); | 6942 source = reinterpret_cast<char*>(fixed_array->DataPtr()); |
| (...skipping 2045 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 8989 Address callback_address = | 8988 Address callback_address = |
| 8990 reinterpret_cast<Address>(reinterpret_cast<intptr_t>(callback)); | 8989 reinterpret_cast<Address>(reinterpret_cast<intptr_t>(callback)); |
| 8991 VMState<EXTERNAL> state(isolate); | 8990 VMState<EXTERNAL> state(isolate); |
| 8992 ExternalCallbackScope call_scope(isolate, callback_address); | 8991 ExternalCallbackScope call_scope(isolate, callback_address); |
| 8993 callback(info); | 8992 callback(info); |
| 8994 } | 8993 } |
| 8995 | 8994 |
| 8996 | 8995 |
| 8997 } // namespace internal | 8996 } // namespace internal |
| 8998 } // namespace v8 | 8997 } // namespace v8 |
| OLD | NEW |