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 6541 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6552 i::Handle<i::JSArrayBuffer> obj = | 6552 i::Handle<i::JSArrayBuffer> obj = |
6553 i_isolate->factory()->NewJSArrayBuffer(i::SharedFlag::kNotShared); | 6553 i_isolate->factory()->NewJSArrayBuffer(i::SharedFlag::kNotShared); |
6554 i::Runtime::SetupArrayBufferAllocatingData(i_isolate, obj, byte_length); | 6554 i::Runtime::SetupArrayBufferAllocatingData(i_isolate, obj, byte_length); |
6555 return Utils::ToLocal(obj); | 6555 return Utils::ToLocal(obj); |
6556 } | 6556 } |
6557 | 6557 |
6558 | 6558 |
6559 Local<ArrayBuffer> v8::ArrayBuffer::New(Isolate* isolate, void* data, | 6559 Local<ArrayBuffer> v8::ArrayBuffer::New(Isolate* isolate, void* data, |
6560 size_t byte_length, | 6560 size_t byte_length, |
6561 ArrayBufferCreationMode mode) { | 6561 ArrayBufferCreationMode mode) { |
| 6562 // Embedders must guarantee that the external backing store is valid. |
| 6563 CHECK(data != NULL); |
6562 i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate); | 6564 i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate); |
6563 LOG_API(i_isolate, "v8::ArrayBuffer::New(void*, size_t)"); | 6565 LOG_API(i_isolate, "v8::ArrayBuffer::New(void*, size_t)"); |
6564 ENTER_V8(i_isolate); | 6566 ENTER_V8(i_isolate); |
6565 i::Handle<i::JSArrayBuffer> obj = | 6567 i::Handle<i::JSArrayBuffer> obj = |
6566 i_isolate->factory()->NewJSArrayBuffer(i::SharedFlag::kNotShared); | 6568 i_isolate->factory()->NewJSArrayBuffer(i::SharedFlag::kNotShared); |
6567 i::Runtime::SetupArrayBuffer(i_isolate, obj, | 6569 i::Runtime::SetupArrayBuffer(i_isolate, obj, |
6568 mode == ArrayBufferCreationMode::kExternalized, | 6570 mode == ArrayBufferCreationMode::kExternalized, |
6569 data, byte_length); | 6571 data, byte_length); |
6570 return Utils::ToLocal(obj); | 6572 return Utils::ToLocal(obj); |
6571 } | 6573 } |
(...skipping 177 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6749 i::Runtime::SetupArrayBufferAllocatingData(i_isolate, obj, byte_length, true, | 6751 i::Runtime::SetupArrayBufferAllocatingData(i_isolate, obj, byte_length, true, |
6750 i::SharedFlag::kShared); | 6752 i::SharedFlag::kShared); |
6751 return Utils::ToLocalShared(obj); | 6753 return Utils::ToLocalShared(obj); |
6752 } | 6754 } |
6753 | 6755 |
6754 | 6756 |
6755 Local<SharedArrayBuffer> v8::SharedArrayBuffer::New( | 6757 Local<SharedArrayBuffer> v8::SharedArrayBuffer::New( |
6756 Isolate* isolate, void* data, size_t byte_length, | 6758 Isolate* isolate, void* data, size_t byte_length, |
6757 ArrayBufferCreationMode mode) { | 6759 ArrayBufferCreationMode mode) { |
6758 CHECK(i::FLAG_harmony_sharedarraybuffer); | 6760 CHECK(i::FLAG_harmony_sharedarraybuffer); |
| 6761 // Embedders must guarantee that the external backing store is valid. |
| 6762 CHECK(data != NULL); |
6759 i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate); | 6763 i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate); |
6760 LOG_API(i_isolate, "v8::SharedArrayBuffer::New(void*, size_t)"); | 6764 LOG_API(i_isolate, "v8::SharedArrayBuffer::New(void*, size_t)"); |
6761 ENTER_V8(i_isolate); | 6765 ENTER_V8(i_isolate); |
6762 i::Handle<i::JSArrayBuffer> obj = | 6766 i::Handle<i::JSArrayBuffer> obj = |
6763 i_isolate->factory()->NewJSArrayBuffer(i::SharedFlag::kShared); | 6767 i_isolate->factory()->NewJSArrayBuffer(i::SharedFlag::kShared); |
6764 i::Runtime::SetupArrayBuffer(i_isolate, obj, | 6768 i::Runtime::SetupArrayBuffer(i_isolate, obj, |
6765 mode == ArrayBufferCreationMode::kExternalized, | 6769 mode == ArrayBufferCreationMode::kExternalized, |
6766 data, byte_length, i::SharedFlag::kShared); | 6770 data, byte_length, i::SharedFlag::kShared); |
6767 return Utils::ToLocalShared(obj); | 6771 return Utils::ToLocalShared(obj); |
6768 } | 6772 } |
(...skipping 1635 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
8404 Address callback_address = | 8408 Address callback_address = |
8405 reinterpret_cast<Address>(reinterpret_cast<intptr_t>(callback)); | 8409 reinterpret_cast<Address>(reinterpret_cast<intptr_t>(callback)); |
8406 VMState<EXTERNAL> state(isolate); | 8410 VMState<EXTERNAL> state(isolate); |
8407 ExternalCallbackScope call_scope(isolate, callback_address); | 8411 ExternalCallbackScope call_scope(isolate, callback_address); |
8408 callback(info); | 8412 callback(info); |
8409 } | 8413 } |
8410 | 8414 |
8411 | 8415 |
8412 } // namespace internal | 8416 } // namespace internal |
8413 } // namespace v8 | 8417 } // namespace v8 |
OLD | NEW |