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 6534 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6545 return static_cast<size_t>(obj->byte_length()->Number()); | 6545 return static_cast<size_t>(obj->byte_length()->Number()); |
6546 } | 6546 } |
6547 | 6547 |
6548 | 6548 |
6549 Local<ArrayBuffer> v8::ArrayBuffer::New(Isolate* isolate, size_t byte_length) { | 6549 Local<ArrayBuffer> v8::ArrayBuffer::New(Isolate* isolate, size_t byte_length) { |
6550 i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate); | 6550 i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate); |
6551 LOG_API(i_isolate, "v8::ArrayBuffer::New(size_t)"); | 6551 LOG_API(i_isolate, "v8::ArrayBuffer::New(size_t)"); |
6552 ENTER_V8(i_isolate); | 6552 ENTER_V8(i_isolate); |
6553 i::Handle<i::JSArrayBuffer> obj = | 6553 i::Handle<i::JSArrayBuffer> obj = |
6554 i_isolate->factory()->NewJSArrayBuffer(i::SharedFlag::kNotShared); | 6554 i_isolate->factory()->NewJSArrayBuffer(i::SharedFlag::kNotShared); |
6555 i::Runtime::SetupArrayBufferAllocatingData(i_isolate, obj, byte_length); | 6555 i::JSArrayBuffer::SetupAllocatingData(obj, i_isolate, byte_length); |
6556 return Utils::ToLocal(obj); | 6556 return Utils::ToLocal(obj); |
6557 } | 6557 } |
6558 | 6558 |
6559 | 6559 |
6560 Local<ArrayBuffer> v8::ArrayBuffer::New(Isolate* isolate, void* data, | 6560 Local<ArrayBuffer> v8::ArrayBuffer::New(Isolate* isolate, void* data, |
6561 size_t byte_length, | 6561 size_t byte_length, |
6562 ArrayBufferCreationMode mode) { | 6562 ArrayBufferCreationMode mode) { |
6563 // Embedders must guarantee that the external backing store is valid. | 6563 // Embedders must guarantee that the external backing store is valid. |
6564 CHECK(byte_length == 0 || data != NULL); | 6564 CHECK(byte_length == 0 || data != NULL); |
6565 i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate); | 6565 i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate); |
6566 LOG_API(i_isolate, "v8::ArrayBuffer::New(void*, size_t)"); | 6566 LOG_API(i_isolate, "v8::ArrayBuffer::New(void*, size_t)"); |
6567 ENTER_V8(i_isolate); | 6567 ENTER_V8(i_isolate); |
6568 i::Handle<i::JSArrayBuffer> obj = | 6568 i::Handle<i::JSArrayBuffer> obj = |
6569 i_isolate->factory()->NewJSArrayBuffer(i::SharedFlag::kNotShared); | 6569 i_isolate->factory()->NewJSArrayBuffer(i::SharedFlag::kNotShared); |
6570 i::Runtime::SetupArrayBuffer(i_isolate, obj, | 6570 i::JSArrayBuffer::Setup(obj, i_isolate, |
6571 mode == ArrayBufferCreationMode::kExternalized, | 6571 mode == ArrayBufferCreationMode::kExternalized, data, |
6572 data, byte_length); | 6572 byte_length); |
6573 return Utils::ToLocal(obj); | 6573 return Utils::ToLocal(obj); |
6574 } | 6574 } |
6575 | 6575 |
6576 | 6576 |
6577 Local<ArrayBuffer> v8::ArrayBufferView::Buffer() { | 6577 Local<ArrayBuffer> v8::ArrayBufferView::Buffer() { |
6578 i::Handle<i::JSArrayBufferView> obj = Utils::OpenHandle(this); | 6578 i::Handle<i::JSArrayBufferView> obj = Utils::OpenHandle(this); |
6579 i::Handle<i::JSArrayBuffer> buffer; | 6579 i::Handle<i::JSArrayBuffer> buffer; |
6580 if (obj->IsJSDataView()) { | 6580 if (obj->IsJSDataView()) { |
6581 i::Handle<i::JSDataView> data_view(i::JSDataView::cast(*obj)); | 6581 i::Handle<i::JSDataView> data_view(i::JSDataView::cast(*obj)); |
6582 DCHECK(data_view->buffer()->IsJSArrayBuffer()); | 6582 DCHECK(data_view->buffer()->IsJSArrayBuffer()); |
(...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6742 | 6742 |
6743 | 6743 |
6744 Local<SharedArrayBuffer> v8::SharedArrayBuffer::New(Isolate* isolate, | 6744 Local<SharedArrayBuffer> v8::SharedArrayBuffer::New(Isolate* isolate, |
6745 size_t byte_length) { | 6745 size_t byte_length) { |
6746 CHECK(i::FLAG_harmony_sharedarraybuffer); | 6746 CHECK(i::FLAG_harmony_sharedarraybuffer); |
6747 i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate); | 6747 i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate); |
6748 LOG_API(i_isolate, "v8::SharedArrayBuffer::New(size_t)"); | 6748 LOG_API(i_isolate, "v8::SharedArrayBuffer::New(size_t)"); |
6749 ENTER_V8(i_isolate); | 6749 ENTER_V8(i_isolate); |
6750 i::Handle<i::JSArrayBuffer> obj = | 6750 i::Handle<i::JSArrayBuffer> obj = |
6751 i_isolate->factory()->NewJSArrayBuffer(i::SharedFlag::kShared); | 6751 i_isolate->factory()->NewJSArrayBuffer(i::SharedFlag::kShared); |
6752 i::Runtime::SetupArrayBufferAllocatingData(i_isolate, obj, byte_length, true, | 6752 i::JSArrayBuffer::SetupAllocatingData(obj, i_isolate, byte_length, true, |
6753 i::SharedFlag::kShared); | 6753 i::SharedFlag::kShared); |
6754 return Utils::ToLocalShared(obj); | 6754 return Utils::ToLocalShared(obj); |
6755 } | 6755 } |
6756 | 6756 |
6757 | 6757 |
6758 Local<SharedArrayBuffer> v8::SharedArrayBuffer::New( | 6758 Local<SharedArrayBuffer> v8::SharedArrayBuffer::New( |
6759 Isolate* isolate, void* data, size_t byte_length, | 6759 Isolate* isolate, void* data, size_t byte_length, |
6760 ArrayBufferCreationMode mode) { | 6760 ArrayBufferCreationMode mode) { |
6761 CHECK(i::FLAG_harmony_sharedarraybuffer); | 6761 CHECK(i::FLAG_harmony_sharedarraybuffer); |
6762 // Embedders must guarantee that the external backing store is valid. | 6762 // Embedders must guarantee that the external backing store is valid. |
6763 CHECK(byte_length == 0 || data != NULL); | 6763 CHECK(byte_length == 0 || data != NULL); |
6764 i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate); | 6764 i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate); |
6765 LOG_API(i_isolate, "v8::SharedArrayBuffer::New(void*, size_t)"); | 6765 LOG_API(i_isolate, "v8::SharedArrayBuffer::New(void*, size_t)"); |
6766 ENTER_V8(i_isolate); | 6766 ENTER_V8(i_isolate); |
6767 i::Handle<i::JSArrayBuffer> obj = | 6767 i::Handle<i::JSArrayBuffer> obj = |
6768 i_isolate->factory()->NewJSArrayBuffer(i::SharedFlag::kShared); | 6768 i_isolate->factory()->NewJSArrayBuffer(i::SharedFlag::kShared); |
6769 i::Runtime::SetupArrayBuffer(i_isolate, obj, | 6769 i::JSArrayBuffer::Setup(obj, i_isolate, |
6770 mode == ArrayBufferCreationMode::kExternalized, | 6770 mode == ArrayBufferCreationMode::kExternalized, data, |
6771 data, byte_length, i::SharedFlag::kShared); | 6771 byte_length, i::SharedFlag::kShared); |
6772 return Utils::ToLocalShared(obj); | 6772 return Utils::ToLocalShared(obj); |
6773 } | 6773 } |
6774 | 6774 |
6775 | 6775 |
6776 Local<Symbol> v8::Symbol::New(Isolate* isolate, Local<String> name) { | 6776 Local<Symbol> v8::Symbol::New(Isolate* isolate, Local<String> name) { |
6777 i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate); | 6777 i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate); |
6778 LOG_API(i_isolate, "Symbol::New()"); | 6778 LOG_API(i_isolate, "Symbol::New()"); |
6779 ENTER_V8(i_isolate); | 6779 ENTER_V8(i_isolate); |
6780 i::Handle<i::Symbol> result = i_isolate->factory()->NewSymbol(); | 6780 i::Handle<i::Symbol> result = i_isolate->factory()->NewSymbol(); |
6781 if (!name.IsEmpty()) result->set_name(*Utils::OpenHandle(*name)); | 6781 if (!name.IsEmpty()) result->set_name(*Utils::OpenHandle(*name)); |
(...skipping 1627 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
8409 Address callback_address = | 8409 Address callback_address = |
8410 reinterpret_cast<Address>(reinterpret_cast<intptr_t>(callback)); | 8410 reinterpret_cast<Address>(reinterpret_cast<intptr_t>(callback)); |
8411 VMState<EXTERNAL> state(isolate); | 8411 VMState<EXTERNAL> state(isolate); |
8412 ExternalCallbackScope call_scope(isolate, callback_address); | 8412 ExternalCallbackScope call_scope(isolate, callback_address); |
8413 callback(info); | 8413 callback(info); |
8414 } | 8414 } |
8415 | 8415 |
8416 | 8416 |
8417 } // namespace internal | 8417 } // namespace internal |
8418 } // namespace v8 | 8418 } // namespace v8 |
OLD | NEW |