v8  8.6.395(node15.0.1)
V8 is Google's open source JavaScript engine
BackingStore Class Reference

#include <v8.h>

Inheritance diagram for BackingStore:
Collaboration diagram for BackingStore:

Public Types

using DeleterCallback = void(*)(void *data, size_t length, void *deleter_data)

Public Member Functions

 ~BackingStore ()
void * Data () const
size_t ByteLength () const
bool IsShared () const

Static Public Member Functions

static std::unique_ptr< BackingStoreReallocate (v8::Isolate *isolate, std::unique_ptr< BackingStore > backing_store, size_t byte_length)
static void EmptyDeleter (void *data, size_t length, void *deleter_data)

Detailed Description

A wrapper around the backing store (i.e. the raw memory) of an array buffer. See a document linked in http://crbug.com/v8/9908 for more information.

The allocation and destruction of backing stores is generally managed by V8. Clients should always use standard C++ memory ownership types (i.e. std::unique_ptr and std::shared_ptr) to manage lifetimes of backing stores properly, since V8 internal objects may alias backing stores.

This object does not keep the underlying |ArrayBuffer::Allocator| alive by default. Use Isolate::CreateParams::array_buffer_allocator_shared when creating the Isolate to make it hold a reference to the allocator itself.

Definition at line 4999 of file v8.h.

Member Typedef Documentation

◆ DeleterCallback

using DeleterCallback = void (*)(void* data, size_t length, void* deleter_data)

This callback is used only if the memory block for a BackingStore cannot be allocated with an ArrayBuffer::Allocator. In such cases the destructor of the BackingStore invokes the callback to free the memory block.

Definition at line 5036 of file v8.h.

Constructor & Destructor Documentation

◆ ~BackingStore()

Member Function Documentation

◆ ByteLength()

size_t ByteLength ( ) const

The length (in bytes) of this backing store.

◆ Data()

void* Data ( ) const

Return a pointer to the beginning of the memory block for this backing store. The pointer is only valid as long as this backing store object lives.

◆ EmptyDeleter()

static void EmptyDeleter ( void *  data,
size_t  length,
void *  deleter_data 

If the memory block of a BackingStore is static or is managed manually, then this empty deleter along with nullptr deleter_data can be passed to ArrayBuffer::NewBackingStore to indicate that.

The manually managed case should be used with caution and only when it is guaranteed that the memory block freeing happens after detaching its ArrayBuffer.

◆ IsShared()

bool IsShared ( ) const

Indicates whether the backing store was created for an ArrayBuffer or a SharedArrayBuffer.

◆ Reallocate()

static std::unique_ptr<BackingStore> Reallocate ( v8::Isolate isolate,
std::unique_ptr< BackingStore backing_store,
size_t  byte_length 

Wrapper around ArrayBuffer::Allocator::Reallocate that preserves IsShared. Assumes that the backing_store was allocated by the ArrayBuffer allocator of the given isolate.

The documentation for this class was generated from the following file: