![]() |
v8 13.6.233 (node 24.1.0)
V8 is Google's open source JavaScript engine
|
#include <v8-array-buffer.h>
Data Structures | |
class | Allocator |
Static Public Member Functions | |
static MaybeLocal< ArrayBuffer > | MaybeNew (Isolate *isolate, size_t byte_length, BackingStoreInitializationMode initialization_mode=BackingStoreInitializationMode::kZeroInitialized) |
static Local< ArrayBuffer > | New (Isolate *isolate, size_t byte_length, BackingStoreInitializationMode initialization_mode=BackingStoreInitializationMode::kZeroInitialized) |
static Local< ArrayBuffer > | New (Isolate *isolate, std::shared_ptr< BackingStore > backing_store) |
static std::unique_ptr< BackingStore > | NewBackingStore (Isolate *isolate, size_t byte_length, BackingStoreInitializationMode initialization_mode=BackingStoreInitializationMode::kZeroInitialized, BackingStoreOnFailureMode on_failure=BackingStoreOnFailureMode::kOutOfMemory) |
static std::unique_ptr< BackingStore > | NewBackingStore (void *data, size_t byte_length, v8::BackingStore::DeleterCallback deleter, void *deleter_data) |
static std::unique_ptr< BackingStore > | NewResizableBackingStore (size_t byte_length, size_t max_byte_length) |
static V8_INLINE ArrayBuffer * | Cast (Value *value) |
![]() | |
static V8_INLINE int | InternalFieldCount (const PersistentBase< Object > &object) |
static V8_INLINE int | InternalFieldCount (const BasicTracedReference< Object > &object) |
static V8_INLINE void * | GetAlignedPointerFromInternalField (const PersistentBase< Object > &object, int index) |
static V8_INLINE void * | GetAlignedPointerFromInternalField (const BasicTracedReference< Object > &object, int index) |
template<CppHeapPointerTag tag, typename T = void> | |
static V8_INLINE T * | Unwrap (v8::Isolate *isolate, const v8::Local< v8::Object > &wrapper) |
template<CppHeapPointerTag tag, typename T = void> | |
static V8_INLINE T * | Unwrap (v8::Isolate *isolate, const PersistentBase< Object > &wrapper) |
template<CppHeapPointerTag tag, typename T = void> | |
static V8_INLINE T * | Unwrap (v8::Isolate *isolate, const BasicTracedReference< Object > &wrapper) |
template<typename T = void> | |
static V8_INLINE T * | Unwrap (v8::Isolate *isolate, const v8::Local< v8::Object > &wrapper, CppHeapPointerTagRange tag_range) |
template<typename T = void> | |
static V8_INLINE T * | Unwrap (v8::Isolate *isolate, const PersistentBase< Object > &wrapper, CppHeapPointerTagRange tag_range) |
template<typename T = void> | |
static V8_INLINE T * | Unwrap (v8::Isolate *isolate, const BasicTracedReference< Object > &wrapper, CppHeapPointerTagRange tag_range) |
template<CppHeapPointerTag tag> | |
static V8_INLINE void | Wrap (v8::Isolate *isolate, const v8::Local< v8::Object > &wrapper, void *wrappable) |
template<CppHeapPointerTag tag> | |
static V8_INLINE void | Wrap (v8::Isolate *isolate, const PersistentBase< Object > &wrapper, void *wrappable) |
template<CppHeapPointerTag tag> | |
static V8_INLINE void | Wrap (v8::Isolate *isolate, const BasicTracedReference< Object > &wrapper, void *wrappable) |
static V8_INLINE void | Wrap (v8::Isolate *isolate, const v8::Local< v8::Object > &wrapper, void *wrappable, CppHeapPointerTag tag) |
static V8_INLINE void | Wrap (v8::Isolate *isolate, const PersistentBase< Object > &wrapper, void *wrappable, CppHeapPointerTag tag) |
static V8_INLINE void | Wrap (v8::Isolate *isolate, const BasicTracedReference< Object > &wrapper, void *wrappable, CppHeapPointerTag tag) |
static V8_INLINE MaybeLocal< Context > | GetCreationContext (v8::Isolate *isolate, const PersistentBase< Object > &object) |
static V8_INLINE MaybeLocal< Context > | GetCreationContext (const PersistentBase< Object > &object) |
static V8_INLINE Isolate * | GetIsolate (const TracedReference< Object > &handle) |
static Local< Object > | New (Isolate *isolate) |
static Local< Object > | New (Isolate *isolate, Local< Value > prototype_or_null, Local< Name > *names, Local< Value > *values, size_t length) |
static V8_INLINE Object * | Cast (Value *obj) |
![]() | |
template<class T> | |
static V8_INLINE Value * | Cast (T *value) |
Static Public Attributes | |
static constexpr int | kInternalFieldCount |
static constexpr int | kEmbedderFieldCount = kInternalFieldCount |
static constexpr size_t | kMaxByteLength |
Friends | |
class | TypedArray |
Additional Inherited Members | |
![]() | |
Local< Value > | prototype |
An instance of the built-in ArrayBuffer constructor (ES6 draft 15.13.5).
Definition at line 131 of file v8-array-buffer.h.
size_t ByteLength | ( | ) | const |
Data length in bytes.
|
inlinestatic |
Definition at line 380 of file v8-array-buffer.h.
References Cast(), and V8_INLINE.
Referenced by Cast().
void * Data | ( | ) | const |
More efficient shortcut for GetBackingStore()->Data(). The returned pointer is valid as long as the ArrayBuffer is alive.
References Data().
Referenced by Data().
V8_WARN_UNUSED_RESULT Maybe< bool > Detach | ( | v8::Local< v8::Value > | key | ) |
Detaches this ArrayBuffer and all its views (typed arrays). Detaching sets the byte length of the buffer and all typed arrays to zero, preventing JavaScript from ever accessing underlying backing store. ArrayBuffer should have been externalized and must be detachable. Returns Nothing if the key didn't pass the [[ArrayBufferDetachKey]] check, Just(true) otherwise.
References Detach(), and V8_WARN_UNUSED_RESULT.
Referenced by Detach(), and V8_DEPRECATED().
std::shared_ptr< BackingStore > GetBackingStore | ( | ) |
Get a shared pointer to the backing store of this array buffer. This pointer coordinates the lifetime management of the internal storage with any live ArrayBuffers on the heap, even across isolates. The embedder should not attempt to manage lifetime of the storage through other means.
The returned shared pointer will not be empty, even if the ArrayBuffer has been detached. Use |WasDetached| to tell if it has been detached instead.
References GetBackingStore().
Referenced by GetBackingStore().
bool IsDetachable | ( | ) | const |
Returns true if this ArrayBuffer may be detached.
bool IsResizableByUserJavaScript | ( | ) | const |
More efficient shortcut for GetBackingStore()->IsResizableByUserJavaScript().
References IsResizableByUserJavaScript().
Referenced by IsResizableByUserJavaScript().
size_t MaxByteLength | ( | ) | const |
Maximum length in bytes.
|
static |
Attempt to create a new ArrayBuffer. Allocate |byte_length| bytes. Allocated memory will be owned by a created ArrayBuffer and will be deallocated when it is garbage-collected, unless the object is externalized. If allocation fails, the Maybe returned will be empty.
References v8::kZeroInitialized.
|
static |
Create a new ArrayBuffer. Allocate |byte_length| bytes, which are either zero-initialized or uninitialized. Allocated memory will be owned by a created ArrayBuffer and will be deallocated when it is garbage-collected, unless the object is externalized.
References v8::kZeroInitialized.
|
static |
Create a new ArrayBuffer with an existing backing store. The created array keeps a reference to the backing store until the array is garbage collected. Note that the IsExternal bit does not affect this reference from the array to the backing store.
In future IsExternal bit will be removed. Until then the bit is set as follows. If the backing store does not own the underlying buffer, then the array is created in externalized state. Otherwise, the array is created in internalized state. In the latter case the array can be transitioned to the externalized state using Externalize(backing_store).
|
static |
Returns a new standalone BackingStore that is allocated using the array buffer allocator of the isolate. The allocation can either be zero initialized, or uninitialized. The result can be later passed to ArrayBuffer::New.
If the allocator returns nullptr, then the function may cause GCs in the given isolate and re-try the allocation.
If GCs do not help and on_failure is kOutOfMemory, then the function will crash with an out-of-memory error.
Otherwise if GCs do not help (or the allocation is too large for GCs to help) and on_failure is kReturnNull, then a null result is returned.
References v8::kOutOfMemory, and v8::kZeroInitialized.
|
static |
Returns a new standalone BackingStore that takes over the ownership of the given buffer. The destructor of the BackingStore invokes the given deleter callback.
The result can be later passed to ArrayBuffer::New. The raw pointer to the buffer must not be passed again to any V8 API function.
|
static |
Returns a new resizable standalone BackingStore that is allocated using the array buffer allocator of the isolate. The result can be later passed to ArrayBuffer::New.
|byte_length| must be <= |max_byte_length|.
This function is usable without an isolate. Unlike |NewBackingStore| calls with an isolate, GCs cannot be triggered, and there are no retries. Allocation failure will cause the function to crash with an out-of-memory error.
V8_DEPRECATED | ( | "Use the version which takes a key parameter (passing a null handle is " "ok)." | ) |
Detaches this ArrayBuffer and all its views (typed arrays). Detaching sets the byte length of the buffer and all typed arrays to zero, preventing JavaScript from ever accessing underlying backing store. ArrayBuffer should have been externalized and must be detachable.
References Detach().
bool WasDetached | ( | ) | const |
Returns true if this ArrayBuffer has been detached.
|
friend |
|
staticconstexpr |
Definition at line 389 of file v8-array-buffer.h.
|
staticconstexpr |
Definition at line 387 of file v8-array-buffer.h.
|
staticconstexpr |
Definition at line 398 of file v8-array-buffer.h.
Referenced by ArrayBuffer::Allocator::MaxAllocationSize().