Loading...
Searching...
No Matches
Public Types | Public Member Functions | Static Public Member Functions | List of all members
v8::ArrayBuffer::Allocator Class Referenceabstract

#include <v8.h>

Public Types

enum class  AllocationMode { kNormal , kReservation }
 
enum class  Protection { kNoAccess , kReadWrite }
 

Public Member Functions

virtual ~Allocator ()
 
virtual void * Allocate (size_t length)=0
 
virtual void * AllocateUninitialized (size_t length)=0
 
virtual void * Reserve (size_t length)
 
virtual void Free (void *data, size_t length)=0
 
virtual void Free (void *data, size_t length, AllocationMode mode)
 
virtual void SetProtection (void *data, size_t length, Protection protection)
 

Static Public Member Functions

static AllocatorNewDefaultAllocator ()
 

Detailed Description

A thread-safe allocator that V8 uses to allocate |ArrayBuffer|'s memory. The allocator is a global V8 setting. It has to be set via Isolate::CreateParams.

Memory allocated through this allocator by V8 is accounted for as external memory by V8. Note that V8 keeps track of the memory for all internalized |ArrayBuffer|s. Responsibility for tracking external memory (using Isolate::AdjustAmountOfExternalAllocatedMemory) is handed over to the embedder upon externalization and taken over upon internalization (creating an internalized buffer from an existing buffer).

Note that it is unsafe to call back into V8 from any of the allocator functions.

Member Enumeration Documentation

◆ AllocationMode

Enumerator
kNormal 
kReservation 

◆ Protection

Enumerator
kNoAccess 
kReadWrite 

Constructor & Destructor Documentation

◆ ~Allocator()

virtual v8::ArrayBuffer::Allocator::~Allocator ( )
inlinevirtual

Member Function Documentation

◆ Allocate()

virtual void * v8::ArrayBuffer::Allocator::Allocate ( size_t  length)
pure virtual

Allocate |length| bytes. Return NULL if allocation is not successful. Memory should be initialized to zeroes.

◆ AllocateUninitialized()

virtual void * v8::ArrayBuffer::Allocator::AllocateUninitialized ( size_t  length)
pure virtual

Allocate |length| bytes. Return NULL if allocation is not successful. Memory does not have to be initialized.

◆ Free() [1/2]

virtual void v8::ArrayBuffer::Allocator::Free ( void *  data,
size_t  length 
)
pure virtual

Free the memory block of size |length|, pointed to by |data|. That memory is guaranteed to be previously allocated by |Allocate|.

◆ Free() [2/2]

virtual void v8::ArrayBuffer::Allocator::Free ( void *  data,
size_t  length,
AllocationMode  mode 
)
virtual

Free the memory block of size |length|, pointed to by |data|. That memory is guaranteed to be previously allocated by |Allocate| or |Reserve|, depending on |mode|.

◆ NewDefaultAllocator()

static Allocator * v8::ArrayBuffer::Allocator::NewDefaultAllocator ( )
static

malloc/free based convenience allocator.

Caller takes ownership, i.e. the returned object needs to be freed using |delete allocator| once it is no longer in use.

Examples
process.cc, and shell.cc.

◆ Reserve()

virtual void * v8::ArrayBuffer::Allocator::Reserve ( size_t  length)
virtual

Reserved |length| bytes, but do not commit the memory. Must call |SetProtection| to make memory accessible.

◆ SetProtection()

virtual void v8::ArrayBuffer::Allocator::SetProtection ( void *  data,
size_t  length,
Protection  protection 
)
virtual

Change the protection on a region of memory.

On platforms that make a distinction between reserving and committing memory, changing the protection to kReadWrite must also ensure the memory is committed.


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