v8
V8 is Google’s open source high-performance JavaScript and WebAssembly engine, written in C++.
Loading...
Searching...
No Matches
v8::base::LsanVirtualAddressSpace Class Referencefinal

#include <lsan-virtual-address-space.h>

Inheritance diagram for v8::base::LsanVirtualAddressSpace:
Collaboration diagram for v8::base::LsanVirtualAddressSpace:

Public Member Functions

 LsanVirtualAddressSpace (std::unique_ptr< v8::VirtualAddressSpace > vas)
 
 ~LsanVirtualAddressSpace () override=default
 
void SetRandomSeed (int64_t seed) override
 
Address RandomPageAddress () override
 
Address AllocatePages (Address hint, size_t size, size_t alignment, PagePermissions permissions) override
 
void FreePages (Address address, size_t size) override
 
Address AllocateSharedPages (Address hint, size_t size, PagePermissions permissions, PlatformSharedMemoryHandle handle, uint64_t offset) override
 
void FreeSharedPages (Address address, size_t size) override
 
bool SetPagePermissions (Address address, size_t size, PagePermissions permissions) override
 
bool RecommitPages (Address address, size_t size, PagePermissions permissions) override
 
bool AllocateGuardRegion (Address address, size_t size) override
 
void FreeGuardRegion (Address address, size_t size) override
 
bool CanAllocateSubspaces () override
 
std::unique_ptr< VirtualAddressSpaceAllocateSubspace (Address hint, size_t size, size_t alignment, PagePermissions max_page_permissions) override
 
bool DiscardSystemPages (Address address, size_t size) override
 
bool DecommitPages (Address address, size_t size) override
 
- Public Member Functions inherited from v8::VirtualAddressSpace
 VirtualAddressSpace (size_t page_size, size_t allocation_granularity, Address base, size_t size, PagePermissions max_page_permissions)
 
virtual ~VirtualAddressSpace ()=default
 
size_t page_size () const
 
size_t allocation_granularity () const
 
Address base () const
 
size_t size () const
 
PagePermissions max_page_permissions () const
 
bool Contains (Address address) const
 

Private Attributes

std::unique_ptr< v8::VirtualAddressSpacevas_
 

Additional Inherited Members

- Public Types inherited from v8::VirtualAddressSpace
using Address = uintptr_t
 
- Static Public Attributes inherited from v8::VirtualAddressSpace
static constexpr Address kNoHint = 0
 

Detailed Description

Definition at line 20 of file lsan-virtual-address-space.h.

Constructor & Destructor Documentation

◆ LsanVirtualAddressSpace()

v8::base::LsanVirtualAddressSpace::LsanVirtualAddressSpace ( std::unique_ptr< v8::VirtualAddressSpace > vas)
explicit

Definition at line 17 of file lsan-virtual-address-space.cc.

◆ ~LsanVirtualAddressSpace()

v8::base::LsanVirtualAddressSpace::~LsanVirtualAddressSpace ( )
overridedefault

Member Function Documentation

◆ AllocateGuardRegion()

bool v8::base::LsanVirtualAddressSpace::AllocateGuardRegion ( Address address,
size_t size )
inlineoverridevirtual

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.

Parameters
addressThe start address of the guard region. Must be aligned to the allocation_granularity().
sizeThe size of the guard region in bytes. Must be a multiple of the allocation_granularity().
Returns
true on success, false otherwise.

Implements v8::VirtualAddressSpace.

Definition at line 55 of file lsan-virtual-address-space.h.

◆ AllocatePages()

Address v8::base::LsanVirtualAddressSpace::AllocatePages ( Address hint,
size_t size,
size_t alignment,
PagePermissions permissions )
overridevirtual

Implements v8::VirtualAddressSpace.

Definition at line 26 of file lsan-virtual-address-space.cc.

Here is the call graph for this function:

◆ AllocateSharedPages()

Address v8::base::LsanVirtualAddressSpace::AllocateSharedPages ( Address hint,
size_t size,
PagePermissions permissions,
PlatformSharedMemoryHandle handle,
uint64_t offset )
overridevirtual

Allocates shared memory pages with the given permissions.

Parameters
hintPlacement hint. See AllocatePages.
sizeThe size of the allocation in bytes. Must be a multiple of the allocation_granularity().
permissionsThe page permissions of the newly allocated pages.
handleA platform-specific handle to a shared memory object. See the SharedMemoryHandleFromX routines above for ways to obtain these.
offsetThe offset in the shared memory object at which the mapping should start. Must be a multiple of the allocation_granularity().
Returns
the start address of the allocated pages on success, zero on failure.

Implements v8::VirtualAddressSpace.

Definition at line 45 of file lsan-virtual-address-space.cc.

Here is the call graph for this function:

◆ AllocateSubspace()

std::unique_ptr< VirtualAddressSpace > v8::base::LsanVirtualAddressSpace::AllocateSubspace ( Address hint,
size_t size,
size_t alignment,
PagePermissions max_page_permissions )
overridevirtual

