| 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 7557 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 7568 return static_cast<size_t>(obj->byte_length()->Number()); | 7568 return static_cast<size_t>(obj->byte_length()->Number()); |
| 7569 } | 7569 } |
| 7570 | 7570 |
| 7571 | 7571 |
| 7572 Local<ArrayBuffer> v8::ArrayBuffer::New(Isolate* isolate, size_t byte_length) { | 7572 Local<ArrayBuffer> v8::ArrayBuffer::New(Isolate* isolate, size_t byte_length) { |
| 7573 i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate); | 7573 i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate); |
| 7574 LOG_API(i_isolate, ArrayBuffer, New); | 7574 LOG_API(i_isolate, ArrayBuffer, New); |
| 7575 ENTER_V8_NO_SCRIPT_NO_EXCEPTION(i_isolate); | 7575 ENTER_V8_NO_SCRIPT_NO_EXCEPTION(i_isolate); |
| 7576 i::Handle<i::JSArrayBuffer> obj = | 7576 i::Handle<i::JSArrayBuffer> obj = |
| 7577 i_isolate->factory()->NewJSArrayBuffer(i::SharedFlag::kNotShared); | 7577 i_isolate->factory()->NewJSArrayBuffer(i::SharedFlag::kNotShared); |
| 7578 i::JSArrayBuffer::SetupAllocatingData(obj, i_isolate, byte_length); | 7578 // TODO(jbroman): It may be useful in the future to provide a MaybeLocal |
| 7579 // version that throws an exception or otherwise does not crash. |
| 7580 if (!i::JSArrayBuffer::SetupAllocatingData(obj, i_isolate, byte_length)) { |
| 7581 i::FatalProcessOutOfMemory("v8::ArrayBuffer::New"); |
| 7582 } |
| 7579 return Utils::ToLocal(obj); | 7583 return Utils::ToLocal(obj); |
| 7580 } | 7584 } |
| 7581 | 7585 |
| 7582 | 7586 |
| 7583 Local<ArrayBuffer> v8::ArrayBuffer::New(Isolate* isolate, void* data, | 7587 Local<ArrayBuffer> v8::ArrayBuffer::New(Isolate* isolate, void* data, |
| 7584 size_t byte_length, | 7588 size_t byte_length, |
| 7585 ArrayBufferCreationMode mode) { | 7589 ArrayBufferCreationMode mode) { |
| 7586 // Embedders must guarantee that the external backing store is valid. | 7590 // Embedders must guarantee that the external backing store is valid. |
| 7587 CHECK(byte_length == 0 || data != NULL); | 7591 CHECK(byte_length == 0 || data != NULL); |
| 7588 i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate); | 7592 i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate); |
| (...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 7758 | 7762 |
| 7759 | 7763 |
| 7760 Local<SharedArrayBuffer> v8::SharedArrayBuffer::New(Isolate* isolate, | 7764 Local<SharedArrayBuffer> v8::SharedArrayBuffer::New(Isolate* isolate, |
| 7761 size_t byte_length) { | 7765 size_t byte_length) { |
| 7762 CHECK(i::FLAG_harmony_sharedarraybuffer); | 7766 CHECK(i::FLAG_harmony_sharedarraybuffer); |
| 7763 i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate); | 7767 i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate); |
| 7764 LOG_API(i_isolate, SharedArrayBuffer, New); | 7768 LOG_API(i_isolate, SharedArrayBuffer, New); |
| 7765 ENTER_V8_NO_SCRIPT_NO_EXCEPTION(i_isolate); | 7769 ENTER_V8_NO_SCRIPT_NO_EXCEPTION(i_isolate); |
| 7766 i::Handle<i::JSArrayBuffer> obj = | 7770 i::Handle<i::JSArrayBuffer> obj = |
| 7767 i_isolate->factory()->NewJSArrayBuffer(i::SharedFlag::kShared); | 7771 i_isolate->factory()->NewJSArrayBuffer(i::SharedFlag::kShared); |
| 7768 i::JSArrayBuffer::SetupAllocatingData(obj, i_isolate, byte_length, true, | 7772 // TODO(jbroman): It may be useful in the future to provide a MaybeLocal |
| 7769 i::SharedFlag::kShared); | 7773 // version that throws an exception or otherwise does not crash. |
| 7774 if (!i::JSArrayBuffer::SetupAllocatingData(obj, i_isolate, byte_length, true, |
| 7775 i::SharedFlag::kShared)) { |
| 7776 i::FatalProcessOutOfMemory("v8::SharedArrayBuffer::New"); |
| 7777 } |
| 7770 return Utils::ToLocalShared(obj); | 7778 return Utils::ToLocalShared(obj); |
| 7771 } | 7779 } |
| 7772 | 7780 |
| 7773 | 7781 |
| 7774 Local<SharedArrayBuffer> v8::SharedArrayBuffer::New( | 7782 Local<SharedArrayBuffer> v8::SharedArrayBuffer::New( |
| 7775 Isolate* isolate, void* data, size_t byte_length, | 7783 Isolate* isolate, void* data, size_t byte_length, |
| 7776 ArrayBufferCreationMode mode) { | 7784 ArrayBufferCreationMode mode) { |
| 7777 CHECK(i::FLAG_harmony_sharedarraybuffer); | 7785 CHECK(i::FLAG_harmony_sharedarraybuffer); |
| 7778 // Embedders must guarantee that the external backing store is valid. | 7786 // Embedders must guarantee that the external backing store is valid. |
| 7779 CHECK(byte_length == 0 || data != NULL); | 7787 CHECK(byte_length == 0 || data != NULL); |
| (...skipping 2233 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 10013 Address callback_address = | 10021 Address callback_address = |
| 10014 reinterpret_cast<Address>(reinterpret_cast<intptr_t>(callback)); | 10022 reinterpret_cast<Address>(reinterpret_cast<intptr_t>(callback)); |
| 10015 VMState<EXTERNAL> state(isolate); | 10023 VMState<EXTERNAL> state(isolate); |
| 10016 ExternalCallbackScope call_scope(isolate, callback_address); | 10024 ExternalCallbackScope call_scope(isolate, callback_address); |
| 10017 callback(info); | 10025 callback(info); |
| 10018 } | 10026 } |
| 10019 | 10027 |
| 10020 | 10028 |
| 10021 } // namespace internal | 10029 } // namespace internal |
| 10022 } // namespace v8 | 10030 } // namespace v8 |
| OLD | NEW |