![]() |
v8
V8 is Google’s open source high-performance JavaScript and WebAssembly engine, written in C++.
|
#include <v8-array-buffer.h>
Public Types | |
enum class | AllocationMode { kNormal , kReservation } |
Public Member Functions | |
virtual | ~Allocator ()=default |
virtual void * | Allocate (size_t length)=0 |
virtual void * | AllocateUninitialized (size_t length)=0 |
virtual void | Free (void *data, size_t length)=0 |
virtual size_t | MaxAllocationSize () const |
virtual PageAllocator * | GetPageAllocator () |
Static Public Member Functions | |
static Allocator * | NewDefaultAllocator () |
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.
Definition at line 148 of file v8-array-buffer.h.
|
strong |
ArrayBuffer allocation mode. kNormal is a malloc/free style allocation, while kReservation is for larger allocations with the ability to set access permissions.
Enumerator | |
---|---|
kNormal | |
kReservation |
Definition at line 184 of file v8-array-buffer.h.
|
virtualdefault |
|
pure virtual |
Allocate |length| bytes. Return nullptr if allocation is not successful. Memory should be initialized to zeroes.
|
pure virtual |
Allocate |length| bytes. Return nullptr if allocation is not successful. Memory does not have to be initialized.
|
pure virtual |
Free the memory block of size |length|, pointed to by |data|. That memory is guaranteed to be previously allocated by |Allocate|.
|
inlinevirtual |
Returns page allocator used by this Allocator instance.
When the sandbox used by Allocator it is expected that this returns sandbox's page allocator. Otherwise, it should return system page allocator.
Definition at line 193 of file v8-array-buffer.h.
|
inlinevirtual |
Returns a size_t that determines the largest ArrayBuffer that can be allocated. Override if your Allocator is more restrictive than the default. Will only be called once, and the value returned will be cached. Should not return a value that is larger than kMaxByteLength.
Definition at line 177 of file v8-array-buffer.h.
|
static |
Convenience allocator.
When the sandbox is enabled, this allocator will allocate its backing memory inside the default global sandbox. Otherwise, it will rely on malloc/free.
Caller takes ownership, i.e. the returned object needs to be freed using |delete allocator| once it is no longer in use.
Definition at line 8923 of file api.cc.