Implements v8::VirtualAddressSpace.

Definition at line 65 of file lsan-virtual-address-space.cc.

Here is the call graph for this function:

◆ CanAllocateSubspaces()

bool v8::base::LsanVirtualAddressSpace::CanAllocateSubspaces ( )
inlineoverridevirtual

Whether this instance can allocate subspaces or not.

Returns
true if subspaces can be allocated, false if not.

Implements v8::VirtualAddressSpace.

Definition at line 63 of file lsan-virtual-address-space.h.

◆ DecommitPages()

bool v8::base::LsanVirtualAddressSpace::DecommitPages ( Address address,
size_t size )
inlineoverridevirtual

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.

Returns
true on success, false otherwise.

Implements v8::VirtualAddressSpace.

Definition at line 73 of file lsan-virtual-address-space.h.

◆ DiscardSystemPages()

bool v8::base::LsanVirtualAddressSpace::DiscardSystemPages ( Address address,
size_t size )
inlineoverridevirtual

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.

Returns
true on success, false otherwise. Since this method is only a hint, a successful invocation does not imply that pages have been removed.

Reimplemented from v8::VirtualAddressSpace.

Definition at line 69 of file lsan-virtual-address-space.h.

◆ FreeGuardRegion()

void v8::base::LsanVirtualAddressSpace::FreeGuardRegion ( Address address,
size_t size )
inlineoverridevirtual

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.

Parameters
addressThe start address of the guard region to free. This address must have previously been used as address parameter in a successful invocation of AllocateGuardRegion.
sizeThe size in bytes of the guard region to free. This must match the size passed to AllocateGuardRegion when the region was created.

Implements v8::VirtualAddressSpace.

Definition at line 59 of file lsan-virtual-address-space.h.

◆ FreePages()

void v8::base::LsanVirtualAddressSpace::FreePages ( Address address,
size_t size )
overridevirtual

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.

Parameters
addressThe start address of the pages to free. This address must have been obtained through a call to AllocatePages.
sizeThe size in bytes of the region to free. This must match the size passed to AllocatePages when the pages were allocated.

Implements v8::VirtualAddressSpace.

Definition at line 38 of file lsan-virtual-address-space.cc.

Here is the call graph for this function:

◆ FreeSharedPages()

void v8::base::LsanVirtualAddressSpace::FreeSharedPages ( Address address,
size_t size )
overridevirtual

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.

Parameters
addressThe start address of the pages to free. This address must have been obtained through a call to AllocateSharedPages.
sizeThe size in bytes of the region to free. This must match the size passed to AllocateSharedPages when the pages were allocated.

Implements v8::VirtualAddressSpace.

Definition at line 58 of file lsan-virtual-address-space.cc.

Here is the call graph for this function:

◆ RandomPageAddress()

Address v8::base::LsanVirtualAddressSpace::RandomPageAddress ( )
inlineoverridevirtual

Returns a random address inside this address space, suitable for page allocations hints.

Returns
a random address aligned to allocation_granularity().

Implements v8::VirtualAddressSpace.

Definition at line 31 of file lsan-virtual-address-space.h.

◆ RecommitPages()

bool v8::base::LsanVirtualAddressSpace::RecommitPages ( Address address,
size_t size,
PagePermissions permissions )
inlineoverridevirtual

Recommits discarded pages in the given range with given permissions. Discarded pages must be recommitted with their original permissions before they are used again.

Parameters
addressThe start address of the range. Must be aligned to page_size().
sizeThe size in bytes of the range. Must be a multiple of page_size().
permissionsThe permissions for the range that the pages must have.
Returns
true on success, false otherwise.

Implements v8::VirtualAddressSpace.

Definition at line 50 of file lsan-virtual-address-space.h.

◆ SetPagePermissions()

bool v8::base::LsanVirtualAddressSpace::SetPagePermissions ( Address address,
size_t size,
PagePermissions permissions )
inlineoverridevirtual

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.

Parameters
addressThe start address of the range. Must be aligned to page_size().
sizeThe size in bytes of the range. Must be a multiple of page_size().
permissionsThe new permissions for the range.
Returns
true on success, false on OOM.

Implements v8::VirtualAddressSpace.

Definition at line 45 of file lsan-virtual-address-space.h.

◆ SetRandomSeed()

void v8::base::LsanVirtualAddressSpace::SetRandomSeed ( int64_t seed)
inlineoverridevirtual

Sets the random seed so that GetRandomPageAddress() will generate repeatable sequences of random addresses.

Parameters
Theseed for the PRNG.

Implements v8::VirtualAddressSpace.

Definition at line 27 of file lsan-virtual-address-space.h.

Member Data Documentation

◆ vas_

std::unique_ptr<v8::VirtualAddressSpace> v8::base::LsanVirtualAddressSpace::vas_
private

Definition at line 78 of file lsan-virtual-address-space.h.


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