| 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 7381 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 7392 return static_cast<size_t>(obj->byte_length()->Number()); | 7392 return static_cast<size_t>(obj->byte_length()->Number()); |
| 7393 } | 7393 } |
| 7394 | 7394 |
| 7395 | 7395 |
| 7396 Local<ArrayBuffer> v8::ArrayBuffer::New(Isolate* isolate, size_t byte_length) { | 7396 Local<ArrayBuffer> v8::ArrayBuffer::New(Isolate* isolate, size_t byte_length) { |
| 7397 i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate); | 7397 i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate); |
| 7398 LOG_API(i_isolate, ArrayBuffer, New); | 7398 LOG_API(i_isolate, ArrayBuffer, New); |
| 7399 ENTER_V8(i_isolate); | 7399 ENTER_V8(i_isolate); |
| 7400 i::Handle<i::JSArrayBuffer> obj = | 7400 i::Handle<i::JSArrayBuffer> obj = |
| 7401 i_isolate->factory()->NewJSArrayBuffer(i::SharedFlag::kNotShared); | 7401 i_isolate->factory()->NewJSArrayBuffer(i::SharedFlag::kNotShared); |
| 7402 i::JSArrayBuffer::SetupAllocatingData(obj, i_isolate, byte_length); | 7402 // TODO(jbroman): It may be useful in the future to provide a MaybeLocal |
| 7403 // version that throws an exception or otherwise does not crash. |
| 7404 if (!i::JSArrayBuffer::SetupAllocatingData(obj, i_isolate, byte_length)) { |
| 7405 i::FatalProcessOutOfMemory("v8::ArrayBuffer::New"); |
| 7406 } |
| 7403 return Utils::ToLocal(obj); | 7407 return Utils::ToLocal(obj); |
| 7404 } | 7408 } |
| 7405 | 7409 |
| 7406 | 7410 |
| 7407 Local<ArrayBuffer> v8::ArrayBuffer::New(Isolate* isolate, void* data, | 7411 Local<ArrayBuffer> v8::ArrayBuffer::New(Isolate* isolate, void* data, |
| 7408 size_t byte_length, | 7412 size_t byte_length, |
| 7409 ArrayBufferCreationMode mode) { | 7413 ArrayBufferCreationMode mode) { |
| 7410 // Embedders must guarantee that the external backing store is valid. | 7414 // Embedders must guarantee that the external backing store is valid. |
| 7411 CHECK(byte_length == 0 || data != NULL); | 7415 CHECK(byte_length == 0 || data != NULL); |
| 7412 i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate); | 7416 i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate); |
| (...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 7582 | 7586 |
| 7583 | 7587 |
| 7584 Local<SharedArrayBuffer> v8::SharedArrayBuffer::New(Isolate* isolate, | 7588 Local<SharedArrayBuffer> v8::SharedArrayBuffer::New(Isolate* isolate, |
| 7585 size_t byte_length) { | 7589 size_t byte_length) { |
| 7586 CHECK(i::FLAG_harmony_sharedarraybuffer); | 7590 CHECK(i::FLAG_harmony_sharedarraybuffer); |
| 7587 i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate); | 7591 i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate); |
| 7588 LOG_API(i_isolate, SharedArrayBuffer, New); | 7592 LOG_API(i_isolate, SharedArrayBuffer, New); |
| 7589 ENTER_V8(i_isolate); | 7593 ENTER_V8(i_isolate); |
| 7590 i::Handle<i::JSArrayBuffer> obj = | 7594 i::Handle<i::JSArrayBuffer> obj = |
| 7591 i_isolate->factory()->NewJSArrayBuffer(i::SharedFlag::kShared); | 7595 i_isolate->factory()->NewJSArrayBuffer(i::SharedFlag::kShared); |
| 7592 i::JSArrayBuffer::SetupAllocatingData(obj, i_isolate, byte_length, true, | 7596 // TODO(jbroman): It may be useful in the future to provide a MaybeLocal |
| 7593 i::SharedFlag::kShared); | 7597 // version that throws an exception or otherwise does not crash. |
| 7598 if (!i::JSArrayBuffer::SetupAllocatingData(obj, i_isolate, byte_length, true, |
| 7599 i::SharedFlag::kShared)) { |
| 7600 i::FatalProcessOutOfMemory("v8::SharedArrayBuffer::New"); |
| 7601 } |
| 7594 return Utils::ToLocalShared(obj); | 7602 return Utils::ToLocalShared(obj); |
| 7595 } | 7603 } |
| 7596 | 7604 |
| 7597 | 7605 |
| 7598 Local<SharedArrayBuffer> v8::SharedArrayBuffer::New( | 7606 Local<SharedArrayBuffer> v8::SharedArrayBuffer::New( |
| 7599 Isolate* isolate, void* data, size_t byte_length, | 7607 Isolate* isolate, void* data, size_t byte_length, |
| 7600 ArrayBufferCreationMode mode) { | 7608 ArrayBufferCreationMode mode) { |
| 7601 CHECK(i::FLAG_harmony_sharedarraybuffer); | 7609 CHECK(i::FLAG_harmony_sharedarraybuffer); |
| 7602 // Embedders must guarantee that the external backing store is valid. | 7610 // Embedders must guarantee that the external backing store is valid. |
| 7603 CHECK(byte_length == 0 || data != NULL); | 7611 CHECK(byte_length == 0 || data != NULL); |
| (...skipping 2189 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 9793 Address callback_address = | 9801 Address callback_address = |
| 9794 reinterpret_cast<Address>(reinterpret_cast<intptr_t>(callback)); | 9802 reinterpret_cast<Address>(reinterpret_cast<intptr_t>(callback)); |
| 9795 VMState<EXTERNAL> state(isolate); | 9803 VMState<EXTERNAL> state(isolate); |
| 9796 ExternalCallbackScope call_scope(isolate, callback_address); | 9804 ExternalCallbackScope call_scope(isolate, callback_address); |
| 9797 callback(info); | 9805 callback(info); |
| 9798 } | 9806 } |
| 9799 | 9807 |
| 9800 | 9808 |
| 9801 } // namespace internal | 9809 } // namespace internal |
| 9802 } // namespace v8 | 9810 } // namespace v8 |
| OLD | NEW |