![]() |
v8
V8 is Google’s open source high-performance JavaScript and WebAssembly engine, written in C++.
|
#include <v8-platform.h>
Public Types | |
using | Address = uintptr_t |
Static Public Attributes | |
static constexpr Address | kNoHint = 0 |
Private Attributes | |
const size_t | page_size_ |
const size_t | allocation_granularity_ |
const Address | base_ |
const size_t | size_ |
const PagePermissions | max_page_permissions_ |
Class to manage a virtual memory address space.
This class represents a contiguous region of virtual address space in which sub-spaces and (private or shared) memory pages can be allocated, freed, and modified. This interface is meant to eventually replace the PageAllocator interface, and can be used as an alternative in the meantime.
This API is not yet stable and may change without notice!
Definition at line 740 of file v8-platform.h.
using v8::VirtualAddressSpace::Address = uintptr_t |
Definition at line 742 of file v8-platform.h.
|
inline |
Definition at line 744 of file v8-platform.h.
|
virtualdefault |
|
pure virtual |
Creates a guard region at the specified address.
Guard regions are guaranteed to cause a fault when accessed and generally do not count towards any memory consumption limits. Further, allocating guard regions can usually not fail in subspaces if the region does not overlap with another region, subspace, or page allocation.
address | The start address of the guard region. Must be aligned to the allocation_granularity(). |
size | The size of the guard region in bytes. Must be a multiple of the allocation_granularity(). |
Implemented in v8::base::LsanVirtualAddressSpace.
|
pure virtual |
|
pure virtual |
Allocates shared memory pages with the given permissions.
hint | Placement hint. See AllocatePages. |
size | The size of the allocation in bytes. Must be a multiple of the allocation_granularity(). |
permissions | The page permissions of the newly allocated pages. |
handle | A platform-specific handle to a shared memory object. See the SharedMemoryHandleFromX routines above for ways to obtain these. |
offset | The offset in the shared memory object at which the mapping should start. Must be a multiple of the allocation_granularity(). |
Implemented in v8::base::LsanVirtualAddressSpace.
|
pure virtual |
|
inline |
The granularity of page allocations and, by extension, of subspace allocations. This is guaranteed to be a power of two and a multiple of the page_size(). In practice, this is equal to the page size on most OSes, but on Windows it is usually 64KB, while the page size is 4KB.
Definition at line 772 of file v8-platform.h.
|
inline |
The base address of the address space managed by this instance.
Definition at line 779 of file v8-platform.h.
|
pure virtual |
Whether this instance can allocate subspaces or not.
Implemented in v8::base::LsanVirtualAddressSpace.
|
inline |
Whether the |address| is inside the address space managed by this instance.
Definition at line 801 of file v8-platform.h.
|
pure virtual |
Decommits any wired memory pages in the given range, allowing the OS to reclaim them, and marks the region as inacessible (kNoAccess). The address range stays reserved and can be accessed again later by changing its permissions. However, in that case the memory content is guaranteed to be zero-initialized again. The memory must have been previously allocated by a call to AllocatePages.
Implemented in v8::base::LsanVirtualAddressSpace.
|
inlinevirtual |
Frees memory in the given [address, address + size) range. address and size should be aligned to the page_size(). The next write to this memory area brings the memory transparently back. This should be treated as a hint to the OS that the pages are no longer needed. It does not guarantee that the pages will be discarded immediately or at all.
Reimplemented in v8::base::LsanVirtualAddressSpace.
Definition at line 1017 of file v8-platform.h.
|
pure virtual |
Frees an existing guard region.
This function will terminate the process on failure as this implies a bug in the client. As such, there is no return value.
address | The start address of the guard region to free. This address must have previously been used as address parameter in a successful invocation of AllocateGuardRegion. |
size | The size in bytes of the guard region to free. This must match the size passed to AllocateGuardRegion when the region was created. |
Implemented in v8::base::LsanVirtualAddressSpace.
|
pure virtual |
Frees previously allocated pages.
This function will terminate the process on failure as this implies a bug in the client. As such, there is no return value.
address | The start address of the pages to free. This address must have been obtained through a call to AllocatePages. |
size | The size in bytes of the region to free. This must match the size passed to AllocatePages when the pages were allocated. |
Implemented in v8::base::LsanVirtualAddressSpace.
|
pure virtual |
Frees previously allocated shared pages.
This function will terminate the process on failure as this implies a bug in the client. As such, there is no return value.
address | The start address of the pages to free. This address must have been obtained through a call to AllocateSharedPages. |
size | The size in bytes of the region to free. This must match the size passed to AllocateSharedPages when the pages were allocated. |
Implemented in v8::base::LsanVirtualAddressSpace.
|
inline |
The maximum page permissions that pages allocated inside this space can obtain.
Definition at line 794 of file v8-platform.h.
|
inline |
The page size used inside this space. Guaranteed to be a power of two. Used as granularity for all page-related operations except for allocation, which use the allocation_granularity(), see below.
Definition at line 762 of file v8-platform.h.
|
pure virtual |
Returns a random address inside this address space, suitable for page allocations hints.
Implemented in v8::base::LsanVirtualAddressSpace.
|
pure virtual |
Recommits discarded pages in the given range with given permissions. Discarded pages must be recommitted with their original permissions before they are used again.
address | The start address of the range. Must be aligned to page_size(). |
size | The size in bytes of the range. Must be a multiple of page_size(). |
permissions | The permissions for the range that the pages must have. |
Implemented in v8::base::LsanVirtualAddressSpace.
|
pure virtual |
Sets permissions of all allocated pages in the given range.
This operation can fail due to OOM, in which case false is returned. If the operation fails for a reason other than OOM, this function will terminate the process as this implies a bug in the client.
address | The start address of the range. Must be aligned to page_size(). |
size | The size in bytes of the range. Must be a multiple of page_size(). |
permissions | The new permissions for the range. |
Implemented in v8::base::LsanVirtualAddressSpace.
|
pure virtual |
Sets the random seed so that GetRandomPageAddress() will generate repeatable sequences of random addresses.
The | seed for the PRNG. |
Implemented in v8::base::LsanVirtualAddressSpace.
|
inline |
The size of the address space managed by this instance.
Definition at line 786 of file v8-platform.h.
|
private |
Definition at line 1036 of file v8-platform.h.
|
private |
Definition at line 1037 of file v8-platform.h.
|
staticconstexpr |
Allocates private memory pages with the given alignment and permissions.
hint | If nonzero, the allocation is attempted to be placed at the given address first. If that fails, the allocation is attempted to be placed elsewhere, possibly nearby, but that is not guaranteed. Specifying zero for the hint always causes this function to choose a random address. The hint, if specified, must be aligned to the specified alignment. |
size | The size of the allocation in bytes. Must be a multiple of the allocation_granularity(). |
alignment | The alignment of the allocation in bytes. Must be a multiple of the allocation_granularity() and should be a power of two. |
permissions | The page permissions of the newly allocated pages. |
Definition at line 841 of file v8-platform.h.
|
private |
Definition at line 1039 of file v8-platform.h.
|
private |
Definition at line 1035 of file v8-platform.h.
|
private |
Definition at line 1038 of file v8-platform.h.